From 0cc768dd158cc08054cc025605abbdea4da4652e Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Fri, 11 Jan 2008 11:22:45 +0000 Subject: [PATCH] KTS-2811 "KnowledgeTree Indexer plugin not indexing in 3.4.5 on a windows machine" Fixed. Replaced the exec function on the word indexer with popen. --- plugins/ktstandard/contents/BaseIndexer.php | 1 + plugins/ktstandard/contents/OpenDocumentIndexer.php | 16 +++++++++++++--- plugins/ktstandard/contents/WordIndexer.php | 31 +++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/plugins/ktstandard/contents/BaseIndexer.php b/plugins/ktstandard/contents/BaseIndexer.php index 194fa18..13a97f7 100644 --- a/plugins/ktstandard/contents/BaseIndexer.php +++ b/plugins/ktstandard/contents/BaseIndexer.php @@ -147,6 +147,7 @@ class KTBaseIndexerTrigger { $cmdline[] = $sFilename; $aOptions = array(); + $aOptions['exec_wait'] = 'true'; if ($this->use_pipes) { $aOptions["append"] = $sTempFilename; } else { diff --git a/plugins/ktstandard/contents/OpenDocumentIndexer.php b/plugins/ktstandard/contents/OpenDocumentIndexer.php index 157bae6..86a70dc 100644 --- a/plugins/ktstandard/contents/OpenDocumentIndexer.php +++ b/plugins/ktstandard/contents/OpenDocumentIndexer.php @@ -118,7 +118,10 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { if (empty($sUnzipCommand)) { return; } - $this->sTmpPath = tempnam('/tmp', 'opendocumentextract'); + $oKTConfig =& KTConfig::getSingleton(); + $sBasedir = $oKTConfig->get("urls/tmpDirectory"); + + $this->sTmpPath = tempnam($sBasedir, 'opendocumentextract'); if ($this->sTmpPath === false) { return; } @@ -131,14 +134,20 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { "-d", $this->sTmpPath, $sFilename, ); - KTUtil::pexec($sCmd); + KTUtil::pexec($sCmd, array('exec_wait' => 'true')); $sManifest = sprintf("%s/%s", $this->sTmpPath, "META-INF/manifest.xml"); + if (OS_WINDOWS) { + $sManifest = str_replace( '/','\\',$sManifest); + } if (!file_exists($sManifest)) { $this->cleanup(); return; } $sContentFile = sprintf("%s/%s", $this->sTmpPath, "content.xml"); + if (OS_WINDOWS) { + $sContentFile = str_replace( '/','\\',$sContentFile ); + } if (!file_exists($sContentFile)) { $this->cleanup(); return; @@ -152,7 +161,8 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { } function cleanup() { - KTUtil::deleteDirectory($this->sTmpPath); + return; + //KTUtil::deleteDirectory($this->sTmpPath); } } diff --git a/plugins/ktstandard/contents/WordIndexer.php b/plugins/ktstandard/contents/WordIndexer.php index a4caaa1..0d7662d 100644 --- a/plugins/ktstandard/contents/WordIndexer.php +++ b/plugins/ktstandard/contents/WordIndexer.php @@ -51,12 +51,35 @@ class KTWordIndexerTrigger extends KTBaseIndexerTrigger { $this->command = 'c:\antiword\antiword.exe'; $this->commandconfig = 'indexer/antiword'; $this->args = array(); + } + putenv('LANG=en_US.UTF-8'); + + $sCommand = KTUtil::findCommand($this->commandconfig, $this->command); + if (empty($sCommand)) { + return false; + } + + if (OS_WINDOWS) { + $sDir = dirname(dirname($sCommand)); + putenv('HOME=' . $sDir); - $sCommand = KTUtil::findCommand($this->commandconfig, $this->command); - $sDir = dirname(dirname($sCommand)); - putenv('HOME=' . $sDir); + $cmdline = array($sCommand); + $cmdline = kt_array_merge($cmdline, $this->args); + $cmdline[] = $sFilename; + + $sCmd = KTUtil::safeShellString($cmdline); + $sCmd .= " >> " . escapeshellarg($sTempFilename); + + $sCmd = str_replace( '/','\\',$sCmd); + + $sCmd = "start /b \"kt\" " . $sCmd; + + pclose(popen($sCmd, 'r')); + + $this->aCommandOutput = 1; + $contents = file_get_contents($sTempFilename); + return $contents; } - putenv('LANG=en_US.UTF-8'); return parent::extract_contents($sFilename, $sTempFilename); } -- libgit2 0.21.4