From 94e2d9318a4948d9008d4ca8dbb4da837644f912 Mon Sep 17 00:00:00 2001 From: bsitu Date: Wed, 29 May 2013 12:29:42 -0700 Subject: [PATCH] Add new parameter $patrolFooterShown to hook ArticleViewFooter Some extensions like PageTriage will be able to use this new parameter to determine whether to show its own curation toolbar. Change-Id: I07e85aa37edc994c5a2bf9d011976b91ff01ab14 --- RELEASE-NOTES-1.22 | 2 ++ docs/hooks.txt | 1 + includes/Article.php | 20 ++++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 9a9aaa545f..ded2cee7fa 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -93,6 +93,8 @@ production. propper connect string. More about DRCP can be found at: http://www.oracle-base.com/articles/11g/database-resident-connection-pool-11gr1.php +* Add a new parameter $patrolFooterShown to hook ArticleViewFooter so the hook + handlers can take further action based on the status of the patrol footer === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/docs/hooks.txt b/docs/hooks.txt index 640d64299a..3c779857c3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -615,6 +615,7 @@ the user is redirected back to the page. 'ArticleViewFooter': After showing the footer section of an ordinary page view $article: Article object +$patrolFooterShown: boolean whether patrol footer is shown 'ArticleViewHeader': Before the parser cache is about to be tried for article viewing. diff --git a/includes/Article.php b/includes/Article.php index da24a98527..4972d2bd8c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1038,9 +1038,9 @@ class Article implements Page { } // Show a footer allowing the user to patrol the shown revision or page if possible - $this->showPatrolFooter(); + $patrolFooterShown = $this->showPatrolFooter(); - wfRunHooks( 'ArticleViewFooter', array( $this ) ); + wfRunHooks( 'ArticleViewFooter', array( $this, $patrolFooterShown ) ); } @@ -1050,6 +1050,8 @@ class Article implements Page { * desired, does nothing. * Side effect: When the patrol link is build, this method will call * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax. + * + * @return bool */ public function showPatrolFooter() { global $wgUseRCPatrol, $wgUseNPPatrol, $wgRCMaxAge, $wgEnableAPI, $wgEnableWriteAPI; @@ -1066,7 +1068,7 @@ class Article implements Page { if ( !$this->getTitle()->quickUserCan( 'patrol', $user ) || ( !$wgUseNPPatrol && !$wgUseRCPatrol ) ) { // Patrolling is fully disabled or the user isn't allowed to - return; + return false; } wfProfileIn( __METHOD__ ); @@ -1075,7 +1077,7 @@ class Article implements Page { // Check for cached results if ( $cache->get( wfMemcKey( 'NotPatrollableRevId', $this->getRevIdFetched() ) ) ) { wfProfileOut( __METHOD__ ); - return; + return false; } // We make use of a little index trick over here: @@ -1091,7 +1093,7 @@ class Article implements Page { // The revision is more than 6 hours older than the Max RC age // no need to torture the DB any further (6h because the RC might not be cleaned out regularly) wfProfileOut( __METHOD__ ); - return; + return false; } $rc = RecentChange::newFromConds( array( @@ -1115,7 +1117,7 @@ class Article implements Page { // Check for cached results if ( $cache->get( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ) ) ) { wfProfileOut( __METHOD__ ); - return; + return false; } $dbr = wfGetDB( DB_SLAVE ); @@ -1130,7 +1132,7 @@ class Article implements Page { // We either didn't find the oldest revision for the given page // or it's to old for the RC table (with 6h tolerance) wfProfileOut( __METHOD__ ); - return; + return false; } $rc = RecentChange::newFromConds( @@ -1159,7 +1161,7 @@ class Article implements Page { $cache->set( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ), '1', $wgRCMaxAge ); } - return; + return false; } $rcid = $rc->getAttribute( 'rc_id' ); @@ -1187,6 +1189,8 @@ class Article implements Page { wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() . '' ); + + return true; } /** -- 2.20.1