Upgrading to MODx 3 Errors

I recently upgraded one of my sites to MODx 3 from 2.8.6. I upgraded it while using PHP 7.4 since using PHP 8.X gave me a session_start error. Now MODx only works with PHP 7.4, when I try to upgrade to any version of PHP 8, I get the errors in the images below. Which includes 1 PHP warning and multiple js errors. Any assistance would be welcome and Thank you in advance.


php_warning

An error like Unexpected token '<' in JS is usually just a subsequent error from a problem in PHP.
JS makes an AJAX-request, expects JSON as a response, but gets HTML instead.

Can you check in the “Network” tab of the developer tools (in the browser), what request returns the wrong data? Does the request return a 500 status code? What’s the response of this request?

All the JS files in the network tab are showing status 200 and there are no Fetch/XHR requests

The first error seems to stem from the file connectors/modx.config.js.php. A request to this PHP file should return valid JS (to make for example the system settings availabe in JS).
Something in the form:

Ext.namespace('MODx');
MODx.config = {...};
MODx.perm = {...};
MODx.user = {...};

Can you check what this request returns instead?

I don’t know if I did this correctly but here:
image

image
it wont output in the modx error log or the local error log.

You don’t have to call fetch. MODX makes the request for you when you load the manager. Just search for the request in the “Network” tab (of the developer tools) and check the result.


The problem seems to be, that the PHP warning gets put into the response and that breaks the code.
Deactivate display_errors on your system. At least for warnings. (But it’s in general not good practice to output error messages to the public.)


I suspect the warning occurs because of some outdated code or setting. The code tries to access the key “modUser” in an array. But in MODX 3 the key is “MODX\Revolution\modUser”.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.