generating Captchas and PHP >= 5.4 versions

Found a bug? Tell us!!
Post Reply
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

generating Captchas and PHP >= 5.4 versions

Post by Timbalu »

I changed to debian Whezzy and PHP 5.4 .x version on my server the last weeks and did ever wonder, why I could not get Captchas properly being generated by the spamblock plugin. (You can see them working or failing at the end of the spamblock plugin config page.)

Its not the imagick bug we had had some time ago. It is a changed behaviour in imagecreate() function with PHP > 5.3 versions, generating a [HTTP error.log] PHP Warning: imagejpeg(): Filename cannot be empty in /var/www/path/to/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php on line 1339 (line num in official released spamblock version 1.80!)

Please change:

Code: Select all

imagejpeg($image, '', 90); 
to

Code: Select all

imagejpeg($image, NULL, 90);
or
download this file and replace it with yours:
https://raw.github.com/s9y/Serendipity/ ... mblock.php

References:
https://bugs.php.net/bug.php?id=63920

Serendipity 1.7.4-beta in our github repository has been updated.

Addition:
On Line 1303 the image is created with

Code: Select all

$image  = imagecreate($width, $height);
[imagecreate() returns an image identifier representing a blank image of specified size.]
It is often recommended to use imagecreatetruecolor() nowadays, but this would turn our background color black.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: generating Captchas and PHP >= 5.4 versions

Post by garvinhicking »

Good ca(p)tch ;) Thanks!
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply