* @return bool
*/
public function showPatrolFooter() {
- global $wgUseNPPatrol, $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
+ global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
$outputPage = $this->getContext()->getOutput();
$user = $this->getContext()->getUser();
$rc = false;
if ( !$this->getTitle()->quickUserCan( 'patrol', $user )
- || !( $wgUseRCPatrol || $wgUseNPPatrol )
+ || !( $wgUseRCPatrol || $wgUseNPPatrol || $wgUseFilePatrol )
) {
// Patrolling is disabled or the user isn't allowed to
return false;
__METHOD__
);
+ $cantPatrolNewPage = false;
+ $cantPatrolFile = false;
+
if ( $oldestRevisionTimestamp
&& RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
) {
),
__METHOD__
);
+ if ( $rc ) {
+ // Use generic patrol message for new pages
+ $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
+ }
+ } else {
+ $cantPatrolNewPage = true;
+ }
+
+ // Allow patrolling of latest file upload
+ if ( !$rc && $wgUseFilePatrol && $this->getTitle()->getNamespace() === NS_FILE ) {
+ // Retrieve timestamp of most recent upload
+ $newestUploadTimestamp = $dbr->selectField(
+ 'image',
+ 'MAX( img_timestamp )',
+ array( 'img_name' => $this->getTitle()->getDBkey() ),
+ __METHOD__
+ );
+ if ( $newestUploadTimestamp
+ && RecentChange::isInRCLifespan( $newestUploadTimestamp, 21600 )
+ ) {
+ // 6h tolerance because the RC might not be cleaned out regularly
+ $rc = RecentChange::newFromConds(
+ array(
+ 'rc_type' => RC_LOG,
+ 'rc_log_type' => 'upload',
+ 'rc_timestamp' => $newestUploadTimestamp,
+ 'rc_namespace' => NS_FILE,
+ 'rc_cur_id' => $this->getTitle()->getArticleID(),
+ 'rc_patrolled' => 0
+ ),
+ __METHOD__,
+ array( 'USE INDEX' => 'rc_timestamp' )
+ );
+ if ( $rc ) {
+ // Use patrol message specific to files
+ $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
+ }
+ } else {
+ $cantPatrolFile = true;
+ }
} else {
+ $cantPatrolFile = true;
+ }
+
+ if ( $cantPatrolFile && $cantPatrolNewPage ) {
// Cache the information we gathered above in case we can't patrol
// Don't cache in case we can patrol as this could change
$cache->set( $key, '1' );
$link = Linker::linkKnown(
$this->getTitle(),
- wfMessage( 'markaspatrolledtext' )->escaped(),
+ $markPatrolledMsg->escaped(),
array(),
array(
'action' => 'markpatrolled',
return true;
}
+ /**
+ * Purge the cache used to check if it is worth showing the patrol footer
+ * For example, it is done during re-uploads when file patrol is used.
+ * @param int $articleID ID of the article to purge
+ * @since 1.27
+ */
+ public static function purgePatrolFooterCache( $articleID ) {
+ $cache = ObjectCache::getMainWANInstance();
+ $cache->touchCheckKey( wfMemcKey( 'unpatrollable-page', $articleID ) );
+ }
+
/**
* Show the error text for a missing article. For articles in the MediaWiki
* namespace, show the default message text. To be called from Article::view().