Modx PHP warning: constant(): Couldn't find constant 32759


Error thrown by modProcessor

Step to reproduce

Clean install of 2.7.1-pl and migx. Error reporting setting default.

Observed behavior

refreshing a migx cmp throws as many lines of the same error as the number of records shown in the grid

Expected behavior

How it should behave after following the steps above.
Dont throw errors :laughing:


MODX version tagged when creating the issue, Apache or NGINX with version, MySQL version, browser, etc. Any relevant information.

In response to this thread where a member described the problem as occurring on a regularly updated installation, i noticed the same behavior on a fresh install of 2.7.1pl

The error thrown is:
(ERROR @ /var/www/vhosts/ : 679) PHP warning: constant(): Couldn’t find constant 32759
[2019-10-16 15:15:36] (ERROR @ /var/www/vhosts/ : 679) PHP warning: constant(): Couldn’t find constant 32759

The line is: $debug = (is_int($debug) ? $debug : defined($debug) ? intval(constant($debug)) : 0);

I’ve thougth about it and figured it should just work cause defined debug should test for the constant being set. And it is. So maybe the ternary (which is a bit hard to read(well for me at least)) is a little borked.

So I’d figure a simple solution to this one which helped me out, and maybe OP as well is the little ditty below.

    // nothing
	$debug = (int) $constant($debug) ;
        $debug = 0 ;

In all fairness as far as I can tell the notice doesn’t prevent anything from functioning properly and when going live error reporting will be set to 0 anyway. Just figured you guys like to know. Also if my ‘fix’ is flawed too I’d like to hear about it.

1 Like

I wonder… does the notice go away if you change the ternary to this?

$debug = is_int($debug) ? $debug : (defined($debug) ? intval(constant($debug)) : 0);

Or slightly more readable:

$debug = is_int($debug) 
    ? $debug 
    : (
        ? intval(constant($debug)) 
        : 0
1 Like