Wednesday, November 12, 2008

Read about French eZ Developer day with Google Readers inline Translations

There is a wonderful French eZ publish community and many of the members blog. In the past keeping up to date with these has been a quite painful and involved passing the link through an online translator.

Yesterday I read an announcement that Google have added automated translations to their online RSS reader product, Google Reader. Now reading these blogs is as simple as adding the feed and selecting "Translate into my language" from the feed settings options.

I discovered this great new feature at the same time that I read Damien Pobels post pointing out summaries of the eZ Developer day recently held in Paris:
Gauthiers post mentions that there is an International eZ Publish Developer day to be held in Barcelona on January 29, 2009. Can't find anything on the eZ site though.

Tuesday, November 11, 2008

eZtip: Errors can be misleading...what happens when the DB is dead

I recently received an email from an eZ community member stating after an abnormal system reboot that their working eZ Publish install was reduced to responding with "Error / kernel (1) Access denied"

My suspicion was that there was an issue with the database. More than likely it had not successfully started when the system was brought up again.

I tested this theory by stopping the database in my local development environment and accessing the associated eZ Publish site. Manually editing the settings/siteaccess/eng/site.ini/append.php to turn on debugging confirms the problem and gives an insight into what is happening:

Warning: PHP
mysqli_connect() [<a href='function.mysqli-connect'
(HY000/2002): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
in /var/www/ezpublish-4.0.0-ezwebmin/lib/ezdb/classes/ezmysqlidb.php
on line 132

Error: eZMySQLiDB
Connection error: Couldn't connect to database.
Please try again later or inform the system administrator.
Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
One of the main concepts of eZ publish is that there is always a user associated with an access. If a specific user is not logged in then the special "anonymous user" is utilised. The anonymous user exists and must be retrieved from the database so that the roles that are associated with it can be access and the permissions system can determine if the user has access to the requested resource.

User not found, returning anonymous
Anonymous user not found, returning NoUser
Because the database is not accessible the Anonymous user cannot be retrieved so the system creates a "dummy" eZUser object (NoUser) and returns that. (This behavior can bee seen in the eZUser:instance method in kernel/classes/datatypes/ezuser/ezuser.php)

As NoUser does not exist and has no role information associated with it, not that any could be retrieved, the system responds with the access denied message.

Now I'm sure that at some point eZ Publish raised an error on database connectivity issues instead of attempting to continue. Having a poke through the source code I found kernel/error/errors.php contains:

No database connection

Interestingly this constant doesn't appear anywhere else within the source. I wonder why it is no longer used?

As eZ Publish is pretty much useless when database access is not present the system should raise a specific DB error error when access cannot be established. (Of course this could be overridden for each siteaccess). At the very least this would give the site owners a better indication of where to start looking for solutions.

I've raised an issue here. I can't think of any reasons why this isn't a good idea.

Update: The Admin siteaccess does display a the following error when the DB is not accessible:
  • No database connection could be made, the system might not behave properly.
Hat tip to @andrewduck. Will have to investigate...