X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=8cc5a39b5111fedc0218e1b36ac55b691a0ce207;hb=0d6ef1c0b20093e03e95a6b7f303c7a2de5de3af;hp=fa01ce49a65b6781439519ba90eac82241136718;hpb=b5ca4f5b26996253fe8f6d2107e91485130d4d9a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index fa01ce49a6..8cc5a39b51 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -813,7 +813,7 @@ class WikiPage implements Page, IDBAccessObject { * * @since 1.21 */ - public function getContent( $audience = Revision::FOR_PUBLIC, User $user = null ) { + public function getContent( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) { $this->loadLastEdit(); if ( $this->mLastRevision ) { return $this->mLastRevision->getContent( $audience, $user ); @@ -851,7 +851,7 @@ class WikiPage implements Page, IDBAccessObject { * to the $audience parameter * @return int User ID for the user that made the last article revision */ - public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) { + public function getUser( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) { $this->loadLastEdit(); if ( $this->mLastRevision ) { return $this->mLastRevision->getUser( $audience, $user ); @@ -870,7 +870,7 @@ class WikiPage implements Page, IDBAccessObject { * to the $audience parameter * @return User|null */ - public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) { + public function getCreator( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) { $revision = $this->getOldestRevision(); if ( $revision ) { $userName = $revision->getUserText( $audience, $user ); @@ -889,7 +889,7 @@ class WikiPage implements Page, IDBAccessObject { * to the $audience parameter * @return string Username of the user that made the last article revision */ - public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) { + public function getUserText( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) { $this->loadLastEdit(); if ( $this->mLastRevision ) { return $this->mLastRevision->getUserText( $audience, $user ); @@ -908,7 +908,7 @@ class WikiPage implements Page, IDBAccessObject { * @return string|null Comment stored for the last article revision, or null if the specified * audience does not have access to the comment. */ - public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) { + public function getComment( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) { $this->loadLastEdit(); if ( $this->mLastRevision ) { return $this->mLastRevision->getComment( $audience, $user ); @@ -1063,6 +1063,7 @@ class WikiPage implements Page, IDBAccessObject { * Insert or update the redirect table entry for this page to indicate it redirects to $rt * @param Title $rt Redirect target * @param int|null $oldLatest Prior page_latest for check and set + * @return bool Success */ public function insertRedirectEntry( Title $rt, $oldLatest = null ) { $dbw = wfGetDB( DB_MASTER ); @@ -1089,9 +1090,14 @@ class WikiPage implements Page, IDBAccessObject { ], __METHOD__ ); + $success = true; + } else { + $success = false; } $dbw->endAtomic( __METHOD__ ); + + return $success; } /** @@ -1176,7 +1182,7 @@ class WikiPage implements Page, IDBAccessObject { $conds[] = 'NOT(' . $actorMigration->getWhere( $dbr, 'rev_user', $user )['conds'] . ')'; // Username hidden? - $conds[] = "{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0"; + $conds[] = "{$dbr->bitAnd( 'rev_deleted', RevisionRecord::DELETED_USER )} = 0"; $jconds = [ 'user' => [ 'LEFT JOIN', $actorQuery['fields']['rev_user'] . ' = user_id' ], @@ -1461,18 +1467,19 @@ class WikiPage implements Page, IDBAccessObject { } if ( $isRedirect ) { - $this->insertRedirectEntry( $redirectTitle ); + $success = $this->insertRedirectEntry( $redirectTitle ); } else { // This is not a redirect, remove row from redirect table $where = [ 'rd_from' => $this->getId() ]; $dbw->delete( 'redirect', $where, __METHOD__ ); + $success = true; } if ( $this->getTitle()->getNamespace() == NS_FILE ) { RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() ); } - return ( $dbw->affectedRows() != 0 ); + return $success; } /** @@ -1588,7 +1595,7 @@ class WikiPage implements Page, IDBAccessObject { $baseRevId = null; if ( $edittime && $sectionId !== 'new' ) { $lb = $this->getDBLoadBalancer(); - $dbr = $lb->getConnection( DB_REPLICA ); + $dbr = $lb->getConnectionRef( DB_REPLICA ); $rev = Revision::loadFromTimestamp( $dbr, $this->mTitle, $edittime ); // Try the master if this thread may have just added it. // This could be abstracted into a Revision method, but we don't want @@ -1597,7 +1604,7 @@ class WikiPage implements Page, IDBAccessObject { && $lb->getServerCount() > 1 && $lb->hasOrMadeRecentMasterChanges() ) { - $dbw = $lb->getConnection( DB_MASTER ); + $dbw = $lb->getConnectionRef( DB_MASTER ); $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); } if ( $rev ) { @@ -2695,7 +2702,7 @@ class WikiPage implements Page, IDBAccessObject { // we need to remember the old content so we can use it to generate all deletion updates. $revision = $this->getRevision(); try { - $content = $this->getContent( Revision::RAW ); + $content = $this->getContent( RevisionRecord::RAW ); } catch ( Exception $ex ) { wfLogWarning( __METHOD__ . ': failed to load content during deletion! ' . $ex->getMessage() ); @@ -2811,9 +2818,9 @@ class WikiPage implements Page, IDBAccessObject { $status->value = $logid; // Show log excerpt on 404 pages rather than just a link - $cache = MediaWikiServices::getInstance()->getMainObjectStash(); - $key = $cache->makeKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) ); - $cache->set( $key, 1, $cache::TTL_DAY ); + $dbCache = ObjectCache::getInstance( 'db-replicated' ); + $key = $dbCache->makeKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) ); + $dbCache->set( $key, 1, $dbCache::TTL_DAY ); } return $status; @@ -2844,7 +2851,7 @@ class WikiPage implements Page, IDBAccessObject { // Bitfields to further suppress the content if ( $suppress ) { - $bitfield = Revision::SUPPRESSED_ALL; + $bitfield = RevisionRecord::SUPPRESSED_ALL; $revQuery['fields'] = array_diff( $revQuery['fields'], [ 'rev_deleted' ] ); } @@ -3503,7 +3510,7 @@ class WikiPage implements Page, IDBAccessObject { self::purgeInterwikiCheckKey( $title ); } - /**#@-*/ + /** #@- */ /** * Purge the check key for cross-wiki cache entries referencing this page @@ -3768,7 +3775,7 @@ class WikiPage implements Page, IDBAccessObject { $slotContent = [ SlotRecord::MAIN => $rev ]; } else { $slotContent = array_map( function ( SlotRecord $slot ) { - return $slot->getContent( Revision::RAW ); + return $slot->getContent( RevisionRecord::RAW ); }, $rev->getSlots()->getSlots() ); }