JamesHeinrich / phpThumb

phpThumb() - The PHP thumbnail generator
Other
315 stars 141 forks source link

PHP 8.1 error ~ passing null #205

Open badbadmonkey opened 1 year ago

badbadmonkey commented 1 year ago

PHP Version 8.1.13 warning ~

[] PHP Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /.../phpthumb/phpthumb.class.php on line 1990

badbadmonkey commented 1 year ago

Also (when debugging enabled)

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /.../phpthumb/phpthumb.class.php on line 1803

JamesHeinrich commented 1 year ago

Can you please confirm the line numbers against the current master version: https://github.com/JamesHeinrich/phpThumb/blob/master/phpthumb.class.php

badbadmonkey commented 1 year ago

Yes they're correct

1803 > $IMuseExplicitImageOutputDimensions = preg_match('#image dimensions are zero#i', $IMresult_test);
1990 > $nh = ((round($nh) != 0) ? round($nh) : '');
badbadmonkey commented 1 year ago

More testing, have realized this error(s) occurs randomly and isn't related to debugging.

It nevertheless generates the image, I have a script to retry after 1 s and it always works perfectly the second call.

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /phpthumb/phpthumb.class.php on line 1803

Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /phpthumb/phpthumb.class.php on line 1990

**Headers already sent in file "/phpthumb/phpthumb.class.php" on line "1803", dumping error message as text:**
JamesHeinrich commented 1 year ago

If you have any insight as to what/where/how the null is being passed it would be helpful.

badbadmonkey commented 1 year ago

What I can discern is it seems to be connected to to generation of a debug msg, but not a successful image output. I just put phpThumb in debug mode and ran my test script, and now I get these PHP errors at the start of every debug output, even though most would be successful. So when not in debug mode I guess they are a secondary symptom of some other error.

Here is debug output of otherwise successful runs -

Fetching images in https://www.dom.com/
Loading /include/phpthumb/phpThumb.php?src=%2Fimages%2Fabout-peter-bg.150421.jpg&q=75&w=588&hash=fe585ae60e5aa9ea401d3af39ac8de4831a1fa6d4c9d9d5b61de9ec7de12a321...
The server responded with HTTP code 200 and I have fetched 28062 B in 0.632345 s of type text/html; charset=UTF-8.

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1803

Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1990

phpThumb() v1.7.19-202210110924
http://phpthumb.sourceforge.net

phpThumb() version          = 1.7.19-202210110924
phpversion()                = 8.1.13
PHP_OS                      = Linux
$_SERVER[SERVER_SOFTWARE]   = Apache
__FILE__                    = /home2/user/public_html/include/phpthumb/phpthumb.class.php
realpath(.)                 = /home2/user/public_html/include/phpthumb
$_SERVER[PHP_SELF]          = /include/phpthumb/phpThumb.php
$_SERVER[HOST_NAME]         = 
$_SERVER[HTTP_REFERER]      = 
$_SERVER[QUERY_STRING]      = src=%2Fimages%2Fabout-peter-bg.150421.jpg&q=75&w=588&hash=fe585ae60e5aa9ea401d3af39ac8de4831a1fa6d4c9d9d5b61de9ec7de12a321
$_SERVER[PATH_INFO]         = 
$_SERVER[DOCUMENT_ROOT]     = /home2/user/public_html
getenv(DOCUMENT_ROOT)       = /home2/user/public_html

get_magic_quotes_gpc()         = 
get_magic_quotes_runtime()     = 
error_reporting()              = integer     32767
ini_get(error_reporting)       = string(5)   "32767"
ini_get(display_errors)        = string(1)   "1"
ini_get(allow_url_fopen)       = string(1)   "1"
ini_get(disable_functions)     = string(0)   ""
get_cfg_var(disable_functions) = string(0)   ""
ini_get(safe_mode)             = FALSE
ini_get(open_basedir)          = string(0)   ""
ini_get(max_execution_time)    = string(2)   "60"
ini_get(memory_limit)          = string(5)   "2048M"
get_cfg_var(memory_limit)      = string(4)   "512M"
memory_get_usage()             = integer     935000

$this->config_prefer_imagemagick            = TRUE
$this->config_imagemagick_path              = NULL
$this->ImageMagickWhichConvert()            = /usr/bin/convert
[actual ImageMagick path used]              = string(16)  "/usr/bin/convert"
file_exists([actual ImageMagick path used]) = TRUE
ImageMagickVersion(false)                   = 6.7.6-8 2016-07-19 Q16
ImageMagickVersion(true)                    = Version: ImageMagick 6.7.6-8 2016-07-19 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

