modx-pro / pdoTools

Library for creating fast snippets for MODX Revolution.
95 stars 87 forks source link

Fatal error caused by loop #341

Closed sdrenth closed 2 years ago

sdrenth commented 2 years ago

I also added this bug in ClientConfig, because I'm not 100% sure if this issue belongs to either ClientConfig or pdoTools.

Issue in ClientConfig repo: https://github.com/modmore/ClientConfig/issues/192

Summary

The plugin from clientconfig 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

EMDM45 commented 2 years ago

Точно такая же ошибка (Allowed memory size) у меня возникает, когда плагину ставлю событие pdoToolsOnFenomInit и открываю любую страницу сайта (web). MODX 3.0.1, pdoTools 3.0.0

Предполагаю, что вот тут проблема в том же самом: https://github.com/modx-pro/pdoTools/issues/329

sdrenth commented 2 years ago

@EMDM45 I checked some more and it occurs as soon as I add the even to the plugin, even if the plugin code is empty. So it seems like it actually is a pdotools issue.

EMDM45 commented 10 months ago

Если сделать плагин статичным, ошибка возвращается. MODX 3.0.4-pl pdoTools 3.0.2-pl php 7.4.9