modx-pro / pdoTools

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

pdoPage: Undefined variable $showLog #351

Open jolichter opened 1 year ago

jolichter commented 1 year ago

Hi, I get this message in the error log:

ERROR @ .../modx/core/cache/includes/elements/modx/revolution/modsnippet/10.include.cache.php : 209) PHP warning: Undefined variable $showLog

My quick & dirty fix in Snippets -> pdoTools -> pdoPage (set the var $showLog):

/** @var bool $showLog */
$showLog ='';
if ($modx->user->isAuthenticated('mgr') && (bool)$showLog) {
    $modx->setPlaceholder('pdoPageLog', print_r($paginator->pdoTools->getTime(), true));
}

Maybe you can fix that in the next update?

Tks Jo

jolichter commented 1 year ago

I cannot create a pull request because I can't find pdoTools 3.0.x-pl on GitHub. But I think this solution with the isset function is the better way:

/** @var bool $showLog */
if (isset($showLog) && $modx->user->isAuthenticated('mgr') && (bool)$showLog) {
    $modx->setPlaceholder('pdoPageLog', print_r($paginator->pdoTools->getTime(), true));
}
Esger commented 6 months ago

It's here as well: [2024-04-04 09:23:01] (ERROR @ /www/core/cache/includes/elements/modx/revolution/modsnippet/7.include.cache.php : 210) PHP warning: Undefined variable $showLog (ModX 3.04 - Modx cloud)

pixelstuff commented 5 months ago

Apparently this wasn't fixed in pdoTools 3.0.2 or MODx 3.0.5 or wherever it needs to be fixed.

Running with PHP 8.2.

If one of the fixes above works, where should it be changed? Changing it the cached file that is reported in the error logs doesn't work if the MODx cache is cleared. I have also tried updating it in the file: core/components/pdotools/elements/snippets/snippet.pdopage.php , but that doesn't fix the cached file either.