[horde] Can't save preferences with MySQL 4.1 and PHP5

Tim Weber horde.list at scytale.de
Fri May 13 06:15:38 PDT 2005


I wrote:
> I've installed Horde 3.0.4 to an Apache 2.0.54 with PHP 5.0.4, MySQL 
> 4.1.8 and PEAR::DB 1.7.6, running under Linux.  I am _not_ using the 
> MySQLi interface.  And my problem is that I cannot save any preferences.
> 
> Setting the logging mode to DEBUG reveals that not a single INSERT or 
> UPDATE statement is issued.  The horde_prefs table stays empty, and so 
> do all the other horde tables.

Together with chagenbu (thanks again!) I found the problem in an IRC 
debugging session yesterday.  The culprit seems to be PHP itself:

In lib/Horde/Prefs/sql.php, there is the function Prefs_sql::store(), 
which is called as a shutdown function (hooked in Prefs::_shutdown() 
called from Prefs::Prefs()) after setting any preferences.  If there are 
dirty preferences, they will be written to the database.  But first 
store() calls $this->_connect() to establish a connection to the 
database, if there is none.

Prefs_sql::_connect() in turn, if not connected, issues a
    require_once 'DB.php';
to use PEAR::DB.  And this is the problem.  Because, for some strange 
reason, require_once does not return.  At least not on my system. 
Script execution simply dies at this point, without any error or 
warning.  If I add Horde::logMessage() calls at the beginning and very 
end of DB.php (I know, it's ugly, but you can't echo in a shutdown 
function), both get logged, which means that the file can be parsed 
quite fine.  If I add logMessage() calls before and after the 
require_once statment, only the first one gets logged.

The problem can be easily fixed (with a bit of performance tradeoffs for 
large installations) by commenting out the require_once statement in 
_connect() and instead adding it at the top of the sql.php file, just 
after the <?php tag.

I'm not quite sure if this is really a PHP bug or just a strange 
coincidence (because, remember, with MySQL 4.0 I _could_ save at least 
last-login times).  Downgrading from PHP 5.0.4 to 5.0.3 did not solve 
the problem for me.

Any comments, questions and ideas concerning the subject are appreciated 
(even though it works for me now).

Regards,

      Tim.


More information about the horde mailing list