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:
mysqli_connect() [<a href='function.mysqli-connect'
(HY000/2002): Can't connect to local MySQL server through socket
on line 132
Connection error: Couldn't connect to database.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.
Please try again later or inform the system administrator.
Can't connect to local MySQL server through socket
User not found, returning anonymousWarning:
Anonymous user not found, returning NoUserBecause 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
define( 'EZ_ERROR_KERNEL_NO_DB_CONNECTION', 50 );
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.