$this->config_cache_directory               = string(49)  "/home2/user/public_html/include/phpthumb/cache/"
$this->config_cache_directory_depth         = integer     2
$this->config_cache_disable_warning         = FALSE
$this->config_cache_maxage                  = integer     15552000
$this->config_cache_maxsize                 = integer     4294967296
$this->config_cache_maxfiles                = integer     100000
$this->config_cache_force_passthru          = TRUE
$this->cache_filename                       = string(179) "/home2/user/public_html/include/phpthumb/cache//b/ba/phpThumb_cache_dom.com__srcbaca5e34a846501df00519e35e865afa_parf89e8c400b028fc727d1db563dd9de2c_dat1429587796.jpeg"
is_readable($this->config_cache_directory)  = TRUE
is_writable($this->config_cache_directory)  = TRUE
is_readable($this->cache_filename)          = TRUE
is_writable($this->cache_filename)          = TRUE

$this->config_document_root                  = string(25)  "/home2/user/public_html"
$this->config_temp_directory                 = string(49)  "/home2/user/public_html/include/phpthumb/cache/"
$this->config_output_format                  = string(4)   "jpeg"
$this->config_output_maxwidth                = integer     0
$this->config_output_maxheight               = integer     0
$this->config_error_message_image_default    = string(0)   ""
$this->config_error_bgcolor                  = string(6)   "CCCCFF"
$this->config_error_textcolor                = string(6)   "FF0000"
$this->config_error_fontsize                 = integer     3
$this->config_error_die_on_error             = TRUE
$this->config_error_silent_die_on_error      = FALSE
$this->config_error_die_on_source_failure    = TRUE
$this->config_nohotlink_enabled              = TRUE
$this->config_nohotlink_valid_domains        = array(1) {   [0]=>   string(21) "www.dom.com" } 
$this->config_nohotlink_erase_image          = TRUE
$this->config_nohotlink_text_message         = string(38)  "Off-server thumbnailing is not allowed"
$this->config_nooffsitelink_enabled          = TRUE
$this->config_nooffsitelink_valid_domains    = array(1) {   [0]=>   string(21) "www.dom.com" } 
$this->config_nooffsitelink_require_refer    = FALSE
$this->config_nooffsitelink_erase_image      = FALSE
$this->config_nooffsitelink_text_message     = string(38)  "Image taken from www.dom.com"
$this->config_high_security_enabled          = TRUE
$this->config_allow_src_above_docroot        = FALSE
$this->config_allow_src_above_phpthumb       = TRUE
$this->config_max_source_pixels              = float       357913941
$this->config_use_exif_thumbnail_for_speed   = FALSE
$this->config_border_hexcolor                = string(6)   "000000"
$this->config_background_hexcolor            = string(6)   "FFFFFF"
$this->config_ttf_directory                  = string(48)  "/home2/user/public_html/include/phpthumb/fonts"
$this->config_disable_pathinfo_parsing       = TRUE
$this->config_disable_imagecopyresampled     = FALSE

$this->phpThumbDebug               = integer     9
$this->thumbnailQuality            = integer     75
$this->thumbnailFormat             = string(4)   "jpeg"
$this->gdimg_output                = NULL
$this->gdimg_source                = object
$this->sourceFilename              = string(58)  "/home2/user/public_html/images/about-peter-bg.150421.jpg"
$this->source_width                = integer     588
$this->source_height               = integer     176
$this->thumbnailCropX              = NULL
$this->thumbnailCropY              = NULL
$this->thumbnailCropW              = NULL
$this->thumbnailCropH              = NULL
$this->exif_thumbnail_width        = NULL
$this->exif_thumbnail_height       = NULL
$this->exif_thumbnail_type         = NULL
$this->thumbnail_width             = NULL
$this->thumbnail_height            = NULL
$this->thumbnail_image_width       = NULL
$this->thumbnail_image_height      = NULL
strlen($this->rawImageData)        = 
strlen($this->exif_thumbnail_data) = 

$this->src  = string(58)  "/home2/user/public_html/images/about-peter-bg.150421.jpg"
$this->new  = NULL
$this->w    = string(3)   "588"
$this->h    = NULL
$this->f    = string(0)   ""
$this->q    = string(2)   "75"
$this->sx   = NULL
$this->sy   = NULL
$this->sw   = NULL
$this->sh   = NULL
$this->far  = NULL
$this->bg   = NULL
$this->bc   = NULL
$this->zc   = NULL
$this->ica  = NULL
$this->file = NULL
$this->goto = NULL
$this->err  = NULL
$this->xto  = NULL
$this->ra   = NULL
$this->ar   = NULL
$this->aoe  = integer     1
$this->iar  = NULL
$this->maxb = NULL

builtin_function_exists(exif_thumbnail)          = TRUE
builtin_function_exists(gd_info)                 = TRUE
builtin_function_exists(image_type_to_mime_type) = TRUE
builtin_function_exists(getimagesize)            = TRUE
builtin_function_exists(imagecopyresampled)      = TRUE
builtin_function_exists(imagecopyresized)        = TRUE
builtin_function_exists(imagecreate)             = TRUE
builtin_function_exists(imagecreatefromstring)   = TRUE
builtin_function_exists(imagecreatetruecolor)    = TRUE
builtin_function_exists(imageistruecolor)        = TRUE
builtin_function_exists(imagerotate)             = TRUE
builtin_function_exists(imagetypes)              = TRUE
builtin_function_exists(version_compare)         = TRUE
builtin_function_exists(imagecreatefromgif)      = TRUE
builtin_function_exists(imagecreatefromjpeg)     = TRUE
builtin_function_exists(imagecreatefrompng)      = TRUE
builtin_function_exists(imagecreatefromwbmp)     = TRUE
builtin_function_exists(imagecreatefromxbm)      = TRUE
builtin_function_exists(imagecreatefromxpm)      = TRUE
builtin_function_exists(imagecreatefromstring)   = TRUE
builtin_function_exists(imagecreatefromgd)       = TRUE
builtin_function_exists(imagecreatefromgd2)      = TRUE
builtin_function_exists(imagecreatefromgd2part)  = TRUE
builtin_function_exists(imagejpeg)               = TRUE
builtin_function_exists(imagegif)                = TRUE
builtin_function_exists(imagepng)                = TRUE
builtin_function_exists(imagewbmp)               = TRUE

gd_info.GD Version                         = string(26)  "bundled (2.1.0 compatible)"
gd_info.FreeType Support                   = TRUE
gd_info.FreeType Linkage                   = string(13)  "with freetype"
gd_info.GIF Read Support                   = TRUE
gd_info.GIF Create Support                 = TRUE
gd_info.JPEG Support                       = TRUE
gd_info.PNG Support                        = TRUE
gd_info.WBMP Support                       = TRUE
gd_info.XPM Support                        = TRUE
gd_info.XBM Support                        = TRUE
gd_info.WebP Support                       = TRUE
gd_info.BMP Support                        = TRUE
gd_info.AVIF Support                       = FALSE
gd_info.TGA Read Support                   = TRUE
gd_info.JIS-mapped Japanese Font Support   = FALSE

exif_info.EXIF Support               = string(7)   "enabled"
exif_info.EXIF Version               = string(0)   ""
exif_info.Supported EXIF Version     = string(4)   "0220"
exif_info.Supported filetypes        = string(10)  "JPEG, TIFF"

ApacheLookupURIarray() -- FAILED

$_GET[src]                           = string(33)  "/images/about-peter-bg.150421.jpg"
$_GET[q]                             = string(2)   "75"
$_GET[w]                             = string(3)   "588"
$_GET[hash]                          = string(64)  "fe585ae60e5aa9ea401d3af39ac8de4831a1fa6d4c9d9d5b61de9ec7de12a321"
$_GET[phpThumbDebug]                 = integer     9

