Gergő Tisza has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/402473 )
Change subject: Avoid replag errors in Article::getFilePatrolChange() ...................................................................... Avoid replag errors in Article::getFilePatrolChange() Ignore Article::getNewPagePatrolChange() which is not used in a way where occasonially failing to report a page as unpatrolled would matter. Adds some master lookups which will be triggered on recently-expired-from-RC files, while fixing a bug that's only relevant on small wikis which use no external caching for files at all. Not sure if that's a good tradeoff. Change-Id: I1e8cc0d292256481b42a4577dff5e9cf36e48396 --- M includes/filerepo/file/LocalFile.php M includes/page/Article.php 2 files changed, 35 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/402473/1 diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index b65aedd..7c8575d 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2124,11 +2124,6 @@ $headers = parent::getContentHeaders(); - // If file patrolling is enabled, and file is unpatrolled, mark it so. - // Note that this is unreliable for very recently (re)uploaded files, due to the way - // Article::getFilePatrolChange works. If the file backend can remember headers, this - // method won't be used much, and if it can't, getContentHeaders() is not reliable anyway, - // so this should be good enough. if ( $wgUseFilePatrol ) { $article = Article::newFromTitle( $this->getTitle(), RequestContext::getMain() ); if ( $article->getFilePatrolChange() ) { diff --git a/includes/page/Article.php b/includes/page/Article.php index d4e8198..b414266 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1076,11 +1076,28 @@ [ 'img_name' => $title->getDBkey() ], __METHOD__ ); + if ( !$newestUploadTimestamp ) { + // Might be a remote file with a local file page override. + $file = wfFindFile( $title ); + if ( $file && !$file->isLocal() ) { + $cache->set( $key, '1' ); + return false; + } + + // Otherwise, must be a recent upload that's not visible due to replication lag. + $dbw = wfGetDB( DB_MASTER ); + $newestUploadTimestamp = $dbw->selectField( + 'image', + 'MAX( img_timestamp )', + [ 'img_name' => $title->getDBkey() ], + __METHOD__ + ); + } if ( !$newestUploadTimestamp || !RecentChange::isInRCLifespan( $newestUploadTimestamp, self::$rcTolerance ) ) { - // Not a local file or too old to be patrollable. This only changes when a new - // version is uploaded, and we clear the cache then, so safe to cache forever. + // Too old to be patrollable. This only changes when a new version is uploaded, and + // we clear the cache then, so safe to cache forever. $cache->set( $key, '1' ); return false; } @@ -1095,7 +1112,22 @@ __METHOD__ ); if ( !$rc ) { - // RC entry probably too new to be visible due to replication lag. Fail but don't cache. + // Like above, check for replag. + $rc = RecentChange::newFromConds( + [ + 'rc_type' => RC_LOG, + 'rc_log_type' => 'upload', + 'rc_timestamp' => $newestUploadTimestamp, + 'rc_namespace' => NS_FILE, + 'rc_cur_id' => $title->getArticleID() + ], + __METHOD__, + DB_MASTER + ); + } + if ( !$rc ) { + // Change is probably in the tolerance interval and was deleted from RC recently. + $cache->set( $key, '1' ); return false; } -- To view, visit https://gerrit.wikimedia.org/r/402473 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e8cc0d292256481b42a4577dff5e9cf36e48396 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits