final public function getContext() {
if ( $this->context instanceof IContextSource ) {
return $this->context;
- } else if ( $this->page instanceof Article ) {
+ } elseif ( $this->page instanceof Article ) {
// NOTE: $this->page can be a WikiPage, which does not have a context.
wfDebug( __METHOD__ . ': no context known, falling back to Article\'s context.' );
return $this->page->getContext();
* - user: DB user
* - password: DB password
* - type: "mysql" or "postgres"
- * - load: ratio of DB_SLAVE load, must be >=0, the sum of all loads must be >0
+ *
+ * - load: Ratio of DB_SLAVE load, must be >=0, the sum of all loads must be >0.
+ * If this is zero for any given server, no normal query traffic will be
+ * sent to it. It will be excluded from lag checks in maintenance scripts.
+ * The only way it can receive traffic is if groupLoads is used.
+ *
* - groupLoads: array of load ratios, the key is the query group name. A query may belong
* to several groups, the most specific group defined here is used.
*
* @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
*/
function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) {
- if( $cluster !== false ) {
+ if ( $cluster !== false ) {
$lb = wfGetLBFactory()->getExternalLB( $cluster );
} else {
$lb = wfGetLB( $wiki );
$subsectionHtml = '';
$hasLabel = false;
- switch( $displayFormat ) {
+ switch ( $displayFormat ) {
case 'table':
$getFieldHtmlMethod = 'getTableRow';
break;
$params['width'] = $width;
$params['height'] = $height;
$thumbnail = $this->displayImg->transform( $params );
+ Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params );
$anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall );
* @param MediaOutput $thumb
* @param array $hp image parameters
*/
- protected static function processResponsiveImages( $file, $thumb, $hp ) {
+ public static function processResponsiveImages( $file, $thumb, $hp ) {
global $wgResponsiveImages;
if ( $wgResponsiveImages ) {
$hp15 = $hp;
}
}
+ /**
+ * If the user is not logged in, throws UserNotLoggedIn error.
+ *
+ * Default error message includes a link to Special:Userlogin with properly set 'returnto' query
+ * parameter.
+ *
+ * @since 1.23
+ * @param string|Message $reasonMsg [optional] Passed on to UserNotLoggedIn constructor. Strings
+ * will be used as message keys. If a string is given, the message will also receive a
+ * formatted login link (generated using the 'loginreqlink' message) as first parameter. If a
+ * Message is given, it will be passed on verbatim.
+ * @param string|Message $titleMsg [optional] Passed on to UserNotLoggedIn constructor. Strings
+ * will be used as message keys.
+ * @throws UserNotLoggedIn
+ */
+ public function requireLogin( $reasonMsg = null, $titleMsg = null ) {
+ if ( $this->getUser()->isAnon() ) {
+ // Use default messages if not given or explicit null passed
+ if ( !$reasonMsg ) {
+ $reasonMsg = 'exception-nologin-text-manual';
+ }
+ if ( !$titleMsg ) {
+ $titleMsg = 'exception-nologin';
+ }
+
+ // Convert to Messages with current context
+ if ( is_string( $reasonMsg ) ) {
+ $loginreqlink = Linker::linkKnown(
+ SpecialPage::getTitleFor( 'Userlogin' ),
+ $this->msg( 'loginreqlink' )->escaped(),
+ array(),
+ array( 'returnto' => $this->getTitle()->getPrefixedText() )
+ );
+ $reasonMsg = $this->msg( $reasonMsg )->rawParams( $loginreqlink );
+ }
+ if ( is_string( $titleMsg ) ) {
+ $titleMsg = $this->msg( $titleMsg );
+ }
+
+ throw new UserNotLoggedIn( $reasonMsg, $titleMsg );
+ }
+ }
+
/**
* Sets headers - this should be called from the execute() method of all derived classes!
*/
$langObj = wfGetLangObj( $contentHandler->getPageLanguage( $this ) );
$this->mPageLanguage = array( $langObj->getCode(), $wgLanguageCode );
} else {
- $langObj = wfGetLangObj( $this->mPageLanguage[0] );
+ $langObj = wfGetLangObj( $this->mPageLanguage[0] );
}
wfProfileOut( __METHOD__ );
return $langObj;
'meta' => 'Which metadata to get about the site. Module help is available below',
'indexpageids' => 'Include an additional pageids section listing all returned page IDs',
'export' => 'Export the current revisions of all given or generated pages',
- 'exportnowrap' => 'Return the export XML without wrapping it in an '.
+ 'exportnowrap' => 'Return the export XML without wrapping it in an ' .
'XML result (same format as Special:Export). Can only be used with export',
'iwurl' => 'Whether to get the full URL if the title is an interwiki link',
'continue' => array(
);
}
- if ( !$startId && !$endId && $res->numRows() < $max ) {
+ if ( $select === 'all' && !$startId && !$endId && $res->numRows() < $max ) {
// The full results fit within the limit, so cache them
$this->fullResultCache[$table] = $res;
} else {
protected $serializer;
/** @} */
- /** @var integer Current idle pool size */
+ /** @var int Current idle pool size */
protected $idlePoolSize = 0;
- /** @var Array (server name => ((connection info array),...) */
+ /** @var array (server name => ((connection info array),...) */
protected $connections = array();
- /** @var Array (server name => UNIX timestamp) */
+ /** @var array (server name => UNIX timestamp) */
protected $downServers = array();
- /** @var Array (pool ID => RedisConnectionPool) */
+ /** @var array (pool ID => RedisConnectionPool) */
protected static $instances = array();
/** integer; seconds to cache servers as "down". */
/**
* @param array $options
+ * @throws MWException
*/
protected function __construct( array $options ) {
if ( !class_exists( 'Redis' ) ) {
}
/**
- * @param $options Array
- * @return Array
+ * @param array $options
+ * @return array
*/
protected static function applyDefaultConfig( array $options ) {
if ( !isset( $options['connectTimeout'] ) ) {
}
/**
- * @param $options Array
+ * @param array $options
* $options include:
* - connectTimeout : The timeout for new connections, in seconds.
* Optional, default is 1 second.
/**
* Mark a connection to a server as free to return to the pool
*
- * @param $server string
- * @param $conn Redis
- * @return boolean
+ * @param string $server
+ * @param Redis $conn
+ * @return bool
*/
public function freeConnection( $server, Redis $conn ) {
$found = false;
/**
* Close any extra idle connections if there are more than the limit
- *
- * @return void
*/
protected function closeExcessIdleConections() {
if ( $this->idlePoolSize <= count( $this->connections ) ) {
return; // nothing to do (no more connections than servers)
}
- foreach ( $this->connections as $server => &$serverConnections ) {
+ foreach ( $this->connections as &$serverConnections ) {
foreach ( $serverConnections as $key => &$connection ) {
if ( $connection['free'] ) {
unset( $serverConnections[$key] );
* not. The safest response for us is to explicitly destroy the connection
* object and let it be reopened during the next request.
*
- * @param $server string
- * @param $cref RedisConnRef
- * @param $e RedisException
- * @return void
+ * @param string $server
+ * @param RedisConnRef $cref
+ * @param RedisException $e
*/
public function handleException( $server, RedisConnRef $cref, RedisException $e ) {
wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() . "\n" );
protected $lastError; // string
/**
- * @param $pool RedisConnectionPool
- * @param $server string
- * @param $conn Redis
+ * @param RedisConnectionPool $pool
+ * @param string $server
+ * @param Redis $conn
*/
public function __construct( RedisConnectionPool $pool, $server, Redis $conn ) {
$this->pool = $pool;
}
/**
- * @param RedisConnRef $conn
+ * @param Redis $conn
* @return bool
*/
public function isConnIdentical( Redis $conn ) {
* @ingroup Content
*/
abstract class AbstractContent implements Content {
-
/**
* Name of the content model this Content object represents.
* Use with CONTENT_MODEL_XXX constants
break;
}
// Redirects to some special pages are not permitted
- if ( $newtitle instanceOf Title && $newtitle->isValidRedirectTarget() ) {
+ if ( $newtitle instanceof Title && $newtitle->isValidRedirectTarget() ) {
// The new title passes the checks, so make that our current
// title so that further recursion can be checked
$title = $newtitle;
break;
}
}
+
return $titles;
}
*/
public function getUltimateRedirectTarget() {
$titles = $this->getRedirectChain();
+
return $titles ? array_pop( $titles ) : null;
}
* database after deletion.
*/
public function getDeletionUpdates( WikiPage $page,
- ParserOutput $parserOutput = null )
- {
+ ParserOutput $parserOutput = null
+ ) {
return array(
new LinksDeletionUpdate( $page ),
);
}
/**
- * This default implementation always returns false. Subclasses may override this to supply matching logic.
+ * This default implementation always returns false. Subclasses may override
+ * this to supply matching logic.
*
* @see Content::matchMagicWord
*
* This base implementation calls the hook ConvertContent to enable custom conversions.
* Subclasses may override this to implement conversion for "their" content model.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
+ * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
+ * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
* not allowed, full round-trip conversion is expected to work without losing information.
*
* @return Content|bool A content object with the content model $toModel, or false if
$result = false;
wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) );
+
return $result;
}
}
* @ingroup Content
*/
interface Content {
-
/**
* @since 1.21
*
public function getParserOutput( Title $title,
$revId = null,
ParserOptions $options = null, $generateHtml = true );
+
// TODO: make RenderOutput and RenderOptions base classes
/**
*
* @param Title $target the new redirect target
*
- * @return Content a new Content object with the updated redirect (or $this if this Content object isn't a redirect)
+ * @return Content a new Content object with the updated redirect (or $this
+ * if this Content object isn't a redirect)
*/
public function updateRedirect( Title $target );
* This may be used to check the content's consistency with global state. This function should
* NOT write any information to the database.
*
- * Note that this method will usually be called inside the same transaction bracket that will be used
- * to save the new revision.
+ * Note that this method will usually be called inside the same transaction
+ * bracket that will be used to save the new revision.
*
- * Note that this method is called before any update to the page table is performed. This means that
- * $page may not yet know a page ID.
+ * Note that this method is called before any update to the page table is
+ * performed. This means that $page may not yet know a page ID.
*
* @since 1.21
*
* @param WikiPage $page The page to be saved.
- * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
- * @param int $baseRevId the ID of the current revision
- * @param User $user
+ * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
+ * @param int $baseRevId the ID of the current revision
+ * @param User $user
*
- * @return Status A status object indicating whether the content was successfully prepared for saving.
- * If the returned status indicates an error, a rollback will be performed and the
- * transaction aborted.
+ * @return Status A status object indicating whether the content was
+ * successfully prepared for saving. If the returned status indicates
+ * an error, a rollback will be performed and the transaction aborted.
*
* @see see WikiPage::doEditContent()
*/
* Converts this content object into another content object with the given content model,
* if that is possible.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
+ * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
+ * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
* not allowed, full round-trip conversion is expected to work without losing information.
*
* @return Content|bool A content object with the content model $toModel, or false if
* that conversion is not supported.
*/
public function convert( $toModel, $lossy = '' );
-
- // TODO: ImagePage and CategoryPage interfere with per-content action handlers
- // TODO: nice&sane integration of GeSHi syntax highlighting
+ // @todo ImagePage and CategoryPage interfere with per-content action handlers
+ // @todo nice&sane integration of GeSHi syntax highlighting
// [11:59] <vvv> Hooks are ugly; make CodeHighlighter interface and a
// config to set the class which handles syntax highlighting
// [12:00] <vvv> And default it to a DummyHighlighter
* @ingroup Content
*/
class MWContentSerializationException extends MWException {
-
}
/**
* @ingroup Content
*/
abstract class ContentHandler {
-
/**
* Switch for enabling deprecation warnings. Used by ContentHandler::deprecated()
* and ContentHandler::runLegacyHooks().
* not be unserialized using $format.
*/
public static function makeContent( $text, Title $title = null,
- $modelId = null, $format = null )
- {
+ $modelId = null, $format = null
+ ) {
if ( is_null( $modelId ) ) {
if ( is_null( $title ) ) {
throw new MWException( "Must provide a Title object or a content model ID." );
}
$handler = ContentHandler::getForModelID( $modelId );
+
return $handler->unserializeContent( $text, $format );
}
*/
public static function getForTitle( Title $title ) {
$modelId = $title->getContentModel();
+
return ContentHandler::getForModelID( $modelId );
}
*/
public static function getForContent( Content $content ) {
$modelId = $content->getModel();
+
return ContentHandler::getForModelID( $modelId );
}
/**
- * @var Array A Cache of ContentHandler instances by model id
+ * @var array A Cache of ContentHandler instances by model id
*/
- static $handlers;
+ protected static $handlers;
/**
* Returns the ContentHandler singleton for the given model ID. Use the
$handler = new $class( $modelId );
if ( !( $handler instanceof ContentHandler ) ) {
- throw new MWException( "$class from \$wgContentHandlers is not compatible with ContentHandler" );
+ throw new MWException( "$class from \$wgContentHandlers is not " .
+ "compatible with ContentHandler" );
}
}
wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
- . ': ' . get_class( $handler ) );
+ . ': ' . get_class( $handler ) );
ContentHandler::$handlers[$modelId] = $handler;
+
return ContentHandler::$handlers[$modelId];
}
}
$formats = array_unique( $formats );
+
return $formats;
}
/**
* Get the language in which the content of the given page is written.
*
- * This default implementation just returns $wgContLang (except for pages in the MediaWiki namespace)
+ * This default implementation just returns $wgContLang (except for pages
+ * in the MediaWiki namespace)
*
- * Note that the pages language is not cacheable, since it may in some cases depend on user settings.
+ * Note that the pages language is not cacheable, since it may in some
+ * cases depend on user settings.
*
* Also note that the page language may or may not depend on the actual content of the page,
* that is, this method may load the content in order to determine the language.
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
+ * @param Title $title the page to determine the language for.
* @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
*
* @return Language the page's language
}
wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
+
return wfGetLangObj( $pageLang );
}
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
+ * @param Title $title the page to determine the language for.
* @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
*
* @return Language the page's language for viewing
if ( is_object( $rt ) ) {
if ( !is_object( $ot )
|| !$rt->equals( $ot )
- || $ot->getFragment() != $rt->getFragment() )
- {
+ || $ot->getFragment() != $rt->getFragment()
+ ) {
$truncatedtext = $newContent->getTextForSummary(
250
- - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
- - strlen( $rt->getFullText() ) );
+ - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
+ - strlen( $rt->getFullText() ) );
return wfMessage( 'autoredircomment', $rt->getFullText() )
- ->rawParams( $truncatedtext )->inContentLanguage()->text();
+ ->rawParams( $truncatedtext )->inContentLanguage()->text();
}
}
200 - strlen( wfMessage( 'autosumm-new' )->inContentLanguage()->text() ) );
return wfMessage( 'autosumm-new' )->rawParams( $truncatedtext )
- ->inContentLanguage()->text();
+ ->inContentLanguage()->text();
}
// Blanking auto-summaries
return wfMessage( 'autosumm-blank' )->inContentLanguage()->text();
} elseif ( !empty( $oldContent )
&& $oldContent->getSize() > 10 * $newContent->getSize()
- && $newContent->getSize() < 500 )
- {
+ && $newContent->getSize() < 500
+ ) {
// Removing more than 90% of the article
$truncatedtext = $newContent->getTextForSummary(
200 - strlen( wfMessage( 'autosumm-replace' )->inContentLanguage()->text() ) );
return wfMessage( 'autosumm-replace' )->rawParams( $truncatedtext )
- ->inContentLanguage()->text();
+ ->inContentLanguage()->text();
}
// If we reach this point, there's no applicable auto-summary for our
* Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
* self::$enableDeprecationWarnings is set to true.
*
- * @param string $func The name of the deprecated function
- * @param string $version The version since the method is deprecated. Usually 1.21
- * for ContentHandler related stuff.
- * @param string|bool $component: Component to which the function belongs.
- * If false, it is assumed the function is in MediaWiki core.
+ * @param string $func The name of the deprecated function
+ * @param string $version The version since the method is deprecated. Usually 1.21
+ * for ContentHandler related stuff.
+ * @param string|bool $component : Component to which the function belongs.
+ * If false, it is assumed the function is in MediaWiki core.
*
* @see ContentHandler::$enableDeprecationWarnings
* @see wfDeprecated
* @see ContentHandler::$enableDeprecationWarnings
*/
public static function runLegacyHooks( $event, $args = array(),
- $warn = null ) {
+ $warn = null
+ ) {
if ( $warn === null ) {
$warn = self::$enableDeprecationWarnings;
wfRestoreWarnings();
- wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " . implode( ', ', $handlerInfo ), 2 );
+ wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " .
+ implode( ', ', $handlerInfo ), 2 );
}
// convert Content objects to text
* @ingroup Content
*/
class CssContentHandler extends TextContentHandler {
-
public function __construct( $modelId = CONTENT_MODEL_CSS ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) );
}
/**
* Returns the english language, because CSS is english, and should be handled as such.
*
+ * @param Title $title
+ * @param Content $content
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageLanguage()
/**
* Returns the english language, because CSS is english, and should be handled as such.
*
+ * @param Title $title
+ * @param Content $content
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageViewLanguage()
* @todo make ScriptContentHandler base class, do highlighting stuff there?
*/
class JavaScriptContentHandler extends TextContentHandler {
-
public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
}
/**
* Returns the english language, because JS is english, and should be handled as such.
*
+ * @param Title $title
+ * @param Content $content
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageLanguage()
/**
* Returns the english language, because JS is english, and should be handled as such.
*
+ * @param Title $title
+ * @param Content $content
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageViewLanguage()
* @ingroup Content
*/
class MessageContent extends AbstractContent {
-
/**
* @var Message
*/
protected $mMessage;
/**
- * @param Message|String $msg A Message object, or a message key
- * @param array|null $params An optional array of message parameters
+ * @param Message|String $msg A Message object, or a message key
+ * @param array|null $params An optional array of message parameters
*/
public function __construct( $msg, $params = null ) {
# XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
/**
* @see Content::isCountable
*
+ * @param bool $hasLinks
* @return bool false
*/
public function isCountable( $hasLinks = null ) {
/**
* @see Content::getParserOutput
*
+ * @param Title $title
+ * @param int $revId Optional revision ID
+ * @param ParserOptions $options
+ * @param bool $generateHtml Wether to generate HTML
* @return ParserOutput
*/
public function getParserOutput(
}
$po = new ParserOutput( $html );
+
return $po;
}
}
* @ingroup Content
*/
class TextContent extends AbstractContent {
-
public function __construct( $text, $model_id = CONTENT_MODEL_TEXT ) {
parent::__construct( $model_id );
if ( $text === null || $text === false ) {
wfWarn( "TextContent constructed with \$text = " . var_export( $text, true ) . "! "
- . "This may indicate an error in the caller's scope." );
+ . "This may indicate an error in the caller's scope." );
$text = '';
}
*/
public function getSize() {
$text = $this->getNativeData();
+
return strlen( $text );
}
*/
public function getNativeData() {
$text = $this->mText;
+
return $text;
}
$nta = explode( "\n", $lang->segmentForDiff( $ntext ) );
$diff = new Diff( $ota, $nta );
+
return $diff;
}
}
$po->setText( $html );
+
return $po;
}
* This implementation provides lossless conversion between content models based
* on TextContent.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
+ * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
+ * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
* not allowed, full round-trip conversion is expected to work without losing information.
*
* @return Content|bool A content object with the content model $toModel, or false if
* @ingroup Content
*/
class TextContentHandler extends ContentHandler {
-
- public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = array( CONTENT_FORMAT_TEXT ) ) {
+ public function __construct( $modelId = CONTENT_MODEL_TEXT,
+ $formats = array( CONTENT_FORMAT_TEXT )
+ ) {
parent::__construct( $modelId, $formats );
}
*/
public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
+
return $content->getNativeData();
}
}
$mergedContent = $this->unserializeContent( $result, $format );
+
return $mergedContent;
}
* @ingroup Content
*/
class WikitextContent extends TextContent {
-
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_WIKITEXT );
}
if ( $section === '' ) {
wfProfileOut( __METHOD__ );
+
return $with; # XXX: copy first?
- } if ( $section == 'new' ) {
+ }
+
+ if ( $section == 'new' ) {
# Inserting a new section
$subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' )
- ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
+ ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
$text = strlen( trim( $oldtext ) ) > 0
? "{$oldtext}\n\n{$subject}{$text}"
$newContent = new WikitextContent( $text );
wfProfileOut( __METHOD__ );
+
return $newContent;
}
if ( !$title instanceof Title || !$title->isValidRedirectTarget() ) {
return null;
}
+
return $title;
}
}
+
return null;
}
/**
- * @see Content::updateRedirect()
+ * @see Content::updateRedirect()
*
* This implementation replaces the first link on the page with the given new target
* if this Content object is a redirect. Otherwise, this method returns $this.
*
* @param Title $target
*
- * @return Content a new Content object with the updated redirect (or $this if this Content object isn't a redirect)
+ * @return Content a new Content object with the updated redirect (or $this
+ * if this Content object isn't a redirect)
*/
public function updateRedirect( Title $target ) {
if ( !$this->isRedirect() ) {
* Returns true if this content is not a redirect, and this content's text
* is countable according to the criteria defined by $wgArticleCountMethod.
*
- * @param bool $hasLinks if it is known whether this content contains
+ * @param bool $hasLinks if it is known whether this content contains
* links, provide this information here, to avoid redundant parsing to
* find out (default: null).
* @param $title Title: (default: null)
}
$po = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
+
return $po;
}
* @ingroup Content
*/
class WikitextContentHandler extends TextContentHandler {
-
public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
}
}
$mwRedir = MagicWord::get( 'redirect' );
- $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
+ $redirectText = $mwRedir->getSynonym( 0 ) .
+ ' [[' . $optionalColon . $destination->getFullText() . ']]';
+
if ( $text != '' ) {
$redirectText .= "\n" . $text;
}
public function getContext() {
if ( $this->context === null ) {
$class = get_class( $this );
- wfDebug( __METHOD__ . " ($class): called and \$context is null. Using RequestContext::getMain() for sanity\n" );
+ wfDebug( __METHOD__ . " ($class): called and \$context is null. " .
+ "Using RequestContext::getMain() for sanity\n" );
$this->context = RequestContext::getMain();
}
+
return $this->context;
}
*/
public function getLang() {
wfDeprecated( __METHOD__, '1.19' );
+
return $this->getLanguage();
}
*/
public function msg( /* $args */ ) {
$args = func_get_args();
+
return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
}
* Set the Title object
*
* @param Title $t
+ * @throws MWException
*/
public function setTitle( $t ) {
if ( $t !== null && !$t instanceof Title ) {
*/
public function msg() {
$args = func_get_args();
+
return call_user_func_array( 'wfMessage', $args )->setContext( $this );
}
}
global $wgRequest; # fallback to $wg till we can improve this
$this->request = $wgRequest;
}
+
return $this->request;
}
* Set the Title object
*
* @param Title $t
+ * @throws MWException
*/
public function setTitle( $t ) {
if ( $t !== null && !$t instanceof Title ) {
global $wgTitle; # fallback to $wg till we can improve this
$this->title = $wgTitle;
}
+
return $this->title;
}
}
$this->wikipage = WikiPage::factory( $title );
}
+
return $this->wikipage;
}
if ( $this->output === null ) {
$this->output = new OutputPage( $this );
}
+
return $this->output;
}
if ( $this->user === null ) {
$this->user = User::newFromSession( $this->getRequest() );
}
+
return $this->user;
}
*/
public function getLang() {
wfDeprecated( __METHOD__, '1.19' );
+
return $this->getLanguage();
}
$this->skin->setContext( $this );
wfProfileOut( __METHOD__ . '-createskin' );
}
+
return $this->skin;
}
*/
public function msg() {
$args = func_get_args();
+
return call_user_func_array( 'wfMessage', $args )->setContext( $this );
}
if ( $instance === null ) {
$instance = new self;
}
+
return $instance;
}
$user = User::newFromName( $params['ip'], false );
}
- $importSessionFunction = function( User $user, array $params ) {
+ $importSessionFunction = function ( User $user, array $params ) {
global $wgRequest, $wgUser;
$context = RequestContext::getMain();
$importSessionFunction( $user, $params );
// Set callback to save and close the new session and reload the old one
- return new ScopedCallback( function() use ( $importSessionFunction, $oUser, $oParams ) {
+ return new ScopedCallback( function () use ( $importSessionFunction, $oUser, $oParams ) {
$importSessionFunction( $oUser, $oParams );
} );
}
$context->setRequest( new FauxRequest( $request ) );
}
$context->user = User::newFromName( '127.0.0.1', false );
+
return $context;
}
}
* @author Daniel Kinzler
*/
abstract class DBAccessBase implements IDBAccessObject {
-
/**
* @var String|bool $wiki The target wiki's name. This must be an ID
* that LBFactory can understand.
*/
protected function getConnection( $id, $groups = array() ) {
$loadBalancer = wfGetLB( $this->wiki );
+
return $loadBalancer->getConnection( $id, $groups, $this->wiki );
}
*
* @since 1.21
*
- * @param DatabaseBase $db the database connection to release.
+ * @param DatabaseBase $db the database connection to release.
*/
protected function releaseConnection( DatabaseBase $db ) {
if ( $this->wiki !== false ) {
public function addIdentifierQuotes( $s ) {
// Characters in the range \u0001-\uFFFF are valid in a quoted identifier
// Remove NUL bytes and escape backticks by doubling
- return '`' . str_replace( array( "\0", '`' ), array( '', '``' ), $s ) . '`';
+ return '`' . str_replace( array( "\0", '`' ), array( '', '``' ), $s ) . '`';
}
/**
// Query for the VIEWS
$result = $this->query( 'SHOW FULL TABLES WHERE TABLE_TYPE = "VIEW"' );
$this->allViews = array();
- while ( ($row = $this->fetchRow($result)) !== false ) {
+ while ( ( $row = $this->fetchRow( $result ) ) !== false ) {
array_push( $this->allViews, $row[$propertyName] );
}
}
- if ( is_null($prefix) || $prefix === '' ) {
+ if ( is_null( $prefix ) || $prefix === '' ) {
return $this->allViews;
}
}
protected function mysqlError( $conn = null ) {
- if ($conn === null) {
+ if ( $conn === null ) {
return mysqli_connect_error();
} else {
return $conn->error;
wfProfileIn( __METHOD__ );
$this->mWaitForPos = $pos;
for ( $i = 1; $i < count( $this->mServers ); $i++ ) {
- $this->doWait( $i, true );
+ if ( $this->mLoads[$i] > 0 ) {
+ $this->doWait( $i, true );
+ }
}
wfProfileOut( __METHOD__ );
}
'img_media_type' => $this->media_type,
'img_major_mime' => $major,
'img_minor_mime' => $minor,
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1,
),
array( 'img_name' => $this->getName() ),
'img_description' => $comment,
'img_user' => $user->getId(),
'img_user_text' => $user->getName(),
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1
),
__METHOD__,
'img_description' => $comment,
'img_user' => $user->getId(),
'img_user_text' => $user->getName(),
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1
),
array( 'img_name' => $this->getName() ),
protected function disableContentHandlerUseDB() {
global $wgContentHandlerUseDB;
- if( $wgContentHandlerUseDB ) {
+ if ( $wgContentHandlerUseDB ) {
$this->output( "Turning off Content Handler DB fields for this part of upgrade.\n" );
$this->holdContentHandlerUseDB = $wgContentHandlerUseDB;
$wgContentHandlerUseDB = false;
protected function enableContentHandlerUseDB() {
global $wgContentHandlerUseDB;
- if( $this->holdContentHandlerUseDB ) {
+ if ( $this->holdContentHandlerUseDB ) {
$this->output( "Content Handler DB fields should be usable now.\n" );
$wgContentHandlerUseDB = $this->holdContentHandlerUseDB;
}
$defaultItem = $vals['x-default'];
unset( $vals['x-default'] );
}
- foreach( $priorityLanguages as $pLang ) {
+ foreach ( $priorityLanguages as $pLang ) {
if ( isset( $vals[$pLang] ) ) {
$isDefault = false;
if ( $vals[$pLang] === $defaultItem ) {
// This is an API-specific function so it would be cleaner to call it from
// outside fetchExtendedMetadata, but this way we don't need to redo the
// computation on a cache hit.
- $this->sanitizeArrayForXml($extendedMetadata);
+ $this->sanitizeArrayForXml( $extendedMetadata );
$valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() );
$wgMemc->set( $cacheKey, $valueToCache, $maxCacheTime );
}
// choose the language best matching user or site settings
$priorityLanguages = $this->getPriorityLanguages();
- foreach( $priorityLanguages as $lang ) {
+ foreach ( $priorityLanguages as $lang ) {
if ( isset( $value[$lang] ) ) {
return $value[$lang];
}
}
// otherwise just return any one language
- unset($value['_type']);
- if (!empty($value)) {
- return reset($value);
+ unset( $value['_type'] );
+ if ( !empty( $value ) ) {
+ return reset( $value );
}
// this should not happen; signal error
$text = str_replace( array( Parser::TOC_START, Parser::TOC_END ), '', $text );
} else {
$text = preg_replace(
- '#'. preg_quote( Parser::TOC_START ) . '.*?' . preg_quote( Parser::TOC_END ) . '#s',
+ '#' . preg_quote( Parser::TOC_START ) . '.*?' . preg_quote( Parser::TOC_END ) . '#s',
'',
$text
);
*/
public function getAllStyleFiles() {
$files = array();
- foreach( (array)$this->styles as $key => $value ) {
+ foreach ( (array)$this->styles as $key => $value ) {
if ( is_array( $value ) ) {
$path = $key;
} else {
$user = $this->getUser();
$request = $this->getRequest();
- if ( !$user->isLoggedIn() ) {
- $this->error( 'changeemail-no-info' );
-
- return;
- }
+ $this->requireLogin( 'changeemail-no-info' );
if ( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) {
$this->doReturnTo();
// This could also let someone check the current email address, so
// require both permissions.
- if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) {
+ if ( !$user->isAllowed( 'viewmyprivateinfo' ) ) {
throw new PermissionsError( 'viewmyprivateinfo' );
}
$this->getOutput()->disallowUserJs();
$request = $this->getRequest();
+
+ if ( !$request->wasPosted() ) {
+ $this->requireLogin( 'resetpass-no-info' );
+ }
+
$this->mUserName = trim( $request->getVal( 'wpName' ) );
$this->mOldpass = $request->getVal( 'wpPassword' );
$this->mNewpass = $request->getVal( 'wpNewPassword' );
$this->mDomain = $request->getVal( 'wpDomain' );
$user = $this->getUser();
- if ( !$request->wasPosted() && !$user->isLoggedIn() ) {
- $this->error( $this->msg( 'resetpass-no-info' )->text() );
-
- return;
- }
if ( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) {
$titleObj = Title::newFromText( $request->getVal( 'returnto' ) );
$this->checkReadOnly();
$this->checkPermissions();
+ $this->requireLogin( 'confirmemail_needlogin' );
+
// This could also let someone check the current email address, so
// require both permissions.
if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) {
}
if ( $code === null || $code === '' ) {
- if ( $this->getUser()->isLoggedIn() ) {
- if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) {
- $this->showRequestForm();
- } else {
- $this->getOutput()->addWikiMsg( 'confirmemail_noemail' );
- }
+ if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) {
+ $this->showRequestForm();
} else {
- $llink = Linker::linkKnown(
- SpecialPage::getTitleFor( 'Userlogin' ),
- $this->msg( 'loginreqlink' )->escaped(),
- array(),
- array( 'returnto' => $this->getTitle()->getPrefixedText() )
- );
- $this->getOutput()->addHTML(
- $this->msg( 'confirmemail_needlogin' )->rawParams( $llink )->parse()
- );
+ $this->getOutput()->addWikiMsg( 'confirmemail_noemail' );
}
} else {
$this->attemptConfirm( $code );
public function execute( $mode ) {
$this->setHeaders();
- $out = $this->getOutput();
-
# Anons don't get a watchlist
- if ( $this->getUser()->isAnon() ) {
- $out->setPageTitle( $this->msg( 'watchnologin' ) );
- $llink = Linker::linkKnown(
- SpecialPage::getTitleFor( 'Userlogin' ),
- $this->msg( 'loginreqlink' )->escaped(),
- array(),
- array( 'returnto' => $this->getTitle()->getPrefixedText() )
- );
- $out->addHTML( $this->msg( 'watchlistanontext' )->rawParams( $llink )->parse() );
+ $this->requireLogin( 'watchlistanontext', 'watchnologin' );
- return;
- }
+ $out = $this->getOutput();
$this->checkPermissions();
$this->checkReadOnly();
}
$field = $prefix . substr( $field, 3 ) . ' AS ' . $field;
}
- $fields[array_search('top', $fields)] = "'no' AS top";
+ $fields[array_search( 'top', $fields )] = "'no' AS top";
} else {
if ( $this->mShowAll ) {
$fields[array_search( 'top', $fields )] = "'yes' AS top";
$out = $this->getOutput();
$out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
- $user = $this->getUser();
- if ( $user->isAnon() ) {
- throw new ErrorPageError(
- 'prefsnologin',
- 'prefsnologintext',
- array( $this->getTitle()->getPrefixedDBkey() )
- );
- }
+ $this->requireLogin( 'prefsnologintext2', 'prefsnologin' );
$this->checkReadOnly();
if ( $par == 'reset' ) {
);
}
- $htmlForm = Preferences::getFormObject( $user, $this->getContext() );
+ $htmlForm = Preferences::getFormObject( $this->getUser(), $this->getContext() );
$htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
$htmlForm->show();
public function execute( $par ) {
// This is a preferences page, so no user JS for y'all.
$this->getOutput()->disallowUserJs();
+ $this->requireLogin();
parent::execute( $par );
}
if ( $includesRestrictedPages || $includesCachedPages ) {
+ $out->wrapWikiMsg( "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top' );
$out->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );
}
}
$output = $this->getOutput();
# Anons don't get a watchlist
- if ( $user->isAnon() ) {
- $output->setPageTitle( $this->msg( 'watchnologin' ) );
- $output->setRobotPolicy( 'noindex,nofollow' );
- $llink = Linker::linkKnown(
- SpecialPage::getTitleFor( 'Userlogin' ),
- $this->msg( 'loginreqlink' )->escaped(),
- array(),
- array( 'returnto' => $this->getTitle()->getPrefixedText() )
- );
- $output->addHTML( $this->msg( 'watchlistanontext' )->rawParams( $llink )->parse() );
- return;
- }
+ $this->requireLogin( 'watchlistanontext', 'watchnologin' );
// Check permissions
$this->checkPermissions();
// Get a 0-byte temp file to perform the concatenation at
$tmpFile = TempFSFile::factory( 'chunkedupload_', $ext );
$tmpPath = false; // fail in concatenate()
- if( $tmpFile ) {
+ if ( $tmpFile ) {
// keep alive with $this
$tmpPath = $tmpFile->bind( $this )->getPath();
}
'invalidtitle-knownnamespace' => 'Invalid title with namespace "$2" and text "$3"',
'invalidtitle-unknownnamespace' => 'Invalid title with unknown namespace number $1 and text "$2"',
'exception-nologin' => 'Not logged in',
-'exception-nologin-text' => 'This page or action requires you to be logged in on this wiki.',
+'exception-nologin-text' => 'Please [[Special:Userlogin|log in]] to be able to access this page or action.',
+'exception-nologin-text-manual' => 'Please $1 to be able to access this page or action.',
# Virus scanner
'virus-badscanner' => "Bad configuration: Unknown virus scanner: ''$1''",
'mypreferences' => 'Preferences',
'prefs-edits' => 'Number of edits:',
'prefsnologin' => 'Not logged in',
-'prefsnologintext' => 'You must be <span class="plainlinks">[{{fullurl:{{#Special:UserLogin}}|returnto=$1}} logged in]</span> to set user preferences.',
+'prefsnologintext2' => 'Please $1 to set user preferences.',
'changepassword' => 'Change password',
'changepassword-summary' => '', # do not translate or duplicate this message to other languages
'prefs-skin' => 'Skin',
mail: $PAGEEDITOR_EMAIL
wiki: $PAGEEDITOR_WIKI
-There will be no other notifications in case of further activity unless you visit this page. You could also reset the notification flags for all your watched pages on your watchlist.
+There will be no other notifications in case of further activity unless you visit this page while logged in. You could also reset the notification flags for all your watched pages on your watchlist.
- Your friendly {{SITENAME}} notification system
+Your friendly {{SITENAME}} notification system
--
To change your email notification settings, visit
# Special:SpecialPages
'specialpages' => 'Special pages',
'specialpages-summary' => '', # do not translate or duplicate this message to other languages
-'specialpages-note' => '----
-* Normal special pages.
+'specialpages-note-top' => 'Legend',
+'specialpages-note' => '* Normal special pages.
* <span class="mw-specialpagerestricted">Restricted special pages.</span>',
'specialpages-group-maintenance' => 'Maintenance reports',
'specialpages-group-other' => 'Other special pages',
'exception-nologin' => 'Generic page title used on error page when a user is not logged in. Message used by the UserNotLoggedIn exception.
{{Identical|Not logged in}}',
'exception-nologin-text' => 'Generic reason displayed on error page when a user is not logged in. Message used by the UserNotLoggedIn exception.',
+'exception-nologin-text-manual' => 'Generic reason displayed on error page when a user is not logged in.
+
+Parameters:
+* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description',
# Virus scanner
'virus-badscanner' => 'Used as error message. Parameters:
{{Identical|Preferences}}',
'prefs-edits' => 'In user preferences.',
'prefsnologin' => '{{Identical|Not logged in}}',
-'prefsnologintext' => 'Parameters:
-* $1 - URI for "returnto" argument',
+'prefsnologintext2' => 'Parameters:
+* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description',
'changepassword' => "Section heading on [[Special:Preferences]], tab 'User profile'.
{{Identical|Change password}}",
'prefs-skin' => 'Used in user preferences.
* {{msg-mw|Accesskey-t-specialpages}}
* {{msg-mw|Tooltip-t-specialpages}}
{{Identical|Special page}}',
+'specialpages-note-top' => 'Heading for {{msg-mw|specialpages-note}}',
'specialpages-note' => 'Footer note for the [[Special:SpecialPages]] page',
'specialpages-group-maintenance' => '{{doc-special-group|like=[[Special:DoubleRedirects]], [[Special:LonelyPages]] and [[Special:WantedPages]]}}',
'specialpages-group-other' => '{{doc-special-group|like=[[Special:AdminLinks]] and [[Special:BookSources]]}}',
}
static function is_win() {
- return substr( php_uname(), 0, 7 ) == 'Windows' ;
+ return substr( php_uname(), 0, 7 ) == 'Windows';
}
// bench function 1
prefs
prefsection
prefsnologin
-prefsnologintext
+prefsnologintext2
prefsubmit
preload
preloads
'invalidtitle-unknownnamespace',
'exception-nologin',
'exception-nologin-text',
+ 'exception-nologin-text-manual',
),
'virus' => array(
'virus-badscanner',
'mypreferences',
'prefs-edits',
'prefsnologin',
- 'prefsnologintext',
+ 'prefsnologintext2',
'changepassword',
'changepassword-summary',
'prefs-skin',
'special-specialpages' => array(
'specialpages',
'specialpages-summary',
+ 'specialpages-note-top',
'specialpages-note',
'specialpages-group-maintenance',
'specialpages-group-other',
fwrite( STDERR, "Loading data from $fileName\n" );
}
// Include the extension to update $wgExtensionMessagesFiles
- if ( !( include_once( $fileName ) ) ) {
+ if ( !( include_once $fileName ) ) {
fwrite( STDERR, "Unable to read $fileName\n" );
exit( 1 );
}
--- Used for storing page restrictions (i.e. protection levels)
CREATE TABLE /*$wgDBprefix*/page_restrictions (
+ pr_id INT UNIQUE IDENTITY,
pr_page INT NOT NULL REFERENCES /*$wgDBprefix*/page(page_id) ON DELETE CASCADE,
pr_type NVARCHAR(200) NOT NULL,
pr_level NVARCHAR(200) NOT NULL,
pr_cascade SMALLINT NOT NULL,
pr_user INT NULL,
pr_expiry DATETIME NULL,
- pr_id INT UNIQUE IDENTITY,
CONSTRAINT /*$wgDBprefix*/pr_pagetype PRIMARY KEY(pr_page,pr_type),
);
CREATE INDEX /*$wgDBprefix*/pr_page ON /*$wgDBprefix*/page_restrictions(pr_page);
mr_lang varchar2(32) NOT NULL,
mr_blob BLOB NOT NULL,
mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
-) ;
+);
CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
ALTER TABLE &mw_prefix.oldimage MODIFY oi_name DEFAULT 0;
mr_lang varchar2(32) NOT NULL,
mr_blob BLOB NOT NULL,
mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
-) ;
+);
CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
CREATE TABLE &mw_prefix.msg_resource_links (
$this->mOptions['verbose'] = 1;
}
- $this->verbose( 'Purging files that were: ' . implode( ', ', $typeList ) . "\n");
+ $this->verbose( 'Purging files that were: ' . implode( ', ', $typeList ) . "\n" );
foreach ( $typeList as $type ) {
$this->verbose( "Checking for {$type} files...\n" );
$this->purgeFromLogType( $type );
// Purge items from fileachive table (rows are likely here)
$this->purgeFromArchiveTable( $repo, $file );
- } else if ( $logType === 'move' ) {
+ } elseif ( $logType === 'move' ) {
// Purge the target file as well
$params = unserialize( $row->log_params );
CREATE TABLE /*_*/page_restrictions_tmp (
+ pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
pr_page int NOT NULL,
pr_type varbinary(60) NOT NULL,
pr_level varbinary(60) NOT NULL,
pr_cascade tinyint NOT NULL,
pr_user int NULL,
- pr_expiry varbinary(14) NULL,
- pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT
+ pr_expiry varbinary(14) NULL
);
CREATE UNIQUE INDEX /*i*/pr_pagetype ON /*_*/page_restrictions_tmp (pr_page,pr_type);
-- Used for storing page restrictions (i.e. protection levels)
CREATE TABLE /*_*/page_restrictions (
+ -- Field for an ID for this restrictions row (sort-key for Special:ProtectedPages)
+ pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- Page to apply restrictions to (Foreign Key to page).
pr_page int NOT NULL,
-- The protection type (edit, move, etc)
-- Field for future support of per-user restriction.
pr_user int NULL,
-- Field for time-limited protection.
- pr_expiry varbinary(14) NULL,
- -- Field for an ID for this restrictions row (sort-key for Special:ProtectedPages)
- pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT
+ pr_expiry varbinary(14) NULL
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/pr_pagetype ON /*_*/page_restrictions (pr_page,pr_type);
$time2 = new MWTimestamp();
$this->output( "\nDone.\n" );
- $this->output( "\nThe job took ". $time2->diff( $time1 )->format( "%i:%S" ). "\n" );
+ $this->output( "\nThe job took " . $time2->diff( $time1 )->format( "%i:%S" ) . "\n" );
}
function afterFinalSetup() {
--- /dev/null
+<?xml version="1.0"?>\r
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="128px" height="128px" id="RSSicon" viewBox="0 0 256 256">\r
+<defs>\r
+<linearGradient x1="0.085" y1="0.085" x2="0.915" y2="0.915" id="RSSg">\r
+<stop offset="0.0" stop-color="#E3702D"/><stop offset="0.1071" stop-color="#EA7D31"/>\r
+<stop offset="0.3503" stop-color="#F69537"/><stop offset="0.5" stop-color="#FB9E3A"/>\r
+<stop offset="0.7016" stop-color="#EA7C31"/><stop offset="0.8866" stop-color="#DE642B"/>\r
+<stop offset="1.0" stop-color="#D95B29"/>\r
+</linearGradient>\r
+</defs>\r
+<rect width="256" height="256" rx="55" ry="55" x="0" y="0" fill="#CC5D15"/>\r
+<rect width="246" height="246" rx="50" ry="50" x="5" y="5" fill="#F49C52"/>\r
+<rect width="236" height="236" rx="47" ry="47" x="10" y="10" fill="url(#RSSg)"/>\r
+<circle cx="68" cy="189" r="24" fill="#FFF"/>\r
+<path d="M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z" fill="#FFF"/>\r
+<path d="M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z" fill="#FFF"/>\r
+</svg>\r
/* feed links */
a.feedlink {
/* @embed */
- background: url(images/feed-icon.png) center left no-repeat;
+ background-image: url(images/feed-icon.png);
+ background-image: linear-gradient(transparent, transparent), url(images/feed-icon.svg);
+ background-position: center left;
+ background-repeat: no-repeat;
+ background-size: 12px 12px;
padding-left: 16px;
}
rev_minor_edit tinyint default '0',
rev_deleted tinyint default '0',
rev_len int,
- rev_parent_id INTEGER default NULL) /*$wgDBTableOptions*/ ;
+ rev_parent_id INTEGER default NULL) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/text (
old_id INTEGER PRIMARY KEY AUTOINCREMENT,
old_text mediumblob ,
- old_flags tinyblob ) /*$wgDBTableOptions*/ ;
+ old_flags tinyblob ) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/archive (
ar_namespace INTEGER default '0',
CREATE TABLE /*$wgDBprefix*/hitcounter (
hc_id INTEGER
-) ;
+);
CREATE TABLE /*$wgDBprefix*/ipblocks (
ipb_id INTEGER PRIMARY KEY AUTOINCREMENT,
CREATE TABLE /*$wgDBprefix*/searchindex (
si_page INTEGER ,
si_title varchar(255) default '',
- si_text mediumtext ) ;
+ si_text mediumtext );
CREATE TABLE /*$wgDBprefix*/interwiki (
iw_prefix varchar(32) ,
* @param $key String Name of the key to validate in the serialized JSON
* @dataProvider provideJsonSerializedKeys
*/
- function testJsonserializeexceptionKeys($expectedKeyType, $exClass, $key) {
+ function testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key ) {
# Make sure we log a backtrace:
$this->setMwGlobals( array( 'wgLogExceptionBacktrace' => true ) );
"JSON serialized exception is missing key '$key'"
);
$this->assertInternalType( $expectedKeyType, $json->$key,
- "JSON serialized key '$key' has type " . gettype($json->$key)
+ "JSON serialized key '$key' has type " . gettype( $json->$key )
. " (expected: $expectedKeyType)."
);
}
*/
function provideJsonSerializedKeys() {
$testCases = array();
- foreach( array( 'Exception', 'MWException' ) as $exClass ) {
+ foreach ( array( 'Exception', 'MWException' ) as $exClass ) {
$exTests = array(
array( 'string', $exClass, 'id' ),
array( 'string', $exClass, 'file' ),
# Backtrace only enabled with wgLogExceptionBacktrace = true
array( 'array', $exClass, 'backtrace' ),
);
- $testCases = array_merge($testCases, $exTests);
+ $testCases = array_merge( $testCases, $exTests );
}
return $testCases;
}
);
}
}
-
-}
\ No newline at end of file
+}
$array = array( 'a', 'b' );
$object = new StdClass();
self::helperThrowAnException( $array, $object, $refvar );
- } catch (Exception $e) {
+ } catch ( Exception $e ) {
}
# Make sure our strack trace contains an array and an object passed to
$hasArray = $hasArray || is_array( $arg );
}
- if( $hasObject && $hasArray ) {
+ if ( $hasObject && $hasArray ) {
break;
}
}
continue;
}
foreach ( $frame['args'] as $arg ) {
- $this->assertNotInternalType( 'array', $arg);
- $this->assertNotInternalType( 'object', $arg);
+ $this->assertNotInternalType( 'array', $arg );
+ $this->assertNotInternalType( 'object', $arg );
}
}
*/
class StatusTest extends MediaWikiTestCase {
- public function testCanConstruct(){
+ public function testCanConstruct() {
new Status();
$this->assertTrue( true );
}
/**
* @dataProvider provideValues
* @covers Status::newGood
- * @covers Status::getValue
- * @covers Status::isGood
- * @covers Status::isOK
*/
- public function testNewGood( $value = null ){
+ public function testNewGood( $value = null ) {
$status = Status::newGood( $value );
$this->assertTrue( $status->isGood() );
$this->assertTrue( $status->isOK() );
$this->assertEquals( $value, $status->getValue() );
}
- public static function provideValues(){
+ public static function provideValues() {
return array(
array(),
array( 'foo' ),
/**
* @covers Status::newFatal
- * @covers Status::isGood
- * @covers Status::isOK
- * @covers Status::getMessage
*/
public function testNewFatalWithMessage() {
$message = $this->getMockBuilder( 'Message' )
/**
* @covers Status::newFatal
- * @covers Status::isGood
- * @covers Status::isOK
- * @covers Status::getMessage
*/
public function testNewFatalWithString() {
$message = 'foo';
$status = Status::newFatal( $message );
$this->assertFalse( $status->isGood() );
$this->assertFalse( $status->isOK() );
- $newMessage = $status->getMessage();
- $this->assertEquals( $message, $newMessage->getKey() );
+ $this->assertEquals( $message, $status->getMessage()->getKey() );
}
/**
* @dataProvider provideSetResult
- * @covers Status::getValue
- * @covers Status::isOK
+ * @covers Status::setResult
*/
public function testSetResult( $ok, $value = null ) {
$status = new Status();
);
}
+ /**
+ * @dataProvider provideIsOk
+ * @covers Status::isOk
+ */
+ public function testIsOk( $ok ) {
+ $status = new Status();
+ $status->ok = $ok;
+ $this->assertEquals( $ok, $status->isOK() );
+ }
+
+ public static function provideIsOk() {
+ return array(
+ array( true ),
+ array( false ),
+ );
+ }
+
+ /**
+ * @covers Status::getValue
+ */
+ public function testGetValue() {
+ $status = new Status();
+ $status->value = 'foobar';
+ $this->assertEquals( 'foobar', $status->getValue() );
+ }
+
+ /**
+ * @dataProvider provideIsGood
+ * @covers Status::isGood
+ */
+ public function testIsGood( $ok, $errors, $expected ) {
+ $status = new Status();
+ $status->ok = $ok;
+ $status->errors = $errors;
+ $this->assertEquals( $expected, $status->isGood() );
+ }
+
+ public static function provideIsGood() {
+ return array(
+ array( true, array(), true ),
+ array( true, array( 'foo' ), false ),
+ array( false, array(), false ),
+ array( false, array( 'foo' ), false ),
+ );
+ }
+
/**
* @dataProvider provideMockMessageDetails
* @covers Status::warning
$status = new Status();
$messages = $this->getMockMessages( $mockDetails );
- foreach( $messages as $message ){
+ foreach ( $messages as $message ) {
$status->warning( $message );
}
$warnings = $status->getWarningsArray();
$this->assertEquals( count( $messages ), count( $warnings ) );
- foreach( $messages as $key => $message ) {
+ foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( array( $message->getKey() ), $message->getParams() );
$this->assertEquals( $warnings[$key], $expectedArray );
}
$status = new Status();
$messages = $this->getMockMessages( $mockDetails );
- foreach( $messages as $message ){
+ foreach ( $messages as $message ) {
$status->error( $message );
}
$errors = $status->getErrorsArray();
$this->assertEquals( count( $messages ), count( $errors ) );
- foreach( $messages as $key => $message ) {
+ foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( array( $message->getKey() ), $message->getParams() );
$this->assertEquals( $errors[$key], $expectedArray );
}
* @param array $messageDetails eg. array( 'KEY' => array(/PARAMS/) )
* @return Message[]
*/
- protected function getMockMessages( $messageDetails ){
+ protected function getMockMessages( $messageDetails ) {
$messages = array();
- foreach( $messageDetails as $key => $paramsArray ){
+ foreach ( $messageDetails as $key => $paramsArray ) {
$messages[] = $this->getMockMessage( $key, $paramsArray );
}
return $messages;
}
- public static function provideMockMessageDetails(){
+ public static function provideMockMessageDetails() {
return array(
array( array( 'key1' => array( 'foo' => 'bar' ) ) ),
array( array( 'key1' => array( 'foo' => 'bar' ), 'key2' => array( 'foo2' => 'bar2' ) ) ),
* @covers Status::merge
* @todo test merge with $overwriteValue true
*/
- public function testMerge(){
+ public function testMerge() {
$status1 = new Status();
$status2 = new Status();
$message1 = $this->getMockMessage( 'warn1' );
$status->fatal( 'bad' );
$this->assertTrue( $status->hasMessage( 'bad' ) );
$this->assertFalse( $status->hasMessage( 'good' ) );
+ }
+ /**
+ * @dataProvider provideCleanParams
+ * @covers Status::cleanParams
+ */
+ public function testCleanParams( $cleanCallback, $params, $expected ) {
+ $method = new ReflectionMethod( 'Status', 'cleanParams' );
+ $method->setAccessible(TRUE);
+ $status = new Status();
+ $status->cleanCallback = $cleanCallback;
+
+ $this->assertEquals( $expected, $method->invoke( $status, $params ) );
+ }
+
+ /**
+ * @todo test cleanParams with a callback
+ */
+ public static function provideCleanParams() {
+ return array(
+ array( false, array( 'foo' => 'bar' ), array( 'foo' => 'bar' ) ),
+ );
+ }
+
+ /**
+ * @dataProvider provideGetWikiText
+ * @covers Status::getWikiText
+ * @todo test long and short context messages generated through this method
+ * this can not really be done now due to use of wfMessage()->plain()
+ * It is possible to mock such methods but only if namespaces are used
+ */
+ public function testGetWikiText( Status $status, $expected ) {
+ $this->assertEquals( $expected, $status->getWikiText() );
+ }
+
+ /**
+ * @return array of arrays with values;
+ * 0 => status object
+ * 1 => expected string (with no context)
+ */
+ public static function provideGetWikiText() {
+ $testCases = array();
+
+ $testCases[ 'GoodStatus' ] = array(
+ new Status(),
+ "Internal error: Status::getWikiText called for a good result, this is incorrect\n",
+ );
+
+ $status = new Status();
+ $status->ok = false;
+ $testCases[ 'GoodButNoError' ] = array(
+ $status,
+ "Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n",
+ );
+
+ $status = new Status();
+ $status->warning( 'fooBar!' );
+ $testCases[ '1StringWarning' ] = array(
+ $status,
+ "<fooBar!>",
+ );
+
+ $status = new Status();
+ $status->warning( 'fooBar!' );
+ $status->warning( 'fooBar2!' );
+ $testCases[ '2StringWarnings' ] = array(
+ $status,
+ "* <fooBar!>\n* <fooBar2!>\n",
+ );
+
+ $status = new Status();
+ $status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
+ $testCases[ '1MessageWarning' ] = array(
+ $status,
+ "<fooBar!>",
+ );
+
+ $status = new Status();
+ $status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
+ $status->warning( new Message( 'fooBar2!' ) );
+ $testCases[ '2MessageWarnings' ] = array(
+ $status,
+ "* <fooBar!>\n* <fooBar2!>\n",
+ );
+
+ return $testCases;
}
- //todo test cleanParams
- //todo test getWikiText
//todo test getMessage
//todo test getErrorMessage
//todo test getHTML
//todo test getStatusArray
//todo test getErrorsByType
//todo test replaceMessage
- //todo test replaceMessage
}
UserMailer::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) );
}
-}
\ No newline at end of file
+}
$this->assertEquals( $value, $obj->value );
}
- public function provideConstruction(){
+ public function provideConstruction() {
return array(
array( null ),
array( '' ),
'text' => "==section 1==\nnew content 1",
) );
$this->assertEquals( 'Success', $re['edit']['result'] );
- $newtext = WikiPage::factory( Title::newFromText( $name) )->getContent( Revision::RAW )->getNativeData();
+ $newtext = WikiPage::factory( Title::newFromText( $name ) )->getContent( Revision::RAW )->getNativeData();
$this->assertEquals( $newtext, "==section 1==\nnew content 1\n\n==section 2==\ncontent2" );
// Test that we raise a 'nosuchsection' error
class ApiOptionsTest extends MediaWikiLangTestCase {
/** @var PHPUnit_Framework_MockObject_MockObject */
- private $mUserMock ;
+ private $mUserMock;
/** @var ApiOptions */
private $mTested;
private $mSession;
return $context;
}
-}
\ No newline at end of file
+}
'sessionkey' => null,
);
}
-}
\ No newline at end of file
+}
}
$this->user->saveSettings();
}
-}
\ No newline at end of file
+}
public function testAddIdentifierQuotes( $expected, $in ) {
$db = new FakeDatabaseMysqlBase();
$quoted = $db->addIdentifierQuotes( $in );
- $this->assertEquals($expected, $quoted);
+ $this->assertEquals( $expected, $quoted );
}
);
}
- private static function createUnicodeString($str) {
+ private static function createUnicodeString( $str ) {
return json_decode( '"' . $str . '"' );
}
$db = $this->getMockForViews();
// The first call populate an internal cache of views
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews() );
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews() );
// Prefix filtering
$db->listViews( 'my' ) );
$this->assertEquals( array(),
$db->listViews( 'UNUSED_PREFIX' ) );
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews( '' ) );
}
function testIsView( $isView, $viewName ) {
$db = $this->getMockForViews();
- switch( $isView ) {
+ switch ( $isView ) {
case true:
$this->assertTrue( $db->isView( $viewName ),
"$viewName should be considered a view" );
}
if ( $this->db->getType() === 'oracle' ) {
- return strtoupper($database . $quote . $prefix . $table);
+ return strtoupper( $database . $quote . $prefix . $table );
} else {
return $database . $quote . $prefix . $table . $quote;
}
$strings = array( "it is a kitten", "two kittens", "three kittens", "four kittens" );
$revisions = array();
- foreach( $strings as $string ) {
+ foreach ( $strings as $string ) {
$content = ContentHandler::makeContent( $string, $title );
$page->doEditContent( $content, 'edit page' );
$revisions[] = $page->getLatest();
public function testMapDiffPrevNext() {
$cases = $this->getMapDiffPrevNextCases();
- foreach( $cases as $case ) {
+ foreach ( $cases as $case ) {
list( $expected, $old, $new, $message ) = $case;
$diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
public function testLoadRevisionData() {
$cases = $this->getLoadRevisionDataCases();
- foreach( $cases as $case ) {
+ foreach ( $cases as $case ) {
list( $expectedOld, $expectedNew, $old, $new, $message ) = $case;
$diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
public function getPath() {
return '';
}
-}
\ No newline at end of file
+}
public static function provideFlattenArray() {
return array(
- array (
- array(1 ,2 ,3), 'ul', false, false,
+ array(
+ array( 1, 2, 3 ), 'ul', false, false,
"<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>",
),
- array (
- array(1 ,2 ,3), 'ol', false, false,
+ array(
+ array( 1, 2, 3 ), 'ol', false, false,
"<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>",
),
- array (
- array(1 ,2 ,3), 'ul', true, false,
+ array(
+ array( 1, 2, 3 ), 'ul', true, false,
"\n*1\n*2\n*3",
),
- array (
- array(1 ,2 ,3), 'ol', true, false,
+ array(
+ array( 1, 2, 3 ), 'ol', true, false,
"\n#1\n#2\n#3",
),
// TODO: more test cases
array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
);
}
-}
\ No newline at end of file
+}
$dummyCereal = 'O:29:"testautoloadedserializedclass":0:{}';
$uncerealized = unserialize( $dummyCereal );
$this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class,
- "unserialize() can load classes case-insensitively.");
+ "unserialize() can load classes case-insensitively." );
}
}
return;
}
mw.messages.set(test.message );
- mw.config.set( 'wgUserLanguage', test.lang ) ;
+ mw.config.set( 'wgUserLanguage', test.lang );
var parser = new mw.jqueryMsg.parser( { language: langClass } );
assert.equal(
parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg',