Skip to content

Commit

Permalink
Prioritize using the value in graphics_toolkit_path over the standard
Browse files Browse the repository at this point in the history
path so that if you change that value in Admin > Settings > Advanced
we prefer it over other paths (which may be restricted by
open_basedir).  Fixes #1395.
  • Loading branch information
bharat committed Sep 23, 2010
1 parent 3b84759 commit 790bf4e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
13 changes: 13 additions & 0 deletions modules/gallery/helpers/gallery.php
Expand Up @@ -140,4 +140,17 @@ static function find_file($directory, $file, $required=false) {
return $file_name;
}

/**
* Set the PATH environment variable to the paths specified.
* @param array Array of paths. Each array entry can contain a colon separated list of paths.
*/
static function set_path_env($paths) {
$path_env = array();
foreach ($paths as $path) {
if ($path) {
array_push($path_env, $path);
}
}
putenv("PATH=" . implode(":", $path_env));
}
}
9 changes: 4 additions & 5 deletions modules/gallery/helpers/graphics.php
Expand Up @@ -313,11 +313,10 @@ static function detect_toolkits() {
$toolkits->graphicsmagick->installed = false;
$toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
} else {
$graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
$extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);

putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
":" . $extra_binary_paths);
gallery::set_path_env(
array(module::get_var("gallery", "graphics_toolkit_path"),
getenv("PATH"),
module::get_var("gallery", "extra_binary_paths")));

// @todo: consider refactoring the two segments below into a loop since they are so
// similar.
Expand Down
9 changes: 4 additions & 5 deletions modules/gallery/helpers/movie.php
Expand Up @@ -85,11 +85,10 @@ static function extract_frame($input_file, $output_file) {

static function find_ffmpeg() {
if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
$graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
$extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);

putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
":" . $extra_binary_paths);
gallery::set_path_env(
array(module::get_var("gallery", "graphics_toolkit_path"),
getenv("PATH"),
module::get_var("gallery", "extra_binary_paths")));
if (function_exists("exec")) {
$ffmpeg_path = exec("which ffmpeg");
}
Expand Down

0 comments on commit 790bf4e

Please sign in to comment.