Merge "Made WikiPage::isRedirect() actually use page_is_redirect"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 8b88986..d3978ea 100644 (file)
@@ -469,12 +469,11 @@ class WikiPage implements Page, IDBAccessObject {
         * @return bool
         */
        public function isRedirect() {
-               $content = $this->getContent();
-               if ( !$content ) {
-                       return false;
+               if ( !$this->mDataLoaded ) {
+                       $this->loadPageData();
                }
 
-               return $content->isRedirect();
+               return (bool)$this->mIsRedirect;
        }
 
        /**
@@ -950,7 +949,6 @@ class WikiPage implements Page, IDBAccessObject {
                if ( $rt->isExternal() ) {
                        if ( $rt->isLocal() ) {
                                // Offsite wikis need an HTTP redirect.
-                               //
                                // This can be hard to reverse and may produce loops,
                                // so they may be disabled in the site configuration.
                                $source = $this->mTitle->getFullURL( 'redirect=no' );
@@ -964,10 +962,8 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( $rt->isSpecialPage() ) {
                        // Gotta handle redirects to special pages differently:
-                       // Fill the HTTP response "Location" header and ignore
-                       // the rest of the page we're on.
-                       //
-                       // Some pages are not valid targets
+                       // Fill the HTTP response "Location" header and ignore the rest of the page we're on.
+                       // Some pages are not valid targets.
                        if ( $rt->isValidRedirectTarget() ) {
                                return $rt->getFullURL();
                        } else {
@@ -1434,7 +1430,7 @@ class WikiPage implements Page, IDBAccessObject {
        ) {
                ContentHandler::deprecated( __METHOD__, '1.21' );
 
-               //NOTE: keep condition in sync with condition in replaceSectionContent!
+               // NOTE: keep condition in sync with condition in replaceSectionContent!
                if ( strval( $sectionId ) === '' ) {
                        // Whole-page edit; let the whole text through
                        return $text;
@@ -1811,8 +1807,7 @@ class WikiPage implements Page, IDBAccessObject {
                                }
                                $revisionId = $revision->insertOn( $dbw );
 
-                               // Update page
-                               //
+                               // Update page.
                                // We check for conflicts by comparing $oldid with the current latest revision ID.
                                $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
 
@@ -2046,7 +2041,7 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                $user = is_null( $user ) ? $wgUser : $user;
-               //XXX: check $user->getId() here???
+               // XXX: check $user->getId() here???
 
                // Use a sane default for $serialFormat, see bug 57026
                if ( $serialFormat === null ) {
@@ -2817,16 +2812,18 @@ class WikiPage implements Page, IDBAccessObject {
                        $bitfield = 'rev_deleted';
                }
 
-               // For now, shunt the revision data into the archive table.
-               // Text is *not* removed from the text table; bulk storage
-               // is left intact to avoid breaking block-compression or
-               // immutable storage schemes.
-               //
-               // For backwards compatibility, note that some older archive
-               // table entries will have ar_text and ar_flags fields still.
-               //
-               // In the future, we may keep revisions and mark them with
-               // the rev_deleted field, which is reserved for this purpose.
+               /**
+                * For now, shunt the revision data into the archive table.
+                * Text is *not* removed from the text table; bulk storage
+                * is left intact to avoid breaking block-compression or
+                * immutable storage schemes.
+                *
+                * For backwards compatibility, note that some older archive
+                * table entries will have ar_text and ar_flags fields still.
+                *
+                * In the future, we may keep revisions and mark them with
+                * the rev_deleted field, which is reserved for this purpose.
+                */
 
                $row = array(
                        'ar_namespace'  => 'page_namespace',
@@ -2933,12 +2930,15 @@ class WikiPage implements Page, IDBAccessObject {
         *   may already return null when the page proper was deleted.
         */
        public function doDeleteUpdates( $id, Content $content = null ) {
-               // update site status
+               // Update site status
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) );
 
-               // remove secondary indexes, etc
+               // Delete pagelinks, update secondary indexes, etc
                $updates = $this->getDeletionUpdates( $content );
-               DataUpdate::runUpdates( $updates, 'enqueue' );
+               // Make sure an enqueued jobs run after commit so they see the deletion
+               wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $updates ) {
+                       DataUpdate::runUpdates( $updates, 'enqueue' );
+               } );
 
                // Reparse any pages transcluding this page
                LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );