• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Problems after upgrade PHP from 5.2.x to 5.3.x

m0rpheu5

Regular Pleskian
Hello guys i´m getting many problems with my client, 80% of their sites or applications stop to work, Joomla, Wordpress, PHPBB is not working, but didn´t give any error log, but many sites that use Thumbnails to create some images, get many messages like this:

PHP Warning: strlen() expects parameter 1 to be string

i got many messages like that.

Anybody know if can i fix this or do i need to do a downgrade in PHP version?

Thanks
 
Take alook at php.net regarding this function: http://php.net/manual/en/function.strlen.php
It seems that there are difference between 5.2.x and 5.3.x for this function. Here is an explaination regarding this issue:

We just ran into what we thought was a bug but turned out to be a documented difference in behavior between PHP 5.2 & 5.3. Take the following code example:

<?php

$attributes = array('one', 'two', 'three');

if (strlen($attributes) == 0 && !is_bool($attributes)) {
echo "We are in the 'if'\n"; // PHP 5.3
} else {
echo "We are in the 'else'\n"; // PHP 5.2
}

?>

This is because in 5.2 strlen will automatically cast anything passed to it as a string, and casting an array to a string yields the string "Array". In 5.3, this changed, as noted in the following point in the backward incompatible changes in 5.3 (http://www.php.net/manual/en/migration53.incompatible.php):

"The newer internal parameter parsing API has been applied across all the extensions bundled with PHP 5.3.x. This parameter parsing API causes functions to return NULL when passed incompatible parameters. There are some exceptions to this rule, such as the get_class() function, which will continue to return FALSE on error."

So, in PHP 5.3, strlen($attributes) returns NULL, while in PHP 5.2, strlen($attributes) returns the integer 5. This likely affects other functions, so if you are getting different behaviors or new bugs suddenly, check if you have upgraded to 5.3 (which we did recently), and then check for some warnings in your logs like this:

strlen() expects parameter 1 to be string, array given in /var/www/sis/lib/functions/advanced_search_lib.php on line 1028

If so, then you are likely experiencing this changed behavior.
 
Back
Top