Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/114142
Change subject: Unbreak this extension by killing $wgCategoryTreeDynamicTag
......................................................................
Unbreak this extension by killing $wgCategoryTreeDynamicTag
Somewhere along the line this extension's JS was refactored,
except for part which was left as is, and was calling functions
since renamed, and still assuming top loaded...
Just kill $wgCategoryTreeDynamicTag, since it doesn't work, it
hasn't worked for a while, and it looks like a bit of work to
make it work properly. Also change the cache disabling defaults
of this extension to be 6 hours so it doesn't cause explosions.
If someone wants the feature represented by $wgCategoryTreeDynamicTag
they can of course re-introduce it in a subsequent commit. In the
mean time, lets not have broken code.
Bug: 59798
Change-Id: I01e0bd264e2a007cd9de017d10667bb2809d70a9
---
M CategoryTree.php
M CategoryTreeFunctions.php
2 files changed, 18 insertions(+), 36 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CategoryTree
refs/changes/42/114142/1
diff --git a/CategoryTree.php b/CategoryTree.php
index 5d0bbdf..bcc5e01 100644
--- a/CategoryTree.php
+++ b/CategoryTree.php
@@ -38,9 +38,8 @@
*
* $wgCategoryTreeMaxChildren - maximum number of children shown in a tree
node. Default is 200
* $wgCategoryTreeAllowTag - enable <categorytree> tag. Default is true.
- * $wgCategoryTreeDynamicTag - loads the first level of the tree in a
<categorytag> dynamically.
- * This way, the cache does not need to be
disabled. Default is false.
- * $wgCategoryTreeDisableCache - disabled the parser cache for pages with a
<categorytree> tag. Default is true.
+ * $wgCategoryTreeDisableCache - disable the parser cache for pages with a
<categorytree> tag or provide
+ * max cache time in seconds. Default is 6 hours.
* $wgCategoryTreeUseCache - enable HTTP cache for anon users. Default is
false.
* $wgCategoryTreeMaxDepth - maximum value for depth argument; An array that
maps mode values to
* the maximum depth acceptable for the depth option.
@@ -53,8 +52,7 @@
$wgCategoryTreeMaxChildren = 200;
$wgCategoryTreeAllowTag = true;
-$wgCategoryTreeDisableCache = true;
-$wgCategoryTreeDynamicTag = false;
+$wgCategoryTreeDisableCache = 6*60*60;
$wgCategoryTreeHTTPCache = false;
# $wgCategoryTreeUnifiedView = true;
$wgCategoryTreeMaxDepth = array( CT_MODE_PAGES => 1, CT_MODE_ALL => 1,
CT_MODE_CATEGORIES => 2 );
diff --git a/CategoryTreeFunctions.php b/CategoryTreeFunctions.php
index a84ba3d..b216dfe 100644
--- a/CategoryTreeFunctions.php
+++ b/CategoryTreeFunctions.php
@@ -395,16 +395,19 @@
* @return bool|string
*/
function getTag( $parser, $category, $hideroot = false, $attr, $depth =
1, $allowMissing = false ) {
- global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
- static $uniq = 0;
+ global $wgCategoryTreeDisableCache;
$category = trim( $category );
if ( $category === '' ) {
return false;
}
- if ( $parser && $wgCategoryTreeDisableCache &&
!$wgCategoryTreeDynamicTag ) {
- $parser->disableCache();
+ if ( $parser ) {
+ if ( $wgCategoryTreeDisableCache === true ) {
+ $parser->disableCache();
+ } elseif ( is_int( $wgCategoryTreeDisableCache ) ) {
+ $parser->getOutput()->updateCacheExpiry(
$wgCategoryTreeDisableCache );
+ }
}
$title = self::makeTitle( $category );
@@ -436,18 +439,9 @@
}
else {
if ( !$hideroot ) {
- $html .= $this->renderNode( $title, $depth,
$wgCategoryTreeDynamicTag );
- } elseif ( !$wgCategoryTreeDynamicTag ) {
- $html .= $this->renderChildren( $title, $depth
);
+ $html .= $this->renderNode( $title, $depth,
false );
} else {
- $uniq += 1;
- $load = 'ct-' . $uniq . '-' . mt_rand( 1,
100000 );
-
- $html .= Xml::openElement( 'script', array(
'type' => 'text/javascript', 'id' => $load ) );
- $html .= 'categoryTreeLoadChildren("' .
Xml::escapeJsString( $title->getDBkey() ) . '", '
- .
$this->getOptionsAsJsStructure( $depth )
- . ', document.getElementById("'
. $load . '").parentNode);';
- $html .= Xml::closeElement( 'script' );
+ $html .= $this->renderChildren( $title, $depth
);
}
}
@@ -537,7 +531,7 @@
$cat = Category::newFromRow( $row, $t );
}
- $s = $this->renderNodeInfo( $t, $cat, $depth - 1, false
);
+ $s = $this->renderNodeInfo( $t, $cat, $depth - 1 );
$s .= "\n\t\t";
if ( $row->page_namespace == NS_CATEGORY ) {
@@ -612,10 +606,9 @@
* Returns a string with a HTML represenation of the given page.
* @param $title Title
* @param int $children
- * @param bool $loadchildren
* @return string
*/
- function renderNode( $title, $children = 0, $loadchildren = false ) {
+ function renderNode( $title, $children = 0 ) {
global $wgCategoryTreeUseCategoryTable;
if ( $wgCategoryTreeUseCategoryTable && $title->getNamespace()
== NS_CATEGORY && !$this->isInverse() ) {
@@ -624,7 +617,7 @@
$cat = null;
}
- return $this->renderNodeInfo( $title, $cat, $children,
$loadchildren );
+ return $this->renderNodeInfo( $title, $cat, $children );
}
/**
@@ -633,20 +626,11 @@
* @param $title Title
* @param $cat Category
* @param $children int
- * @param $loadchildren bool
* @return string
*/
- function renderNodeInfo( $title, $cat, $children = 0, $loadchildren =
false ) {
- static $uniq = 0;
-
+ function renderNodeInfo( $title, $cat, $children = 0 ) {
$mode = $this->getOption( 'mode' );
$load = false;
-
- if ( $children > 0 && $loadchildren ) {
- $uniq += 1;
-
- $load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );
- }
$ns = $title->getNamespace();
$key = $title->getDBkey();
@@ -740,7 +724,7 @@
$linkattr['style'] = 'display: none;'; //
Unhidden by JS
$linkattr['data-ct-title'] = $key;
- if ( $children == 0 || $loadchildren ) {
+ if ( $children == 0 ) {
$tag = 'span';
$txt = wfMessage(
'categorytree-expand-bullet' )->plain();
# Don't load this message for ajax
requests, so that we don't have to initialise $wgLang
@@ -818,7 +802,7 @@
)
);
- if ( $ns == NS_CATEGORY && $children > 0 && !$loadchildren ) {
+ if ( $ns == NS_CATEGORY && $children > 0 ) {
$children = $this->renderChildren( $title, $children );
if ( $children == '' ) {
$s .= Xml::openElement( 'i', array( 'class' =>
'CategoryTreeNotice' ) );
--
To view, visit https://gerrit.wikimedia.org/r/114142
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I01e0bd264e2a007cd9de017d10667bb2809d70a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CategoryTree
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits