pdoTools icon indicating copy to clipboard operation
pdoTools copied to clipboard

pdoPage: Undefined variable $showLog

Open jolichter opened this issue 2 years ago • 3 comments

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?

  • MODX 3.0.1-pl installation on Linux Server
  • PHP: 8.1.11
  • mySQL: 8.0.30
  • pdoTools 3.0.1-pl

Tks Jo

jolichter avatar Nov 01 '22 18:11 jolichter

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));
}

jolichter avatar Dec 27 '22 11:12 jolichter

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)

Esger avatar Apr 04 '24 10:04 Esger

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.

pixelstuff avatar Apr 21 '24 18:04 pixelstuff