X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=7498ca52b064306c6f46ce3ad4419cd4cec48088;hb=9dcc56b3c9e7a3212d0900ee23808b9402cad952;hp=95b7be265e901fce94b754d5ed7883adf11cc4b4;hpb=46eddc4b82404a58beb6de172371e0c108f4f482;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 95b7be265e..7498ca52b0 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -23,6 +23,7 @@ use MediaWiki\Edit\PreparedEdit; use \MediaWiki\Logger\LoggerFactory; use \MediaWiki\MediaWikiServices; +use Wikimedia\Assert\Assert; use Wikimedia\Rdbms\FakeResultWrapper; use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\DBError; @@ -671,7 +672,7 @@ class WikiPage implements Page, IDBAccessObject { $revision = Revision::newFromPageId( $this->getId(), $latest, $flags ); } else { $dbr = wfGetDB( DB_REPLICA ); - $revision = Revision::newKnownCurrent( $dbr, $this->getId(), $latest ); + $revision = Revision::newKnownCurrent( $dbr, $this->getTitle(), $latest ); } if ( $revision ) { // sanity @@ -1264,8 +1265,11 @@ class WikiPage implements Page, IDBAccessObject { $conditions['page_latest'] = $lastRevision; } + $revId = $revision->getId(); + Assert::parameter( $revId > 0, '$revision->getId()', 'must be > 0' ); + $row = [ /* SET */ - 'page_latest' => $revision->getId(), + 'page_latest' => $revId, 'page_touched' => $dbw->timestamp( $revision->getTimestamp() ), 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0, 'page_is_redirect' => $rt !== null ? 1 : 0, @@ -1305,7 +1309,7 @@ class WikiPage implements Page, IDBAccessObject { * Add row to the redirect table if this is a redirect, remove otherwise. * * @param IDatabase $dbw - * @param Title $redirectTitle Title object pointing to the redirect target, + * @param Title|null $redirectTitle Title object pointing to the redirect target, * or NULL if this is not a redirect * @param null|bool $lastRevIsRedirect If given, will optimize adding and * removing rows in redirect table. @@ -1617,13 +1621,15 @@ class WikiPage implements Page, IDBAccessObject { $old_revision = $this->getRevision(); // current revision $old_content = $this->getContent( Revision::RAW ); // current revision's content - if ( $old_content && $old_content->getModel() !== $content->getModel() ) { - $tags[] = 'mw-contentmodelchange'; + $handler = $content->getContentHandler(); + $tag = $handler->getChangeTag( $old_content, $content, $flags ); + // If there is no applicable tag, null is returned, so we need to check + if ( $tag ) { + $tags[] = $tag; } - // Provide autosummaries if one is not provided and autosummaries are enabled + // Provide autosummaries if summary is not provided and autosummaries are enabled if ( $wgUseAutomaticEditSummaries && ( $flags & EDIT_AUTOSUMMARY ) && $summary == '' ) { - $handler = $content->getContentHandler(); $summary = $handler->getAutosummary( $old_content, $content, $flags ); } @@ -3211,6 +3217,10 @@ class WikiPage implements Page, IDBAccessObject { $targetContent = $target->getContent(); $changingContentModel = $targetContent->getModel() !== $current->getContentModel(); + if ( in_array( 'mw-rollback', ChangeTags::getSoftwareTags() ) ) { + $tags[] = 'mw-rollback'; + } + // Actually store the edit $status = $this->doEditContent( $targetContent, @@ -3287,7 +3297,8 @@ class WikiPage implements Page, IDBAccessObject { 'summary' => $summary, 'current' => $current, 'target' => $target, - 'newid' => $revId + 'newid' => $revId, + 'tags' => $tags ]; return []; @@ -3317,7 +3328,9 @@ class WikiPage implements Page, IDBAccessObject { MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title ); // Invalidate caches of articles which include this page - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' ) + ); if ( $title->getNamespace() == NS_CATEGORY ) { // Load the Category object, which will schedule a job to create @@ -3355,7 +3368,9 @@ class WikiPage implements Page, IDBAccessObject { // Images if ( $title->getNamespace() == NS_FILE ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' ) + ); } // User talk pages @@ -3378,10 +3393,14 @@ class WikiPage implements Page, IDBAccessObject { */ public static function onArticleEdit( Title $title, Revision $revision = null ) { // Invalidate caches of articles which include this page - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' ) + ); // Invalidate the caches of all pages which redirect here - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'redirect' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'redirect', 'page-edit' ) + ); MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );