Merge "Make ForeignDBRepo::getDBFactory() actually work on 5.3"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 8 Oct 2015 07:56:08 +0000 (07:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 8 Oct 2015 07:56:08 +0000 (07:56 +0000)
includes/OutputPage.php
includes/deferred/DeferredUpdates.php
includes/specials/SpecialEditWatchlist.php
tests/phpunit/includes/OutputPageTest.php

index 755b165..d85c60c 100644 (file)
@@ -2004,7 +2004,7 @@ class OutputPage extends ContextSource {
        function haveCacheVaryCookies() {
                $request = $this->getRequest();
                foreach ( $this->getCacheVaryCookies() as $cookieName ) {
-                       if ( $request->getCookie( $cookieName, '' ) ) {
+                       if ( $request->getCookie( $cookieName, '', '' ) !== '' ) {
                                wfDebug( __METHOD__ . ": found $cookieName\n" );
                                return true;
                        }
@@ -3312,22 +3312,31 @@ class OutputPage extends ContextSource {
         * @return bool
         */
        public function userCanPreview() {
-               if ( $this->getRequest()->getVal( 'action' ) != 'submit'
-                       || !$this->getRequest()->wasPosted()
-                       || !$this->getUser()->matchEditToken(
-                               $this->getRequest()->getVal( 'wpEditToken' ) )
-               ) {
+               $request = $this->getRequest();
+               if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) {
+                       return false;
+               }
+
+               $user = $this->getUser();
+               if ( !$user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
                        return false;
                }
-               if ( !$this->getTitle()->isJsSubpage() && !$this->getTitle()->isCssSubpage() ) {
+
+               $title = $this->getTitle();
+               if ( !$title->isJsSubpage() && !$title->isCssSubpage() ) {
                        return false;
                }
-               if ( !$this->getTitle()->isSubpageOf( $this->getUser()->getUserPage() ) ) {
+               if ( !$title->isSubpageOf( $user->getUserPage() ) ) {
                        // Don't execute another user's CSS or JS on preview (T85855)
                        return false;
                }
 
-               return !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) );
+               $errors = $title->getUserPermissionsErrors( 'edit', $user );
+               if ( count( $errors ) !== 0 ) {
+                       return false;
+               }
+
+               return true;
        }
 
        /**
index 7d02a7a..8b3582d 100644 (file)
@@ -44,7 +44,7 @@ interface DeferrableUpdate {
  * @since 1.19
  */
 class DeferredUpdates {
-       /** @var array Updates to be deferred until the end of the request */
+       /** @var DeferrableUpdate[] Updates to be deferred until the end of the request */
        private static $updates = array();
        /** @var bool Defer updates fully even in CLI mode */
        private static $forceDeferral = false;
@@ -102,9 +102,22 @@ class DeferredUpdates {
 
                while ( count( $updates ) ) {
                        self::clearPendingUpdates();
-
-                       /** @var DeferrableUpdate $update */
+                       /** @var DataUpdate[] $dataUpdates */
+                       $dataUpdates = array();
+                       /** @var DeferrableUpdate[] $otherUpdates */
+                       $otherUpdates = array();
                        foreach ( $updates as $update ) {
+                               if ( $update instanceof DataUpdate ) {
+                                       $dataUpdates[] = $update;
+                               } else {
+                                       $otherUpdates[] = $update;
+                               }
+                       }
+
+                       // Delegate DataUpdate execution to the DataUpdate class
+                       DataUpdate::runUpdates( $dataUpdates, 'run' );
+                       // Execute the non-DataUpdate tasks
+                       foreach ( $otherUpdates as $update ) {
                                try {
                                        $update->doUpdate();
 
index 64a93a0..952ae0e 100644 (file)
@@ -282,10 +282,12 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        }
 
                        if ( $title instanceof Title ) {
-                               $output .= "<li>"
-                                       . Linker::link( $title )
-                                       . ' (' . Linker::link( $title->getTalkPage(), $talk )
-                                       . ")</li>\n";
+                               $output .= '<li>' .
+                                       Linker::link( $title ) . ' ' .
+                                       $this->msg( 'parentheses' )->rawParams(
+                                               Linker::link( $title->getTalkPage(), $talk )
+                                       )->escaped() .
+                                       "</li>\n";
                        }
                }
 
@@ -659,7 +661,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        $link = '<span class="watchlistredir">' . $link . '</span>';
                }
 
-               return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
+               return $link . ' ' .
+                       $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $tools ) )->escaped();
        }
 
        /**
index aa6655d..5f21e07 100644 (file)
@@ -339,6 +339,27 @@ class OutputPageTest extends MediaWikiTestCase {
                        ),
                );
        }
+
+       /**
+        * @covers OutputPage::haveCacheVaryCookies
+        */
+       function testHaveCacheVaryCookies() {
+               $request = new FauxRequest();
+               $context = new RequestContext();
+               $context->setRequest( $request );
+               $outputPage = new OutputPage( $context );
+
+               // No cookies are set.
+               $this->assertFalse( $outputPage->haveCacheVaryCookies() );
+
+               // 'Token' is present but empty, so it shouldn't count.
+               $request->setCookie( 'Token', '' );
+               $this->assertFalse( $outputPage->haveCacheVaryCookies() );
+
+               // 'Token' present and nonempty.
+               $request->setCookie( 'Token', '123' );
+               $this->assertTrue( $outputPage->haveCacheVaryCookies() );
+       }
 }
 
 /**