$this->debugmessages:
  * phpThumb() v1.7.19-202210110924 in file "phpthumb.class.php" on line 279
  * setParameter(config_document_root, string(25)  "/home2/user/public_html") in file "phpThumb.php" on line 160
  * setParameter(config_disable_debug, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_high_security_enabled, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_high_security_url_separator, string(1)   "&") in file "phpThumb.php" on line 160
  * setParameter(config_allow_src_above_docroot, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_allow_src_above_phpthumb, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_auto_allow_symlinks, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_additional_allowed_dirs, array(0) { } ) in file "phpThumb.php" on line 160
  * setParameter(config_cache_directory, string(49)  "/home2/user/public_html/include/phpthumb/cache/") in file "phpThumb.php" on line 160
  * setParameter(config_cache_disable_warning, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_cache_directory_depth, integer     2) in file "phpThumb.php" on line 160
  * setParameter(config_cache_maxage, integer     15552000) in file "phpThumb.php" on line 160
  * setParameter(config_cache_maxsize, integer     4294967296) in file "phpThumb.php" on line 160
  * setParameter(config_cache_maxfiles, integer     100000) in file "phpThumb.php" on line 160
  * setParameter(config_cache_source_enabled, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_cache_source_directory, string(56)  "/home2/user/public_html/include/phpthumb/cache/source/") in file "phpThumb.php" on line 160
  * setParameter(config_cache_source_filemtime_ignore_local, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_cache_source_filemtime_ignore_remote, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_cache_default_only_suffix, string(0)   "") in file "phpThumb.php" on line 160
  * setParameter(config_cache_prefix, string(33)  "phpThumb_cache_dom.com_") in file "phpThumb.php" on line 160
  * setParameter(config_cache_force_passthru, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_temp_directory, string(49)  "/home2/user/public_html/include/phpthumb/cache/") in file "phpThumb.php" on line 160
  * setParameter(config_prefer_imagemagick, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_imagemagick_use_thumbnail, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_imagemagick_path, NULL) in file "phpThumb.php" on line 160
  * setParameter(config_max_source_pixels, float       357913941) in file "phpThumb.php" on line 160
  * setParameter(config_output_format, string(4)   "jpeg") in file "phpThumb.php" on line 160
  * setParameter(config_output_maxwidth, integer     0) in file "phpThumb.php" on line 160
  * setParameter(config_output_maxheight, integer     0) in file "phpThumb.php" on line 160
  * setParameter(config_output_interlace, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_error_image_width, integer     600) in file "phpThumb.php" on line 160
  * setParameter(config_error_image_height, integer     150) in file "phpThumb.php" on line 160
  * setParameter(config_error_message_image_default, string(0)   "") in file "phpThumb.php" on line 160
  * setParameter(config_error_bgcolor, string(6)   "CCCCFF") in file "phpThumb.php" on line 160
  * setParameter(config_error_textcolor, string(6)   "FF0000") in file "phpThumb.php" on line 160
  * setParameter(config_error_fontsize, integer     3) in file "phpThumb.php" on line 160
  * setParameter(config_error_die_on_error, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_error_silent_die_on_error, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_error_die_on_source_failure, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_nohotlink_enabled, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_nohotlink_valid_domains, array(1) {   [0]=>   string(21) "www.dom.com" } ) in file "phpThumb.php" on line 160
  * setParameter(config_nohotlink_erase_image, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_nohotlink_text_message, string(38)  "Off-server thumbnailing is not allowed") in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_enabled, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_valid_domains, array(1) {   [0]=>   string(21) "www.dom.com" } ) in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_require_refer, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_erase_image, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_watermark_src, string(26)  "/demo/images/watermark.png") in file "phpThumb.php" on line 160
  * setParameter(config_nooffsitelink_text_message, string(38)  "Image taken from www.dom.com") in file "phpThumb.php" on line 160
  * setParameter(config_border_hexcolor, string(6)   "000000") in file "phpThumb.php" on line 160
  * setParameter(config_background_hexcolor, string(6)   "FFFFFF") in file "phpThumb.php" on line 160
  * setParameter(config_ttf_directory, string(48)  "/home2/user/public_html/include/phpthumb/fonts") in file "phpThumb.php" on line 160
  * setParameter(config_http_user_agent, string(92)  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12") in file "phpThumb.php" on line 160
  * setParameter(config_disable_pathinfo_parsing, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_disable_imagecopyresampled, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_disable_onlycreateable_passthru, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_disable_realpath, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_http_fopen_timeout, integer     10) in file "phpThumb.php" on line 160
  * setParameter(config_http_follow_redirect, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_allow_local_http_src, FALSE) in file "phpThumb.php" on line 160
  * setParameter(config_use_exif_thumbnail_for_speed, FALSE) in file "phpThumb.php" on line 160
  * setParameter(src, string(33)  "/images/about-peter-bg.150421.jpg") in file "phpThumb.php" on line 395
  * ResolveFilenameToAbsolute() prepending $this->config_document_root (/home2/user/public_html) to $filename (/images/about-peter-bg.150421.jpg) resulting in ($AbsoluteFilename = "/home2/user/public_html/images/about-peter-bg.150421.jpg") in file "phpthumb.class.php" on line 1409
  * resolvePath: /home2/user/public_html/images/about-peter-bg.150421.jpg (allowed_dirs: Array
(
)
) in file "phpthumb.class.php" on line 1240
  * resolvePath: iteration, path=/home2/user/public_html/images/about-peter-bg.150421.jpg, base path = /home2/user/public_html in file "phpthumb.class.php" on line 1259
  * open_basedir: "" in file "phpthumb.class.php" on line 1226
  * resolvePath: stop at component 6 in file "phpthumb.class.php" on line 1275
  * resolvePath: stop at path=/home2/user/public_html/images/about-peter-bg.150421.jpg in file "phpthumb.class.php" on line 1278
  * resolvePath: path parsed, over in file "phpthumb.class.php" on line 1284
  * setSourceFilename(/home2/user/public_html/images/about-peter-bg.150421.jpg) set $this->sourceFilename to "/home2/user/public_html/images/about-peter-bg.150421.jpg" in file "phpthumb.class.php" on line 344
  * setParameter(q, string(2)   "75") in file "phpThumb.php" on line 395
  * setParameter(w, string(3)   "588") in file "phpThumb.php" on line 395
  * setParameter(hash, string(64)  "fe585ae60e5aa9ea401d3af39ac8de4831a1fa6d4c9d9d5b61de9ec7de12a321") in file "phpThumb.php" on line 395
  * setParameter(phpThumbDebug, integer     9) in file "phpThumb.php" on line 395
  * $CanPassThroughDirectly=false because $_GET[q;hash] are set in file "phpThumb.php" on line 478
  * $CanPassThroughDirectly="0" && $phpThumb->src="/home2/user/public_html/images/about-peter-bg.150421.jpg" in file "phpThumb.php" on line 489
  * Addding ImageMagick formats to $AvailableImageOutputFormats (text;ico;bmp;wbmp;gif;webp;png;jpeg) in file "phpthumb.class.php" on line 1062
  * $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;webp;png;jpeg;avif) in file "phpthumb.class.php" on line 1068
  * $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 1080
  * $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 1097
  * SetCacheFilename() _src set from md5($this->sourceFilename) "/home2/user/public_html/images/about-peter-bg.150421.jpg" = "baca5e34a846501df00519e35e865afa" in file "phpthumb.class.php" on line 3693
  * SetCacheFilename() _par set from md5(_w588_aoe1_dpi150_q75) in file "phpthumb.class.php" on line 3732
  * Would have used cached file, but skipping due to phpThumbDebug in file "phpThumb.php" on line 70
  * * Would have sent headers (1): Last-Modified: Tue, 20 Dec 2022 20:11:58 GMT in file "phpThumb.php" on line 71
  * * Would have sent headers (2): Content-Type: image/jpeg in file "phpThumb.php" on line 73
  * * Would have sent headers (3): Location: /include/phpthumb/cache//b/ba/phpThumb_cache_dom.com__srcbaca5e34a846501df00519e35e865afa_parf89e8c400b028fc727d1db563dd9de2c_dat1429587796.jpeg in file "phpThumb.php" on line 76
  * resolvePath: /home2/user/public_html/images/about-peter-bg.150421.jpg (allowed_dirs: Array
(
)
) in file "phpthumb.class.php" on line 1240
  * resolvePath: iteration, path=/home2/user/public_html/images/about-peter-bg.150421.jpg, base path = /home2/user/public_html in file "phpthumb.class.php" on line 1259
  * resolvePath: stop at component 6 in file "phpthumb.class.php" on line 1275
  * resolvePath: stop at path=/home2/user/public_html/images/about-peter-bg.150421.jpg in file "phpthumb.class.php" on line 1278
  * resolvePath: path parsed, over in file "phpthumb.class.php" on line 1284
  * $this->sourceFilename set to "/home2/user/public_html/images/about-peter-bg.150421.jpg" in file "phpthumb.class.php" on line 985
  * $this->cache_filename already set, skipping SetCacheFilename() in file "phpthumb.class.php" on line 3649
  * starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 3486
  * getimagesize(/home2/user/public_html/images/about-peter-bg.150421.jpg) says image is 3160x944 in file "phpthumb.class.php" on line 3496
  * $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1719
  * phpThumb_tempnam() returning "/home2/user/public_html/include/phpthumb/cache/pThumb6gWmCP" in file "phpthumb.class.php" on line 4589
  * ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1645
  * IMuseExplicitImageOutputDimensions = 0 in file "phpthumb.class.php" on line 1804
  * getimagesize(/home2/user/public_html/images/about-peter-bg.150421.jpg) SUCCEEDED: Array
