Merge "Fix flush-like commit in DeferredUpdates."
authorIAlex <ialex.wiki@gmail.com>
Tue, 9 Oct 2012 16:26:16 +0000 (16:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Oct 2012 16:26:16 +0000 (16:26 +0000)
includes/Article.php
includes/Revision.php
includes/content/ContentHandler.php
includes/filebackend/TempFSFile.php
tests/phpunit/includes/filerepo/FileBackendTest.php

index ee96338..7367812 100644 (file)
@@ -832,19 +832,20 @@ class Article extends Page {
         * @param bool $showCacheHint whether to show a message telling the user to clear the browser cache (default: true).
         */
        protected function showCssOrJsPage( $showCacheHint = true ) {
+               $outputPage = $this->getContext()->getOutput();
+
                if ( $showCacheHint ) {
                        $dir = $this->getContext()->getLanguage()->getDir();
                        $lang = $this->getContext()->getLanguage()->getCode();
 
-                       $outputPage = $this->getContext()->getOutput();
                        $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
                                'clearyourcache' );
                }
 
                // Give hooks a chance to customise the output
-               if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->fetchContentObject(), $this->getTitle(), $wgOut ) ) ) {
+               if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
                        $po = $this->mContentObject->getParserOutput( $this->getTitle() );
-                       $wgOut->addHTML( $po->getText() );
+                       $outputPage->addHTML( $po->getText() );
                }
        }
 
index 40e7734..4874490 100644 (file)
@@ -118,15 +118,13 @@ class Revision implements IDBAccessObject {
         * @param $flags Integer Bitfield (optional)
         * @return Revision or null
         */
-       public static function newFromPageId( $pageId, $revId = 0, $flags = null ) {
+       public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
                $conds = array( 'page_id' => $pageId );
                if ( $revId ) {
                        $conds['rev_id'] = $revId;
                } else {
                        // Use a join to get the latest revision
                        $conds[] = 'rev_id = page_latest';
-                       // Callers assume this will be up-to-date
-                       $flags = is_int( $flags ) ? $flags : self::READ_LATEST; // b/c
                }
                return self::newFromConds( $conds, (int)$flags );
        }
index 6845255..00761cf 100644 (file)
@@ -973,7 +973,40 @@ abstract class ContentHandler {
                }
 
                if ( $warn ) {
-                       wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()", 2 );
+                       // Log information about which handlers are registered for the legacy hook,
+                       // so we can find and fix them.
+
+                       $handlers = Hooks::getHandlers( $event );
+                       $handlerInfo = array();
+
+                       wfSuppressWarnings();
+
+                       foreach ( $handlers as $handler ) {
+                               $info = '';
+
+                               if ( is_array( $handler ) ) {
+                                       if ( is_object( $handler[0] ) ) {
+                                               $info = get_class( $handler[0] );
+                                       } else {
+                                               $info = $handler[0];
+                                       }
+
+                                       if ( isset( $handler[1] ) ) {
+                                               $info .= '::' . $handler[1];
+                                       }
+                               } else if ( is_object( $handler ) ) {
+                                       $info = get_class( $handler[0] );
+                                       $info .= '::on' . $event;
+                               } else {
+                                       $info = $handler;
+                               }
+
+                               $handlerInfo[] = $info;
+                       }
+
+                       wfRestoreWarnings();
+
+                       wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " . implode(', ', $handlerInfo), 2 );
                }
 
                // convert Content objects to text
index 5032bf6..2e45093 100644 (file)
@@ -86,6 +86,10 @@ class TempFSFile extends FSFile {
         */
        public function bind( $object ) {
                if ( is_object( $object ) ) {
+                       if ( !isset( $object->tempFSFileReferences ) ) {
+                               // Init first since $object might use __get() and return only a copy variable
+                               $object->tempFSFileReferences = array();
+                       }
                        $object->tempFSFileReferences[] = $this;
                }
        }
index 2303c78..f159d5d 100644 (file)
@@ -1026,6 +1026,9 @@ class FileBackendTest extends MediaWikiTestCase {
                        $this->assertNotEquals( false, $contents, "Local copy of $source exists ($backendName)." );
                        $this->assertEquals( $content[0], $contents, "Local copy of $source is correct ($backendName)." );
                }
+
+               $obj = new stdClass();
+               $tmpFile->bind( $obj );
        }
 
        function provider_testGetLocalCopy() {