Strange behaviour: MODx + PDOTools + Cli mode

We have several MODX instances which have been running perfectly for several years and are administered via the CLI for certain operations.

After installing PDOTools, the web display works perfectly while CLI calls give errors:

Fatal error: Uncaught Error: Call to a member function parseProperties() on null in /{path}/core/model/modx/modelement.class.php:567 
Stack trace: #0 /{path}/core/model/modx/modx.class.php(1672): modElement->getProperties() #1 /{path}/core/model/modx/modx.class.php(570): modX->invokeEvent() #2 
/app/web/projects/webtest/ug-stg/my.php(11): modX->initialize() #3 {main} thrown in /{path}/core/model/modx/modelement.class.php on line 567

I tried to install a clean version of MODX: same result.
I tried a simulation on my development server with an identical version of PHP: it works.
With a restore on my development server: it works.

I try it with a minimal cli script too:

$modx_folder = '/{path}}/';
require_once ($modx_folder.'config.core.php');
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
// require_once($modx_folder.'index.php');
$modx= new modX();
$modx->initialize('mgr');

Does anyone have any clues? Apache or PHP configuration?
The only difference is mod_PHP versus CGI. I suspect a PHP setting.

Any other ideas?

MODX 2.8.5
PHP 7.4.33
Apache 2.4.54

The error message implies, that (somehow) the pdoParser (an extension of modParser) can’t be loaded:

Thank you for your help. Do you have any suggestion to adapt my code or settings? It’s strange: before installing PdoTools, it work fine.
Stranger is that problem occured only in cli mode and not in the browser…

I have no idea why the error occurs.

Maybe try resetting the system settings parser_class and parser_class_path to their original values (if you don’t need the parser from pdoTools; e.g. for Fenom) and test if that fixes the issue.

Thanks for your help.
I found the solution.

We use a NFS mount point to share MODX-data on several server behind a load balancer.
We use an admin-server to launch some command in CLI-mode.

Path on PROD server are not the same as on ADMIN server.
Some variables are stored on MODX cache, this include path to the parser.
If I called MODX on web side, this corrupt the cache for CLI and if I launched CLI, it corrupted the cache for the web side.

Solution: after initializing MODX, setup $conf var to the right value in CLI-mode.
Thank you to Fabian (pixmill.ch) and Vassily (bezumkin2)

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.