I have heard that PHP 5.4 is faster than PHP 5.3.
Would it be ok for Drupal 7 to run under 5.4, or various contributed modules may start to break the site?
Anyway, If I use APC opcode cache, maybe 5.4, would not offer any benefit at all?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
I have begun running Drupal 7 on PHP 5.4 myself with only minor problems in the form of notices and warnings.
On top of 7.12, you will need these two patches to fix the issues causing PHP to complain:
One of these patches has already been applied to -dev, so will be in 7.13, and the other is likely going in soon. In all cases that I can immediately think of, the bad practice causing 5.4 warnings has been bad use of array keys.
The first version of this looks like this:
$some_key = function_call(); return $some_array[$some_key];
Some times, the function call will return an array or an object, neither of which is a valid array key. In PHP 5.3, what actually, and silently happens, looks like this:
$some_key = function_call(); return $some_array[(string)$some_key];
PHP 5.4 however, warns that this may not be what you want. The second version is exactly the same, but the other way around.
$some_key = 'a_valid_key'; $may_be_a_string = function_call(); return $may_be_a_string[$some_key];
which yields an error message like
Illegal string offset 'a_valid_key'
$may_be_a_string is actually a string, not an array, since the only valid string indexes are integers.
As the problems are easy to understand and the fix is (mostly) easy to apply, I've found that in several cases, -dev versions are already updated, or patches posted in the queue, that are likely to quickly go in due to their simple nature.
After some testing, I don't feel like 5.4 is "dangerous" to run in production, and I have begun running my small and personal sites on it already. I would encourage other to do the same, so we can avoid the historically slow uptake of new PHP versions.
At the time of writing, APCs latest version, 3.1.9, does not work with 5.4. I have successfully built and used it from git though.
Using APC will likely reduce the performance benefit of upgrading the PHP version, but not remove it.