Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/367854 )
Change subject: BSExtendedSearch: Add WikiFarming integration
......................................................................
BSExtendedSearch: Add WikiFarming integration
This files allowes to create a new search index when a new wiki gets created
NEEDS CHERRY-PICK TO REL1_27
Change-Id: I174dec162bf8c9605ebfbd4da3f71e7f946d6d91
---
A ExtendedSearch/maintenance/SimpleFarmer.ExtendedSearch.Integration.php
1 file changed, 54 insertions(+), 0 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/54/367854/1
diff --git
a/ExtendedSearch/maintenance/SimpleFarmer.ExtendedSearch.Integration.php
b/ExtendedSearch/maintenance/SimpleFarmer.ExtendedSearch.Integration.php
new file mode 100644
index 0000000..d4a9745
--- /dev/null
+++ b/ExtendedSearch/maintenance/SimpleFarmer.ExtendedSearch.Integration.php
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * When "Extension:BlueSpiceWikiFarm/SimpleFarmer" creates a new wiki instance
+ * (by cloning of from the scratch) the search index for this new instance
needs
+ * to be created
+ *
+ * ATTENTION: This file needs to be included in the 'LocalSettings.php'
+ * _before_ 'BlueSpiceWikiFarm.php'!
+ */
+
+$wgHooks['BSSimpleFarmerAPICreateWikiBeforeResult'][] =
'bs_extendedSearch_onBSSimpleFarmerAPICxWikiBeforeResult';
+$wgHooks['BSSimpleFarmerAPICloneWikiBeforeResult'][] =
'bs_extendedSearch_onBSSimpleFarmerAPICxWikiBeforeResult';
+
+/**
+ * Runs "searchUpdate.php" for a new instance created by
+ * "Extension:BlueSpiceWikiFarm/SimpleFarmer"
+ * @param array $aResultMessages
+ * @param SimpleFarmerInstaller $oInstaller
+ * @param string $sPath
+ * @param string $sTitle
+ * @param string $sSourcePath
+ * @return boolean
+ */
+function bs_extendedSearch_onBSSimpleFarmerAPICxWikiBeforeResult(
&$aResultMessages, &$oInstaller, $sPath, $sTitle, $sSourcePath = '' ) {
+ global $wgPhpCli;
+
+ $sScript = __DIR__ . '/searchUpdate.php';
+
//http://stackoverflow.com/questions/222414/asynchronous-shell-exec-in-php
+ $sCmd = "$wgPhpCli $sScript --sfr \"$sPath\" > /dev/null 2>/dev/null
&";
+ $sCmd = escapeshellcmd( $sCmd );
+
+ $sResult = 'Running in background';
+ if( wfIsWindows() ) {
+ //We need to run in background, so no $sResult = wfShellExec(
$sCmd );
+ //https://stackoverflow.com/a/40243588
+ pclose( popen( "start /B ". $sCmd, "r" ) );
+ }
+ else {
+ $aOutput = array();
+ exec( $sCmd, $aOutput );
+ $sActualResult = implode( "\n", $aOutput );
+ if( !empty( $sActualResult ) ) {
+ $sResult = $sActualResult;
+ }
+ }
+
+ wfDebugLog(
+ 'ExtendedSearch',
+ __FUNCTION__ . ": Running 'searchUpdate.php' for '$sPath'.
Result:\n $sResult"
+ );
+
+ return true;
+}
--
To view, visit https://gerrit.wikimedia.org/r/367854
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I174dec162bf8c9605ebfbd4da3f71e7f946d6d91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits