modmore / ClientConfig

ClientConfig is a MODX Revolution Extra to allow clients to maintain settings in a user friendly way.
https://docs.modmore.com/en/Open_Source/ClientConfig/index.html
MIT License
28 stars 27 forks source link

Fatal error caused by loop #192

Closed sdrenth closed 1 year ago

sdrenth commented 2 years ago

Summary

The plugin causes a loop which results in a fatal error: Fatal error: Allowed memory size of 134217728 bytes exhausted

Step to reproduce

On MODX 3 using pdoTools 3.0.0-beta:

The error should now be triggered in both the MODX manager & frontend.

Observed behavior

The client config plugin listens to the pdoToolsOnFenomInit event, which triggers the parseProperties in the modMediaSource class which triggers the loop:

public function parseProperties(array $properties)
{
    if (empty($properties)) {
        $properties = $this->getProperties();
    }
    $this->xpdo->getParser();
    if ($this->xpdo->parser) {
        foreach ($properties as &$property) {
            $this->xpdo->parser->processElementTags('', $property['value'], true, true);
        }
    }

    return $properties;
}

Because the constructor of ModxPro\PdoTools\Parsing\Fenom\Fenom includes the invokeEvent:

$this->modx->invokeEvent(
    'pdoToolsOnFenomInit',
    [
        'fenom' => $this,
        'config' => $pdoTools->config(),
    ]
);

This keeps triggering the clientconfig event resulting in the allowed memory exhausted error.

Expected behavior

I'd expect that the ClientConfig plugin is only triggered once for the pdoToolsOnFenomInit event.

Environment

MODX3 PDOTools 3.0.0 beta ClientConfig 2.3.0

Mark-H commented 2 years ago

I doubt it's intended in pdoTools to repeatedly trigger that event, so it would be great to also report it on that repo.

Like you say, ClientConfig can guard against it as well tho so will look at that.

MaticSulc commented 2 years ago

Any updates regarding this?

Mark-H commented 2 years ago

Nope, we'll update this issue when that happens.

muzzwood commented 1 year ago

Hi @sdrenth, are you able to confirm if this issue has been resolved now?

https://github.com/modx-pro/pdoTools/issues/341

muzzwood commented 1 year ago

I can replicate it with pdoTools 3.0.1-pl, so have added a check to the plugin to prevent it running more than once.