(
    [0] => 3160
    [1] => 944
    [2] => 2
    [3] => width="3160" height="944"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)
 in file "phpthumb.class.php" on line 1818
  * ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1645
  * getimagesize(/home2/user/public_html/images/about-peter-bg.150421.jpg) returned [w=3160;h=944;f=2] in file "phpthumb.class.php" on line 1833
  * source dimensions set to 3160x944 in file "phpthumb.class.php" on line 1836
  * SetOrientationDependantWidthHeight() starting with "3160"x"944" in file "phpthumb.class.php" on line 3465
  * SetOrientationDependantWidthHeight() setting w="588", h="0" in file "phpthumb.class.php" on line 3481
  * Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 2384
  * ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1642
  * ImageMagick called as (convert '/home2/user/public_html/images/about-peter-bg.150421.jpg[0]' -flatten -density '150' -background '#FFFFFF' -resize '588x' -quality '75' -interlace line  -sampling-factor 1x1 jpeg:'/home2/user/public_html/include/phpthumb/cache/pThumb6gWmCP' 2>&1) in file "phpthumb.class.php" on line 2410
  * getimagesize(/home2/user/public_html/include/phpthumb/cache/pThumb6gWmCP) returned [w=588;h=176;f=2] in file "phpthumb.class.php" on line 2427
  * ImageMagickThumbnailToGD::imagecreatefromjpeg() succeeded, $this->gdimg_source is now (588x176) in file "phpthumb.class.php" on line 2433
  * ImageMagickThumbnailToGD() returning $this->IMresizedData (15118 bytes) in file "phpthumb.class.php" on line 2434
  * deleting "/home2/user/public_html/include/phpthumb/cache/pThumb6gWmCP" in file "phpthumb.class.php" on line 2440
  * Skipping rest of GenerateThumbnail() because ($this->useRawIMoutput == true) in file "phpthumb.class.php" on line 419
  * CleanUpCacheDirectory() set to purge (180.0 days; 4,096.00 MB; 100,000 files) in file "phpthumb.class.php" on line 803
  * CleanUpCacheDirectory() skipped because "/home2/user/public_html/include/phpthumb/cache//phpThumbCacheStats.txt" is recently modified in file "phpthumb.class.php" on line 813
  * RenderOutput copying $this->IMresizedData (15118 bytes) to $this->outputImage in file "phpthumb.class.php" on line 508
  * RenderToFile(/home2/user/public_html/include/phpthumb/cache//b/ba/phpThumb_cache_dom.com__srcbaca5e34a846501df00519e35e865afa_parf89e8c400b028fc727d1db563dd9de2c_dat1429587796.jpeg) succeeded in file "phpthumb.class.php" on line 681
  * Would have used cached file, but skipping due to phpThumbDebug in file "phpThumb.php" on line 70
  * * Would have sent headers (1): Last-Modified: Tue, 20 Dec 2022 20:11:58 GMT in file "phpThumb.php" on line 71
  * * Would have sent headers (2): Content-Type: image/jpeg in file "phpThumb.php" on line 73
  * * Would have sent headers (3): Location: /include/phpthumb/cache//b/ba/phpThumb_cache_dom.com__srcbaca5e34a846501df00519e35e865afa_parf89e8c400b028fc727d1db563dd9de2c_dat1429587796.jpeg in file "phpThumb.php" on line 76

$this->debugtiming:
  * 1672885969.841731 : phpThumb() constructor in file "phpthumb.class.php" on line 278
  * 1672885969.841625 : phpThumb.php start in file "phpThumb.php" on line 127
  * 1672885969.842112 : phpThumbDebug[0] in file "phpThumb.php" on line 218
  * 1672885969.842145 : phpThumbDebug[1] in file "phpThumb.php" on line 278
  * 1672885969.842182 : phpThumbDebug[2] in file "phpThumb.php" on line 380
  * 1672885969.842294 : phpThumbDebug[3] in file "phpThumb.php" on line 416
  * 1672885969.842363 : phpThumbDebug[4] in file "phpThumb.php" on line 483
  * 1672885969.842368 : phpThumbDebug[5] in file "phpThumb.php" on line 577
  * 1672885969.842458 : skipped using cached image in file "phpThumb.php" on line 69
  * 1672885969.842516 : phpThumbDebug[6] in file "phpThumb.php" on line 593
  * 1672885969.842538 : phpThumbDebug[7] in file "phpThumb.php" on line 658
  * 1672885970.396113 : phpThumbDebug[8] in file "phpThumb.php" on line 668
  * 1672885970.396449 : skipped using cached image in file "phpThumb.php" on line 69
  * 1672885970.396494 : phpThumbDebug[9] in file "phpThumb.php" on line 701
  * Total processing time: 0.554869

Retrying after 1 s...
The server responded with HTTP code 200 and I have fetched 28062 B in 0.563865 s of type text/html; charset=UTF-8.

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1803

Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1990

phpThumb() v1.7.19-202210110924
http://phpthumb.sourceforge.net

phpThumb() version          = 1.7.19-202210110924
phpversion()                = 8.1.13
PHP_OS                      = Linux

... repeats identically ...
badbadmonkey commented 1 year ago

When debug is disabled, this is what happens. My test script is doing one phpThumb at a time with a short delay in between, so as to not overload server. If it gets something unexpected returned it waits 1 sec then retries.

All cached images always return ok. About 9/10 images needing thumbnailing process and return ok. About 1/10 fail with the below text return. Text because the PHP errors are conflicting with headers I suppose.

It would be very hard to get a full debug output because I do not know in advance which will generate the problem, and as you can see the next time the same thumbnail is requested, it always returns ok immediately, so by definition it's not repeatable.

Note the time measurements - nearly 4 secs before failing, 0.01 s to succeed, which suggests the image was processed and cached successfully the first time but for some reason did not get passed through.

Loading /include/phpthumb/phpThumb.php?src=%2Fphotos%2Fpatagonia%2F090221-07-pia.jpg&w=1668&f=jpg&q=72&hash=fd72269db355d2516c8b9c7a74ef188d8b6449e9a2161225006ddd4f81716a39...
The server responded with HTTP code 200 and I have fetched 786 B in 3.847452 s of type text/html; charset=UTF-8.

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1803

Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /home2/user/public_html/include/phpthumb/phpthumb.class.php on line 1990

**Headers already sent in file "/home2/user/public_html/include/phpthumb/phpthumb.class.php" on line "1803", dumping error message as text:**

phpThumb() v1.7.19-202210110924
http://phpthumb.sourceforge.net

Error messages disabled.

edit phpThumb.config.php and (temporarily) set
$PHPTHUMB_CONFIG['disable_debug'] = false;
to view the details of this error

Retrying after 1 s...
The server responded with HTTP code 200 and I have fetched 522833 B in 0.013025 s of type image/jpeg.

So this is some fundamental issue, but as above these PHP errors of the OP appear to be just connected with any and all debug output.

deni2s commented 1 year ago

https://github.com/JamesHeinrich/phpThumb/pull/208 should fix the issue in first comment.

@badbadmonkey what happens is that since 8.x compiler throws warnings about using values which are not set. Those are sent before headers are set, so image is generated, but not visible as text was sent before headers. On second request code uses cached image - so code with warnings is not executed.

Could be fixed by checking with isset() if variable was set and if not - then not use it or set some default value.

A workaround would be to disable warnings with error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); in the beginning of the file, but the best solution would be to fix those warnings instead.

cc: @JamesHeinrich

andymnc commented 1 month ago

208 should fix the issue in first comment.

@badbadmonkey what happens is that since 8.x compiler throws warnings about using values which are not set. Those are sent before headers are set, so image is generated, but not visible as text was sent before headers. On second request code uses cached image - so code with warnings is not executed.

Could be fixed by checking with isset() if variable was set and if not - then not use it or set some default value.

A workaround would be to disable warnings with error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); in the beginning of the file, but the best solution would be to fix those warnings instead.

cc: @JamesHeinrich

i suggest using !empty instead of isset, cause isset could return true while the value still being null (ie $example = null then you test with isset($example) and it will return true). Using !empty instead of isset, it checks for isset (and if not it doesn't throw a warning but it returns false) and if variable is set but value is null, it returns false