From 68c609c2640292d5e4f6a700c46bb4044f9da75f Mon Sep 17 00:00:00 2001 From: Paul Barrett Date: Mon, 23 Nov 2009 16:04:16 +0200 Subject: [PATCH] Attempted fix of issue with imagemagick path not set correctly on a migration/upgrade from 3.6.1 - setting did not exist and so could not be updated, setup wizard should now create if not present --- plugins/thumbnails/thumbnailsPlugin.php | 9 +++++++++ setup/wizard/steps/database.php | 26 +++++++++++++++++++++++--- sql/mysql/upgrade/3.7.0-1/config_settings.sql | 5 +---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/plugins/thumbnails/thumbnailsPlugin.php b/plugins/thumbnails/thumbnailsPlugin.php index 86d6351..2d32844 100755 --- a/plugins/thumbnails/thumbnailsPlugin.php +++ b/plugins/thumbnails/thumbnailsPlugin.php @@ -49,6 +49,15 @@ class thumbnailsPlugin extends KTPlugin { require_once(KT_LIB_DIR . '/templating/templating.inc.php'); $oTemplating =& KTTemplating::getSingleton(); $oTemplating->addLocation('thumbnails', $plugin_dir.'templates', 'thumbnails.generator.processor.plugin'); + + // check for existing config settings entry and only add if not already present + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"'; + $result = DBUtil::getOneResult($sql); + if(PEAR::isError($result) || empty($result)) { + DBUtil::runQuery('INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) ' + . 'VALUES ("externalBinary", "convert", "The path to the ImageMagick \"convert\" binary", "convertPath", "default", "convert", ' + . '"string", NULL, 1);'); + } } } diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 7e02f52..0acd43e 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -810,14 +810,34 @@ class database extends Step // continue without attempting to set the path if we can't find the file in the specified location if (!file_exists($bin[1])) continue; + // escape paths for insert/update query + $bin[1] = str_replace('\\', '\\\\', $bin[1]); + // instaView won't exist, must be inserted instead of updated - if ($displayName == 'pdf2swf') { + // TODO this may need to be modified to first check for existing setting as with the convert step below; not necessary for 3.7.0.x + if ($displayName == 'pdf2swf') { $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) ' . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the SWFTools \"pdf2swf\" binary", "pdf2swfPath", ' - . '"' . str_replace('\\', '\\\\', $bin[1]) . '", "pdf2swf", "string", NULL, 1);'; + . '"' . $bin[1] . '", "pdf2swf", "string", NULL, 1);'; + } + // on a migration, the convert setting will not exist, so do something similar to the above, but first check whether it exists + else if ($displayName == 'convert') { + // check for existing config settings entry and only add if not already present + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"'; + $result = $this->util->dbUtilities->query($sql); + $output = $this->util->dbUtilities->fetchAssoc($result); + if(is_null($output)) { + $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) ' + . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the ImageMagick \"convert\" binary", "convertPath", ' + . '"' . $bin[1] . '", "convert", "string", NULL, 1)'; + } + else { + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" ' + . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";'; + } } else { - $updateBin = 'UPDATE config_settings c SET c.value = "'. str_replace('\\', '\\\\', $bin[1]) . '" ' + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" ' . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";'; } diff --git a/sql/mysql/upgrade/3.7.0-1/config_settings.sql b/sql/mysql/upgrade/3.7.0-1/config_settings.sql index 0bba239..2f92edb 100644 --- a/sql/mysql/upgrade/3.7.0-1/config_settings.sql +++ b/sql/mysql/upgrade/3.7.0-1/config_settings.sql @@ -1,5 +1,2 @@ INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) -VALUES ('urls', 'Internal Var Directory', 'The path to the internal var directory that must sit within the web root', 'internalVarDirectory', 'default', '${fileSystemRoot}/var', 'string', NULL, 0); - -INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) -VALUES ('externalBinary', 'convert', 'The path to the ImageMagick "convert" binary', 'convertPath', 'default', 'convert', 'string', NULL, 1); \ No newline at end of file +VALUES ('urls', 'Internal Var Directory', 'The path to the internal var directory that must sit within the web root', 'internalVarDirectory', 'default', '${fileSystemRoot}/var', 'string', NULL, 0); \ No newline at end of file -- libgit2 0.21.4