Thiemo Kreuz (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/399412 )
Change subject: Disable hooks instead of accessing private Cite properties
......................................................................
Disable hooks instead of accessing private Cite properties
I am not absolutely shure what I do here is really a working
alternative for what the code did before. I am suggesting this as a
much cleaner replacement for the previous hack, but ask others more
familiar with this extension to actually try it out. I have not tested
this suggestion.
Bug: T183323
Change-Id: Ib9e85b0eb590695ba2ea58ce30a34fe662fdb708
---
M DPL.php
M DPLArticle.php
2 files changed, 20 insertions(+), 23 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DynamicPageList
refs/changes/12/399412/1
diff --git a/DPL.php b/DPL.php
index 8f7cba9..77f1cc9 100644
--- a/DPL.php
+++ b/DPL.php
@@ -4,6 +4,9 @@
class DPL {
+ /**
+ * @var DPLArticle[]
+ */
public $mArticles;
public $mHeadingType; // type of heading: category, user, etc.
(depends on 'ordermethod' param)
public $mHListMode; // html list mode for headings
@@ -16,6 +19,10 @@
public $mIncSecLabelsMatch = array(); // array of match patterns for
sections to transclude
public $mIncSecLabelsNotMatch = array(); // array of NOT match patterns
for sections to transclude
public $mIncParsed; // whether to match raw parameters or parsed
contents
+
+ /**
+ * @var Parser
+ */
public $mParser;
public $mParserOptions;
public $mParserTitle;
@@ -23,6 +30,10 @@
public $mOutput;
public $mReplaceInTitle;
public $filteredCount = 0; // number of (filtered) row count
+
+ /**
+ * @var string[]
+ */
public $nameSpaces;
public $mTableRow; // formatting rules for table fields
@@ -31,7 +42,7 @@
$includeseclabelsnotmatch,
$includematchparsed, &$parser, $logger, $replaceInTitle, $iTitleMaxLen,
$defaultTemplateSuffix, $aTableRow,
$bIncludeTrim, $iTableSortCol, $updateRules, $deleteRules ) {
- global $wgContLang;
+ global $wgContLang, $wgHooks;
$this->nameSpaces = $wgContLang->getNamespaces();
$this->mArticles = $articles;
$this->mListMode = $listmode;
@@ -70,30 +81,12 @@
// The CITE extension registers a hook on parser->clearState
// We must UNDO the effect of that call (Cite->clearState)
because otherwise all Cititations would be lost
- // that were made before a DPL call; we borrow a handle to the
cite object from the parser“s tag hooks
+ // that were made before a DPL call
- $citeObject = null;
- // store current state of Cite Object
- if ( isset( $parser->mTagHooks['references'] ) ) {
- $citeObject =
$parser->mTagHooks['references'][0];
- $tmpCiteGroupCnt =
$citeObject->mGroupCnt;
- $tmpCiteOutCnt =
$citeObject->mOutCnt;
- $tmpCiteCallCnt =
$citeObject->mCallCnt;
- $tmpCiteRefs =
$citeObject->mRefs;
- $tmpCiteReferencesErrors =
$citeObject->mReferencesErrors;
- $tmpCiteRefCallStack =
$citeObject->mRefCallStack;
- }
- // now clear the state
+ $clearStateHooks = $wgHooks['ParserClearState'];
+ $wgHooks['ParserClearState'] = [];
$this->mParser->clearState(); // eliminated to avoid conflict
with CITE extension
- // restore Cite Object
- if ( $citeObject != null ) {
- $citeObject->mGroupCnt =
$tmpCiteGroupCnt;
- $citeObject->mOutCnt =
$tmpCiteOutCnt;
- $citeObject->mCallCnt =
$tmpCiteCallCnt;
- $citeObject->mRefs =
$tmpCiteRefs;
- $citeObject->mReferencesErrors =
$tmpCiteReferencesErrors;
- $citeObject->mRefCallStack =
$tmpCiteRefCallStack;
- }
+ $wgHooks['ParserClearState'] = $clearStateHooks;
$this->mParserOptions = $parser->mOptions;
$this->mParserTitle = $parser->mTitle;
diff --git a/DPLArticle.php b/DPLArticle.php
index f35fa8f..d09cb06 100644
--- a/DPLArticle.php
+++ b/DPLArticle.php
@@ -2,6 +2,10 @@
// Simple Article/Page class with properties used in the DPL
class DPLArticle {
+
+ /**
+ * @var Title
+ */
public $mTitle = ''; // title
public $mNamespace = -1; // namespace (number)
public $mID = 0; // page_id
--
To view, visit https://gerrit.wikimedia.org/r/399412
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9e85b0eb590695ba2ea58ce30a34fe662fdb708
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DynamicPageList
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits