r83213 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83212‎ | r83213 | r83214 >
Date:11:45, 4 March 2011
Author:janpaul123
Status:ok (Comments)
Tags:
Comment:
Followup of r82891 and r82894. Fixes hook for InlineEditor, which forces a page reparse when either a <ref> or <references> tag shows up. Doesn't affect normal behaviour when not using InlineEditor.
Modified paths:
  • /trunk/extensions/Cite/Cite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/Cite_body.php
@@ -71,6 +71,12 @@
7272 * @var int
7373 */
7474 var $mInCnt = 0;
 75+
 76+ /**
 77+ * Counter to track the total number of (useful) calls to either the
 78+ * ref or references tag hook
 79+ */
 80+ var $mCallCnt = 0;
7581
7682 /**
7783 * The backlinks, in order, to pass as $3 to
@@ -151,6 +157,7 @@
152158 if ( $this->mInCite ) {
153159 return htmlspecialchars( "<ref>$str</ref>" );
154160 } else {
 161+ $this->mCallCnt++;
155162 $this->mInCite = true;
156163 $ret = $this->guardedRef( $str, $argv, $parser );
157164 $this->mInCite = false;
@@ -507,6 +514,7 @@
508515 return htmlspecialchars( "<references>$str</references>" );
509516 }
510517 } else {
 518+ $this->mCallCnt++;
511519 $this->mInReferences = true;
512520 $ret = $this->guardedReferences( $str, $argv, $parser );
513521 $this->mInReferences = false;
@@ -984,6 +992,7 @@
985993 $this->mGroupCnt = array();
986994 $this->mOutCnt = - 1;
987995 $this->mInCnt = 0;
 996+ $this->mCallCnt = 0;
988997 $this->mRefs = array();
989998 $this->mReferencesErrors = array();
990999 $this->mRefCallStack = array();
@@ -1015,11 +1024,11 @@
10161025 }
10171026
10181027 /**
1019 - * Hook for the InlineEditor extension. If any reference is in the text, the entire
 1028+ * Hook for the InlineEditor extension. If any ref or reference reference tag is in the text, the entire
10201029 * page should be reparsed, so we return false in that case.
10211030 */
1022 - function checkAnyRefs( &$output ) {
1023 - return ( count( $this->mRefs ) <= 0 );
 1031+ function checkAnyCalls( &$output ) {
 1032+ return ( $this->mCallCnt <= 0 );
10241033 }
10251034
10261035 /**
@@ -1033,7 +1042,7 @@
10341043
10351044 $wgHooks['ParserClearState'][] = array( self::$instance, 'clearState' );
10361045 $wgHooks['ParserBeforeTidy'][] = array( self::$instance, 'checkRefsNoReferences' );
1037 - $wgHooks['InlineEditorPartialAfterParse'][] = array( self::$instance, 'checkAnyRefs' );
 1046+ $wgHooks['InlineEditorPartialAfterParse'][] = array( self::$instance, 'checkAnyCalls' );
10381047 }
10391048 $parser->setHook( 'ref' , array( self::$instance, 'ref' ) );
10401049 $parser->setHook( 'references' , array( self::$instance, 'references' ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82891Added hook to support partial rendering for the InlineEditor extension. Doesn...janpaul12314:50, 27 February 2011
r82894Fixed call per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82891#c14483janpaul12315:30, 27 February 2011

Comments

#Comment by Bryan (talk | contribs)   11:48, 4 March 2011

Abbreviating variable names for a gain of 2 characters is really not necessary. Just make it $mCallCount.

#Comment by JanPaul123 (talk | contribs)   11:49, 4 March 2011

I agree with that, but as the class already uses $mOutCnt and $mInCnt, I thought it'd be good to use this convention.

#Comment by Bryan (talk | contribs)   11:54, 4 March 2011

Yeah, that makes sense.

Status & tagging log