Commit 68c609c2640292d5e4f6a700c46bb4044f9da75f

Authored by Paul Barrett
1 parent eca90f03

Attempted fix of issue with imagemagick path not set correctly on a migration/up…

…grade from 3.6.1 - setting did not exist and so could not be updated, setup wizard should now create if not present

KTS-4526. Upgrade: Imagemagick path is not set correctly, user cannot view thumbnails.

Fixed

Committed by: Paul Barrett

Reviewed by: Megan Watson
plugins/thumbnails/thumbnailsPlugin.php
... ... @@ -49,6 +49,15 @@ class thumbnailsPlugin extends KTPlugin {
49 49 require_once(KT_LIB_DIR . '/templating/templating.inc.php');
50 50 $oTemplating =& KTTemplating::getSingleton();
51 51 $oTemplating->addLocation('thumbnails', $plugin_dir.'templates', 'thumbnails.generator.processor.plugin');
  52 +
  53 + // check for existing config settings entry and only add if not already present
  54 + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"';
  55 + $result = DBUtil::getOneResult($sql);
  56 + if(PEAR::isError($result) || empty($result)) {
  57 + DBUtil::runQuery('INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
  58 + . 'VALUES ("externalBinary", "convert", "The path to the ImageMagick \"convert\" binary", "convertPath", "default", "convert", '
  59 + . '"string", NULL, 1);');
  60 + }
52 61 }
53 62 }
54 63  
... ...
setup/wizard/steps/database.php
... ... @@ -810,14 +810,34 @@ class database extends Step
810 810 // continue without attempting to set the path if we can't find the file in the specified location
811 811 if (!file_exists($bin[1])) continue;
812 812  
  813 + // escape paths for insert/update query
  814 + $bin[1] = str_replace('\\', '\\\\', $bin[1]);
  815 +
813 816 // instaView won't exist, must be inserted instead of updated
814   - if ($displayName == 'pdf2swf') {
  817 + // 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
  818 + if ($displayName == 'pdf2swf') {
815 819 $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
816 820 . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the SWFTools \"pdf2swf\" binary", "pdf2swfPath", '
817   - . '"' . str_replace('\\', '\\\\', $bin[1]) . '", "pdf2swf", "string", NULL, 1);';
  821 + . '"' . $bin[1] . '", "pdf2swf", "string", NULL, 1);';
  822 + }
  823 + // on a migration, the convert setting will not exist, so do something similar to the above, but first check whether it exists
  824 + else if ($displayName == 'convert') {
  825 + // check for existing config settings entry and only add if not already present
  826 + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"';
  827 + $result = $this->util->dbUtilities->query($sql);
  828 + $output = $this->util->dbUtilities->fetchAssoc($result);
  829 + if(is_null($output)) {
  830 + $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
  831 + . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the ImageMagick \"convert\" binary", "convertPath", '
  832 + . '"' . $bin[1] . '", "convert", "string", NULL, 1)';
  833 + }
  834 + else {
  835 + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" '
  836 + . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";';
  837 + }
818 838 }
819 839 else {
820   - $updateBin = 'UPDATE config_settings c SET c.value = "'. str_replace('\\', '\\\\', $bin[1]) . '" '
  840 + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" '
821 841 . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";';
822 842 }
823 843  
... ...
sql/mysql/upgrade/3.7.0-1/config_settings.sql
1 1 INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit)
2   -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);
3   -
4   -INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit)
5   -VALUES ('externalBinary', 'convert', 'The path to the ImageMagick "convert" binary', 'convertPath', 'default', 'convert', 'string', NULL, 1);
6 2 \ No newline at end of file
  3 +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);
7 4 \ No newline at end of file
... ...