I recently upgraded this machine to Debian Wheezy (mainly to fix odd kernel crash issues that occured a couple times now) and this included a new PHP version. 5.4.0 has been stable for a month now, so I was eager to give it a spin.
Almost all applications worked without any changes, apart from the popular “Gallery” script. Gallery3 just stopped working after upgrading to PHP 5.4.0. I maintain a fairly large gallery here, so it was vital for me to keep it running.
So, the TL;DR version to fix Gallery3 in Debian Wheezy with PHP 5.4.0:
set date.timezone = <your-timezone> in php.ini and restart Apache
comment-out line 530 in gallery3/system/core/Kohana.php
If you see everything twice (all pages are there twice), you have applied the wrong hotfix. Check in the bottom of the long entry for an explanation and a fix.
After restarting Apache, the application greeted me with this error:
Notice: Undefined offset: 1 in /home/www/htdocs/gallery3.christopher-kunz.de/system/libraries/I18n.php on line 60
Updating Gallery to the current version 3.0.2 didn’t fix the issue.
Neither did the latest Git checkout, and my locales were all fine and
dandy. When googling for the error, I found a thread where the original
Gallery author debugged this issue in an earlier version of Gallery.
That thread gave me a hint that the issue might have been caused by an
incorrect php.ini setting.
From wheezy on, Debian is packaging libapache2-mod-php5filter instead
of the old libapache2-mod-php5. This new module has a new subdirectory
in /etc/php5/ and thus brings a new configuration. I found that the way
to fix the I18n.php issue is setting a timezone like this:
Search for “timezone”
Change the commented line to: date.timezone = CET (or whatever your local time zone is)
Restart Apache: service restart apache2
After this, there was no more PHP notice and sad smiley - but there was no Gallery, either. All I got was a blank screen and no error was logged. Cranking up error_reporting and even trying the method described in the Gallery3 debugging guide did not yield any usable output.
Googling helped, again. It seems that the output buffering functions
have changed in 5.4.0. What was right for 5.3 seems to be broken now -
so output buffering methods in Gallery3 have to be tweaked slightly.
Change to your gallery3 root directory.
:530 (go to line 530)
Comment out the ob_end_clean() call
Save & exit
After applying this hotfix, everything started working again.
EDIT: It seems that many people see everything twice - gallery pages,
login boxes etc. If so, you have applied an incorrect hotfix (you have
exchanged ob_end_clean() with ob_flush() or similar instead of
commenting it out). Comment the ob_end_clean() call instead of changing