Strange and critical cache problem on shared hosting

it seems like the cache files are written twice.

The problem :
Most of the time, when clearing cache, the front and the manager not working but display cache error like :

Parse error: syntax error, unexpected '<', expecting end of file in …

Parse error: syntax error, unexpected 'resource' (T_STRING), expecting ']' in /home/hqdoewe/recette/core/cache/includes/elements/modplugin/9.include.cache.php on line 254

then, the front and the manager become broken, only displaying the error.
the only way is to delete manually the /core/cache folder.

When i try to edit the problematic cached files, at the faulty line, i can see the file is written twice !
in the middle of the file, there’s a <?php … and the file content again.

note :
I’ve used MODX for dozen of sites. For years, it’s my main tool for doing good job.
Most of the time, i do the development on my private server,
and once my client validate it, deploy the site on the client hosting.
I’m not a great developper, but i’m relatively confortable with MODX and PHP.
MODX cache always worked well, for all the sites i did. Never had a problem.

This problem is very specific, but it occured for all the sites i did since MODX 2.7.x (not really sure when it happend first) when they run from OVH shared hosting.

For the strict same site (same files, same db):

  • the problem occurs only on shared hosting (mutualisé OVH :
  • it never occurred on my vps server (centos7)
  • it never occurred on my dedicated server (centos7)
  • it never occurred on o2switch shared hosting

Can anyone help me with this ?
thank you

In your config file in core/config/, find $config_options and add use_flock to it:

$config_options = array(
    'use_flock' => false

It seems your shared server doesn’t provide a safe flock (file-lock) implementation, so by telling MODX not to use flock but a custom file locking approach that should become more reliable.

Thank you Mark for your swift and effective response !

it seems to work, i will see other time if it’s really OK.

Why this setting doesn’t exists in MODX params beside cache settings ?

Since MODX system settings are themselves cached, this option has to be set manually in the config file in order for it to apply to all caching. This is why it is not in the system settings. It is also not a common setup to have a filesystem that does not support flock.