Page MenuHomePhabricator

Fix: Don't run SemanticDrilldown in CLI Mode (runJobs, rebuildDatabase)
Closed, ResolvedPublic

Description

In our corner-case, SemanticDrilldown is trancluded in some MediaWiki Categories.
This leads to SemanticDrilldown crashing the rebuildData Script, probably because some context is missing or different.

.PHP Notice:  Undefined offset: 0 in /var/www/www2.semantic-apps.net/wiki-wiki/extensions/SemanticDrilldown/includes/SD_Filter.php on line 142

Notice: Undefined offset: 0 in /var/www/www2.semantic-apps.net/wiki-wiki/extensions/SemanticDrilldown/includes/SD_Filter.php on line 142
PHP Notice:  Undefined offset: 0 in /var/www/www2.semantic-apps.net/wiki-wiki/extensions/SemanticDrilldown/includes/SD_Filter.php on line 144

Notice: Undefined offset: 0 in /var/www/www2.semantic-apps.net/wiki-wiki/extensions/SemanticDrilldown/includes/SD_Filter.php on line 144
PHP Notice:  Undefined offset: 0 in /var/www/www2.semantic-apps.net/wiki-wiki/extensions/SemanticDrilldown/includes/SD_Filter.php on line 153

The easiest solution for this problem is to disable SemanticDrilldown in CLI mode:

Index: specials/SD_BrowseData.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- specials/SD_BrowseData.php	(revision 56c33cbd8d22cb590e9557cc005944fc87118bf6)
+++ specials/SD_BrowseData.php	(revision )
@@ -18,6 +18,11 @@
 	}
 
 	function execute( $query ) {
+
+		if (php_sapi_name() == "cli") {
+			return false;
+		}
+
 		global $sdgScriptPath, $sdgContLang, $sdgNumResultsPerPage;
 
 		$out = $this->getOutput();
@@ -1059,6 +1064,10 @@
 		global $sdgContLang, $sdgScriptPath;
 		global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize;
 
+		if (php_sapi_name() == "cli") {
+			return '';
+		}
+
 		$categories = SDUtils::getCategoriesForBrowsing();
 		// if there are no categories, escape quickly
 		if ( count( $categories ) == 0 ) {
@@ -1302,6 +1311,10 @@
 	 */
 	protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
 		global $wgContLang;
+
+		if (php_sapi_name() == "cli") {
+			return false;
+		}
 
 		// Add Drilldown Results
 		$all_display_params = SDUtils::getDisplayParamsForCategory( $this->category );

Event Timeline

While testing, I realized that this fix will introduce a different problem: Since the #drilldowninfo function will store some of its content as semantic properties, those will not be restored when running rebuildDatabase.

I try to create a better fix.

I've updated the original patch, as the old one was buggy

I just checked this in - thank you!