Merge "CologneBlue rewrite: rework otherLanguages(), CSS: serif font"
authorBrion VIBBER <brion@wikimedia.org>
Fri, 5 Oct 2012 17:39:26 +0000 (17:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 5 Oct 2012 17:39:26 +0000 (17:39 +0000)
19 files changed:
includes/Article.php
includes/EditPage.php
includes/Html.php
includes/SqlDataUpdate.php
includes/User.php
includes/api/ApiEditPage.php
includes/db/Database.php
includes/diff/DifferenceEngine.php
includes/filebackend/filejournal/DBFileJournal.php
includes/filebackend/filejournal/FileJournal.php
includes/installer/DatabaseUpdater.php
includes/specials/SpecialSearch.php
maintenance/language/checkLanguage.inc
maintenance/syncFileBackend.php
tests/parser/parserTests.txt
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/LinksUpdateTest.php
tests/phpunit/includes/api/ApiTestCase.php
tests/phpunit/includes/upload/UploadFromUrlTest.php

index 76e566b..db4444e 100644 (file)
@@ -380,7 +380,7 @@ class Article extends Page {
 
                // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
                // We should instead work with the Revision object when we need it...
-               $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
+               $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER, $this->getContext()->getUser() ); // Loads if user is allowed
                $this->mRevIdFetched = $this->mRevision->getId();
 
                wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
index 3922719..cc85a7d 100644 (file)
@@ -946,7 +946,7 @@ class EditPage {
 
                $title = Title::newFromText( $preload );
                # Check for existence to avoid getting MediaWiki:Noarticletext
-               if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
+               if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
                        return '';
                }
 
@@ -954,7 +954,7 @@ class EditPage {
                if ( $page->isRedirect() ) {
                        $title = $page->getRedirectTarget();
                        # Same as before
-                       if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
+                       if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
                                return '';
                        }
                        $page = WikiPage::factory( $title );
@@ -1215,7 +1215,7 @@ class EditPage {
 
                if ( $new ) {
                        // Late check for create permission, just in case *PARANOIA*
-                       if ( !$this->mTitle->userCan( 'create' ) ) {
+                       if ( !$this->mTitle->userCan( 'create', $wgUser ) ) {
                                $status->fatal( 'nocreatetext' );
                                $status->value = self::AS_NO_CREATE_PERMISSION;
                                wfDebug( __METHOD__ . ": no create permission\n" );
@@ -1994,7 +1994,7 @@ class EditPage {
                                if ( $revision ) {
                                        // Let sysop know that this will make private content public if saved
 
-                                       if ( !$revision->userCan( Revision::DELETED_TEXT ) ) {
+                                       if ( !$revision->userCan( Revision::DELETED_TEXT, $wgUser ) ) {
                                                $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
                                        } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
                                                $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
index dfd081f..9fcdc52 100644 (file)
@@ -753,7 +753,7 @@ class Html {
         * - name: [optional], default: 'namespace'
         * @return string HTML code to select a namespace.
         */
-       public static function namespaceSelector( Array $params = array(), Array $selectAttribs = array() ) {
+       public static function namespaceSelector( array $params = array(), array $selectAttribs = array() ) {
                global $wgContLang;
 
                ksort( $selectAttribs );
index 52c9be0..256e8f7 100644 (file)
@@ -108,7 +108,7 @@ abstract class SqlDataUpdate extends DataUpdate {
         * @param $namespace Integer
         * @param $dbkeys Array
         */
-       protected function invalidatePages( $namespace, Array $dbkeys ) {
+       protected function invalidatePages( $namespace, array $dbkeys ) {
                if ( !count( $dbkeys ) ) {
                        return;
                }
index 8216914..4ab90ed 100644 (file)
@@ -1204,6 +1204,7 @@ class User {
                $this->mEffectiveGroups = null;
                $this->mImplicitGroups = null;
                $this->mOptions = null;
+               $this->mEditCount = null;
 
                if ( $reloadFrom ) {
                        $this->mLoadedItems = array();
index 0963fe7..2b9e849 100644 (file)
@@ -63,7 +63,7 @@ class ApiEditPage extends ApiBase {
                                $titles = Title::newFromRedirectArray(
                                        Revision::newFromTitle(
                                                $oldTitle, false, Revision::READ_LATEST
-                                       )->getText( Revision::FOR_THIS_USER )
+                                       )->getText( Revision::FOR_THIS_USER, $user )
                                );
                                // array_shift( $titles );
 
index c082cc9..5271208 100644 (file)
@@ -2923,13 +2923,11 @@ abstract class DatabaseBase implements DatabaseType {
                                //
                                // b) the DBO_TRX flag is not set. Explicit transactions should always be properly
                                //    started and comitted.
-                               wfWarn( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
-                                       " performing implicit commit!" );
-                       } else {
-                               if ( $wgDebugDBTransactions ) {
-                                       wfDebug( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
-                                               " performing implicit commit!\n" );
-                               }
+                               /*wfWarn( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
+                                       " performing implicit commit!" );*/
+                       } elseif ( $wgDebugDBTransactions ) {
+                               wfDebug( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
+                                       " performing implicit commit!\n" );
                        }
 
                        $this->doCommit( $fname );
index c7156fb..31fdc6d 100644 (file)
@@ -1082,13 +1082,13 @@ class DifferenceEngine extends ContextSource {
                        return false;
                }
                if ( $this->mOldRev ) {
-                       $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER );
+                       $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
                        if ( $this->mOldtext === false ) {
                                return false;
                        }
                }
                if ( $this->mNewRev ) {
-                       $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
+                       $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
                        if ( $this->mNewtext === false ) {
                                return false;
                        }
@@ -1110,7 +1110,7 @@ class DifferenceEngine extends ContextSource {
                if ( !$this->loadRevisionData() ) {
                        return false;
                }
-               $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
+               $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
                return true;
        }
 }
index f6268c2..34f3e53 100644 (file)
@@ -83,6 +83,19 @@ class DBFileJournal extends FileJournal {
                return $status;
        }
 
+       /**
+        * @see FileJournal::doGetCurrentPosition()
+        * @return integer|false
+        */
+       protected function doGetCurrentPosition() {
+               $dbw = $this->getMasterDB();
+
+               return $dbw->selectField( 'filejournal', 'MAX(fj_id)',
+                       array( 'fj_backend' => $this->backend ),
+                       __METHOD__
+               );
+       }
+
        /**
         * @see FileJournal::doGetChangeEntries()
         * @return Array
index ce029bb..3bc0df7 100644 (file)
@@ -110,6 +110,21 @@ abstract class FileJournal {
         */
        abstract protected function doLogChangeBatch( array $entries, $batchId );
 
+       /**
+        * Get the position ID of the latest journal entry
+        *
+        * @return integer|false
+        */
+       final public function getCurrentPosition() {
+               return $this->doGetCurrentPosition();
+       }
+
+       /**
+        * @see FileJournal::getCurrentPosition()
+        * @return integer|false
+        */
+       abstract protected function doGetCurrentPosition();
+
        /**
         * Get an array of file change log entries.
         * A starting change ID and/or limit can be specified.
@@ -169,7 +184,7 @@ abstract class FileJournal {
  */
 class NullFileJournal extends FileJournal {
        /**
-        * @see FileJournal::logChangeBatch()
+        * @see FileJournal::doLogChangeBatch()
         * @param $entries array
         * @param $batchId string
         * @return Status
@@ -178,6 +193,14 @@ class NullFileJournal extends FileJournal {
                return Status::newGood();
        }
 
+       /**
+        * @see FileJournal::doGetCurrentPosition()
+        * @return integer|false
+        */
+       protected function doGetCurrentPosition() {
+               return false;
+       }
+
        /**
         * @see FileJournal::doGetChangeEntries()
         * @return Array
@@ -187,7 +210,7 @@ class NullFileJournal extends FileJournal {
        }
 
        /**
-        * @see FileJournal::purgeOldLogs()
+        * @see FileJournal::doPurgeOldLogs()
         * @return Status
         */
        protected function doPurgeOldLogs() {
index ff0a99e..a575334 100644 (file)
@@ -177,7 +177,7 @@ abstract class DatabaseUpdater {
         *                Note that callback functions will receive this object as
         *                first parameter.
         */
-       public function addExtensionUpdate( Array $update ) {
+       public function addExtensionUpdate( array $update ) {
                $this->extensionUpdates[] = $update;
        }
 
index d2add62..3ae0b83 100644 (file)
@@ -423,7 +423,7 @@ class SpecialSearch extends SpecialPage {
 
                if( $t->isKnown() ) {
                        $messageName = 'searchmenu-exists';
-               } elseif( $t->userCan( 'create' ) ) {
+               } elseif( $t->userCan( 'create', $this->getUser() ) ) {
                        $messageName = 'searchmenu-new';
                } else {
                        $messageName = 'searchmenu-new-nocreate';
@@ -559,7 +559,7 @@ class SpecialSearch extends SpecialPage {
                //If page content is not readable, just return the title.
                //This is not quite safe, but better than showing excerpts from non-readable pages
                //Note that hiding the entry entirely would screw up paging.
-               if( !$t->userCan( 'read' ) ) {
+               if( !$t->userCan( 'read', $this->getUser() ) ) {
                        wfProfileOut( __METHOD__ );
                        return "<li>{$link}</li>\n";
                }
index 11b00e1..2a0932a 100644 (file)
@@ -43,7 +43,7 @@ class CheckLanguageCLI {
         * Constructor.
         * @param $options array Options for script.
         */
-       public function __construct( Array $options ) {
+       public function __construct( array $options ) {
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
                        exit(1);
@@ -484,7 +484,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
         * @param $options array Options for script.
         * @param $extension string The extension name (or names).
         */
-       public function __construct( Array $options, $extension ) {
+       public function __construct( array $options, $extension ) {
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
                        exit(1);
index a29647b..e279ccb 100644 (file)
@@ -34,21 +34,44 @@ class SyncFileBackend extends Maintenance {
                parent::__construct();
                $this->mDescription = "Sync one file backend with another using the journal";
                $this->addOption( 'src', 'Name of backend to sync from', true, true );
-               $this->addOption( 'dst', 'Name of destination backend to sync', true, true );
+               $this->addOption( 'dst', 'Name of destination backend to sync', false, true );
                $this->addOption( 'start', 'Starting journal ID', false, true );
                $this->addOption( 'end', 'Ending journal ID', false, true );
                $this->addOption( 'posdir', 'Directory to read/record journal positions', false, true );
+               $this->addOption( 'posdump', 'Just dump current journal position into the position dir.' );
                $this->addOption( 'verbose', 'Verbose mode', false, false, 'v' );
                $this->setBatchSize( 50 );
        }
 
        public function execute() {
                $src = FileBackendGroup::singleton()->get( $this->getOption( 'src' ) );
-               $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) );
 
                $posDir = $this->getOption( 'posdir' );
                $posFile = $posDir ? $posDir . '/' . wfWikiID() : false;
 
+               if ( $this->hasOption( 'posdump' ) ) {
+                       // Just dump the current position into the specified position dir
+                       if ( !$this->hasOption( 'posdir' ) ) {
+                               $this->error( "Param posdir required!", 1 );
+                       }
+                       $id = (int)$src->getJournal()->getCurrentPosition(); // default to 0
+                       $this->output( "Current journal position is $id.\n" );
+                       if ( file_put_contents( $posFile, $id, LOCK_EX ) !== false ) {
+                               $this->output( "Saved journal position file.\n" );
+                       } else {
+                               $this->output( "Could not save journal position file.\n" );
+                       }
+                       if ( $this->isQuiet() ) {
+                               print $id; // give a single machine-readable number
+                       }
+                       return;
+               }
+
+               if ( !$this->hasOption( 'dst' ) ) {
+                       $this->error( "Param dst required!", 1 );
+               }
+               $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) );
+
                $start = $this->getOption( 'start', 0 );
                if ( !$start && $posFile && is_dir( $posDir ) ) {
                        $start = is_file( $posFile )
index f555d4f..c7acfd5 100644 (file)
@@ -4322,6 +4322,47 @@ section=1
 ==Section 1==
 !! end
 
+###
+### <includeonly> and <noinclude> in attributes
+###
+!!test
+1. includeonly around the entire attribute
+!!input
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!!result
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr key
+!!input
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!!result
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in html attr value
+!!input
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!!result
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+4. includeonly in part of an attr value
+!!input
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!!result
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
 ###
 ### Testing parsing of templates where a template arg
 ### has the same name as the template itself.
index f9e9f77..54a3f7c 100644 (file)
@@ -368,7 +368,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         *         or list the tables under testing in $this->tablesUsed, or override the
         *         needsDB() method.
         */
-       protected function assertSelect( $table, $fields, $condition, Array $expectedRows ) {
+       protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
                if ( !$this->needsDB() ) {
                        throw new MWException( 'When testing database state, the test cases\'s needDB()' .
                                ' method should return true. Use @group Database or $this->tablesUsed.');
index 09858b0..8e37b13 100644 (file)
@@ -148,7 +148,7 @@ class LinksUpdateTest extends MediaWikiTestCase {
 
        #@todo: test recursive, too!
 
-       protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, Array $expectedRows ) {
+       protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
                $update = new LinksUpdate( $title, $parserOutput );
 
                $update->doUpdate();
index 3cec99a..3ca6741 100644 (file)
@@ -41,7 +41,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
 
        }
 
-       protected function doApiRequest( Array $params, Array $session = null, $appendModule = false, User $user = null ) {
+       protected function doApiRequest( array $params, array $session = null, $appendModule = false, User $user = null ) {
                global $wgRequest, $wgUser;
 
                if ( is_null( $session ) ) {
@@ -86,7 +86,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
         * @param $session Array|null: session array
         * @param $user User|null A User object for the context
         */
-       protected function doApiRequestWithToken( Array $params, Array $session = null, User $user = null ) {
+       protected function doApiRequestWithToken( array $params, array $session = null, User $user = null ) {
                global $wgRequest;
 
                if ( $session === null ) {
index f66c387..3093334 100644 (file)
@@ -20,7 +20,7 @@ class UploadFromUrlTest extends ApiTestCase {
                }
        }
 
-       protected function doApiRequest( Array $params, Array $unused = null, $appendModule = false, User $user = null ) {
+       protected function doApiRequest( array $params, array $unused = null, $appendModule = false, User $user = null ) {
                $sessionId = session_id();
                session_write_close();