Skip to content

Commit

Permalink
Fix some potential null-parameter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeinrich committed Apr 13, 2022
1 parent 6be9d25 commit cdde823
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions phpthumb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class phpthumb {
public $issafemode = null;
public $php_memory_limit = null;

public $phpthumb_version = '1.7.18-202201121135';
public $phpthumb_version = '1.7.18-202204131313';

//////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1405,10 +1405,12 @@ public function file_exists_ignoreopenbasedir($filename, $cached=true) {
static $open_basedirs = null;
static $file_exists_cache = array();
if (!$cached || !isset($file_exists_cache[$filename])) {
if (null === $open_basedirs) {
if (is_null($open_basedirs)) {
$open_basedirs = preg_split('#[;:]#', ini_get('open_basedir'));
}
if (empty($open_basedirs) || in_array(dirname($filename), $open_basedirs)) {
if (is_null($filename)) { // shouldn't happen, but https://github.com/JamesHeinrich/phpThumb/issues/188
$file_exists_cache[$filename] = false;
} elseif (empty($open_basedirs) || in_array(dirname($filename), $open_basedirs)) {
$file_exists_cache[$filename] = file_exists($filename);
} elseif ($this->iswindows) {
$ls_filename = trim(phpthumb_functions::SafeExec('dir /b '.phpthumb_functions::escapeshellarg_replacement($filename)));
Expand Down Expand Up @@ -1474,7 +1476,10 @@ public function ImageMagickCommandlineBase() {

$this->DebugMessage('using ImageMagick path from $this->config_imagemagick_path ('.$this->config_imagemagick_path.')', __FILE__, __LINE__);
if ($this->iswindows) {
$commandline = substr($this->config_imagemagick_path, 0, 2).' && cd '.phpthumb_functions::escapeshellarg_replacement(str_replace('/', DIRECTORY_SEPARATOR, substr(dirname($this->config_imagemagick_path), 2))).' && '.phpthumb_functions::escapeshellarg_replacement(basename($this->config_imagemagick_path));
$commandline = '';
$commandline .= substr($this->config_imagemagick_path, 0, 2);
$commandline .= ' && cd '.phpthumb_functions::escapeshellarg_replacement(str_replace('/', DIRECTORY_SEPARATOR, substr(dirname($this->config_imagemagick_path), 2)));
$commandline .= ' && '.phpthumb_functions::escapeshellarg_replacement(basename($this->config_imagemagick_path));
} else {
$commandline = phpthumb_functions::escapeshellarg_replacement($this->config_imagemagick_path);
}
Expand Down Expand Up @@ -1588,7 +1593,7 @@ public function ImageMagickFormatsList() {
if (null === $IMformatsList) {
$IMformatsList = '';
$commandline = $this->ImageMagickCommandlineBase();
if (null !== $commandline) {
if (!is_null($commandline)) {
$commandline = dirname($commandline).DIRECTORY_SEPARATOR.str_replace('convert', 'identify', basename($commandline));
$commandline .= ' -list format';
$IMformatsList = phpthumb_functions::SafeExec($commandline);
Expand Down Expand Up @@ -3513,7 +3518,7 @@ public function ExtractEXIFgetImageSize() {

}

$this->DebugMessage('EXIF thumbnail extraction: (size='.strlen($this->exif_thumbnail_data).'; type="'.$this->exif_thumbnail_type.'"; '. (int) $this->exif_thumbnail_width .'x'. (int) $this->exif_thumbnail_height .')', __FILE__, __LINE__);
$this->DebugMessage('EXIF thumbnail extraction: (size='.(!empty($this->exif_thumbnail_data) ? strlen($this->exif_thumbnail_data) : 0).'; type="'.$this->exif_thumbnail_type.'"; '. (int) $this->exif_thumbnail_width .'x'. (int) $this->exif_thumbnail_height .')', __FILE__, __LINE__);

// see if EXIF thumbnail can be used directly with no processing
if ($this->config_use_exif_thumbnail_for_speed && $this->exif_thumbnail_data) {
Expand Down

0 comments on commit cdde823

Please sign in to comment.