diff options
Diffstat (limited to 'includes/context')
-rw-r--r-- | includes/context/ContextSource.php | 1 | ||||
-rw-r--r-- | includes/context/DerivativeContext.php | 7 | ||||
-rw-r--r-- | includes/context/IContextSource.php | 3 | ||||
-rw-r--r-- | includes/context/MutableContext.php | 82 | ||||
-rw-r--r-- | includes/context/RequestContext.php | 20 |
5 files changed, 102 insertions, 11 deletions
diff --git a/includes/context/ContextSource.php b/includes/context/ContextSource.php index d526d84b..caf5afaa 100644 --- a/includes/context/ContextSource.php +++ b/includes/context/ContextSource.php @@ -168,6 +168,7 @@ abstract class ContextSource implements IContextSource { * Parameters are the same as wfMessage() * * @since 1.18 + * @param mixed ... * @return Message */ public function msg( /* $args */ ) { diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index 00323cae..09c39396 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -26,7 +26,7 @@ * a different Title instance set on it. * @since 1.19 */ -class DerivativeContext extends ContextSource { +class DerivativeContext extends ContextSource implements MutableContext { /** * @var WebRequest */ @@ -68,6 +68,11 @@ class DerivativeContext extends ContextSource { private $config; /** + * @var Stats + */ + private $stats; + + /** * Constructor * @param IContextSource $context Context to inherit from */ diff --git a/includes/context/IContextSource.php b/includes/context/IContextSource.php index 713c5cbf..58bf5d98 100644 --- a/includes/context/IContextSource.php +++ b/includes/context/IContextSource.php @@ -132,8 +132,9 @@ interface IContextSource { public function getStats(); /** - * Get a Message object with context set + * Get a Message object with context set. See wfMessage for parameters. * + * @param mixed ... * @return Message */ public function msg(); diff --git a/includes/context/MutableContext.php b/includes/context/MutableContext.php new file mode 100644 index 00000000..6358f11c --- /dev/null +++ b/includes/context/MutableContext.php @@ -0,0 +1,82 @@ +<?php +/** + * Request-dependant objects containers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 1.26 + * + * @file + */ + +interface MutableContext { + /** + * Set the Config object + * + * @param Config $c + */ + public function setConfig( Config $c ); + + /** + * Set the WebRequest object + * + * @param WebRequest $r + */ + public function setRequest( WebRequest $r ); + + /** + * Set the Title object + * + * @param Title $t + */ + public function setTitle( Title $t ); + + /** + * Set the WikiPage object + * + * @param WikiPage $p + */ + public function setWikiPage( WikiPage $p ); + + /** + * Set the OutputPage object + * + * @param OutputPage $o + */ + public function setOutput( OutputPage $o ); + + /** + * Set the User object + * + * @param User $u + */ + public function setUser( User $u ); + + /** + * Set the Language object + * + * @param Language|string $l Language instance or language code + */ + public function setLanguage( $l ); + + /** + * Set the Skin object + * + * @param Skin $s + */ + public function setSkin( Skin $s ); + +} diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index 4e790c04..93adde1f 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -25,7 +25,7 @@ /** * Group all the pieces relevant to the context of a request into one instance */ -class RequestContext implements IContextSource { +class RequestContext implements IContextSource, MutableContext { /** * @var WebRequest */ @@ -62,7 +62,7 @@ class RequestContext implements IContextSource { private $skin; /** - * @var StatsdDataFactory + * @var \Liuggio\StatsdClient\Factory\StatsdDataFactory */ private $stats; @@ -131,7 +131,7 @@ class RequestContext implements IContextSource { public function getStats() { if ( $this->stats === null ) { $config = $this->getConfig(); - $prefix = $config->has( 'StatsdMetricPrefix' ) + $prefix = $config->get( 'StatsdMetricPrefix' ) ? rtrim( $config->get( 'StatsdMetricPrefix' ), '.' ) : 'MediaWiki'; $this->stats = new BufferingStatsdDataFactory( $prefix ); @@ -380,7 +380,6 @@ class RequestContext implements IContextSource { */ public function getSkin() { if ( $this->skin === null ) { - $skin = null; Hooks::run( 'RequestContextCreateSkin', array( $this, &$skin ) ); $factory = SkinFactory::getDefaultInstance(); @@ -428,6 +427,7 @@ class RequestContext implements IContextSource { * Get a Message object with context set * Parameters are the same as wfMessage() * + * @param mixed ... * @return Message */ public function msg() { @@ -495,15 +495,17 @@ class RequestContext implements IContextSource { /** * Import an client IP address, HTTP headers, user ID, and session ID * - * This sets the current session and sets $wgUser and $wgRequest. + * This sets the current session, $wgUser, and $wgRequest from $params. * Once the return value falls out of scope, the old context is restored. - * This method should only be called in contexts (CLI or HTTP job runners) - * where there is no session ID or end user receiving the response. This + * This method should only be called in contexts where there is no session + * ID or end user receiving the response (CLI or HTTP job runners). This * is partly enforced, and is done so to avoid leaking cookies if certain * error conditions arise. * - * This will setup the session from the given ID. This is useful when - * background scripts inherit context when acting on behalf of a user. + * This is useful when background scripts inherit context when acting on + * behalf of a user. In general the 'sessionId' parameter should be set + * to an empty string unless session importing is *truly* needed. This + * feature is somewhat deprecated. * * @note suhosin.session.encrypt may interfere with this method. * |