Endless Saving message

Summary

I’m getting an endless Saving message when trying to save resources, but only for users that don’t have full admin permissions (“editors”, based on the Administrator Template). The resource does get saved, despite the message. Updating the permissions for editors to include all the permissions in the Administrator Template also doesn’t fix the issue, nor does recreating the Editors group from scratch. Adding the Administrator ACL to editors at the Super User level and updating an editor to super user also doesn’t work. Switching the user’s access permissions to the Administrator group is the only thing that fixes it.

This was working fine before; no permissions have been changed. I’m wondering if some plugin update did something, although disabling plugins doesn’t fix the issue.

This is happening on two or three of my sites. The great majority of them don’t have this issue.

Observed behavior

Javascript console shows this after clicking the Save button:

POST https://www.healthandenvironment.org/connectors/index.php 500
VM1412:1 Uncaught SyntaxError: Unexpected token '<'
    at doDecode (ext-all.js:21:53110)
    at Object.decode (ext-all.js:21:54709)
    at Ext.form.Action.Submit.handleResponse (utilities.js:358:21)
    at Ext.form.Action.Submit.processResponse (ext-all.js:21:629307)
    at Ext.form.Action.Submit.success (ext-all.js:21:631040)
    at o (ext-all.js:21:52418)
    at Ext.data.Connection.s (ext-all.js:21:52430)
    at HTMLIFrameElement.I (ext-all.js:21:57750)

Any ideas?

Environment

MODX 2.8.4 with various plugins

These console error messages are not very useful most of the time.
Usually there is an AJAX request and javascript expects a JSON result. If there is an error, the result is not JSON and javascript outputs an error message.

So instead, go to the “Network” tab in the developer tools, and look at the response of the request that fails. Is there something useful in the response?

If not, as this seems to be a 500 error, check the server error log for any related error messages.

The Network tab shows index.php firing, with this response:

GENERAL
Request URL: https://www.healthandenvironment.org/connectors/index.php
Request Method: POST
Status Code: 500 
Remote Address: 216.37.42.139:443
Referrer Policy: strict-origin-when-cross-origin

RESPONSE HEADERS
alt-svc: h3=":443"; ma=2592000, h3-29=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="43,46"
cache-control: no-store, no-cache, must-revalidate
content-encoding: gzip
content-security-policy: upgrade-insecure-requests
content-type: text/html; charset=UTF-8
date: Wed, 15 Feb 2023 17:50:37 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: LiteSpeed
set-cookie: PHPSESSID=redacted; path=/; HttpOnly; secure
vary: Accept-Encoding,User-Agent
x-powered-by: PHP/7.4.33

REQUEST HEADERS
:authority: www.healthandenvironment.org
:method: POST
:path: /connectors/index.php
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: max-age=0
content-length: 12294
content-type: multipart/form-data; boundary=----WebKitFormBoundaryONaJxboqFJD5OQIe
cookie: PHPSESSID=redacted; timezone=America/New_York; cpsession=redacted
origin: https://www.healthandenvironment.org
referer: https://www.healthandenvironment.org/manager/?a=resource/update&id=6363
sec-ch-ua: "Chromium";v="108", "Not?A_Brand";v="8"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
sec-fetch-dest: iframe
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

The plugin LinkStrategy was causing an issue on one site. Removing it fixed the problem there.

On a different site, the console shows "Object { message: “JsonReader.read: Json object not found” }, and the Network tab shows:

GENERAL
Request URL: https://www.nedcc.org/connectors/index.php
Request Method: POST
Status Code: 500 
Remote Address: [2606:4700:3030::ac43:cf51]:443
Referrer Policy: strict-origin-when-cross-origin

RESPONSE HEADERS
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cache-control: no-store, no-cache, must-revalidate
cf-cache-status: DYNAMIC
cf-ray: 79a02722aa1f8cbd-EWR
content-type: text/html; charset=UTF-8
date: Wed, 15 Feb 2023 18:37:07 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
pragma: no-cache
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=AvED9JhDAK9A3Tl3wmeYdrrQQQH%2Fr7x2iuJCFXdd53sH48yuSpyluIiUeXrJDCANatElH0aYnyLiXNYXTvUzKdxaA7f6x14SoZlsqoAYLG3lo5Om9q8J16AFkGiyCJAmxJtGw4THM1bgc7at"}],"group":"cf-nel","max_age":604800}
server: cloudflare
set-cookie: PHPSESSID=redacted; path=/; HttpOnly; secure
vary: Accept-Encoding
x-powered-by: PHP/7.2.34
x-turbo-charged-by: LiteSpeed

REQUEST HEADERS
:authority: www.nedcc.org
:method: POST
:path: /connectors/index.php
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: max-age=0
content-length: 15660
content-type: multipart/form-data; boundary=----WebKitFormBoundary4de02kxNmuH54nyA
cookie: __utmz=45962043.1659969880.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=45962043.1689695777.1659969880.1659969880.1667495732.2; PHPSESSID=redacted
origin: https://www.nedcc.org
referer: https://www.nedcc.org/mgnedr/?a=resource/update&id=1778
sec-ch-ua: "Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
sec-fetch-dest: iframe
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

There are no errors in either the MODX log or the server error log.

So what is the actual response? (Not the response headers!)

None. It just says “This request has no response data available.”

It could be that a mod_security rule has changed and doesn’t like something in the pages. That will always result in an endless save progress bar.

Because the resource gets saved, I don’t think it’s a firewall issue. (I also don’t see how MODX permissions would influence the behaviour of the firewall.)

My guess is, that a plugin on the event “OnDocFormSave” generates an error.
But without an error message, it’s impossible to know for sure.

Errors in plugins, even serious syntax errors, almost never generate an error message. They just die. And in the case of OnDocFormSave, you usually get the endless progress bar after the resource has been saved.

Really? What is so special about code in a plugin that PHP wouldn’t log an execution error?


@snowcreative When you save a resource in the manager, a request occurs that executes the resource/update processor. This processor runs the event “OnBeforeDocFormSave”, saves the resource, then runs “OnDocFormSave”.

You could try to narrow down where the error happens by creating a custom plugin (or adding log-lines to existing plugins).

For example:
Create a plugin with this code and select the checkboxes for the events “OnBeforeDocFormSave” and “OnDocFormSave”.

<?php
$eventName = $modx->event->name;
$modx->log(modX::LOG_LEVEL_ERROR, $eventName . ' runs...');

After the error, check the MODX error log. What gets logged?

Change the priority of the custom plugin (or other plugins that run on the same event) to see if that changes the output. Plugins with a low priority number run first.

  1. I tried the custom plugin. The log records it running OnBeforeDocFormSave, but not OnDocFormSave, unless I’m logged in as Administrator / Super User, in which case it runs on both.

  2. modSecurity is turned off for this site.

  3. I disabled every plugin, and the problem persists.

And now things have gotten even worse. I noticed when clearing the cache through an editor account that one resource was listed as inaccessible at the end of the displayed cache clearing log. That resource was assigned to the group “admin”, so it’s hidden from editors. In a different browser, I logged in as admin and removed this resource from the admin group. Then, the editor account could access this resource, but every other resource became inaccessible! At first, there as just an “access denied” message, now there is nothing but a white screen when trying to edit a resource. Further, the admin account now can’t access resources either — I just get the white screen. Something is seriously messed up.

I restored the databases from a recent backup, and that didn’t fix anything. I then reinstalled MODX 2.8.4 using UpgradeModx, and everything is back the way it was — I can edit resources again, but there is still the endless saving problem for editors.

OK, update: I again removed the two resources that were in the Admin group from that group, and now editors can save resources properly. It seems that clearing the cache is what triggers the problem. Resources in a group that is inaccessible to editors are trying to be cleared from the cache, and can’t because they don’t have permission to access those resources, so it just hangs up.

Something must have been corrupted in the MODX installation, so reinstalling fixed that, but the cache issue remains. Did some update in 2.8.4 make some change to the way clearing the cache works or the way ACLs or resource groups work? I didn’t have this problem prior to 2.8.4.

However, there is another weird thing with clearing the cache on this site. The clear cache console shows a string of messages like this:

10 was requested but no alias was located.
Resource with id 10 was not found in context mgr

Every resource shows up in this list. The cache does get cleared, but why does MODX think there is “no alias” and why is it looking for them in the “mgr” context instead of the “web” context?

I’m pretty sure you don’t need permission to access a resource to be able to clear the “resource” cache partition.

@halftrainedharry I don’t know why it happens, but I’ve seen it many times.

The invokeEvent() method of the modX class is pretty complex. It creates ad hoc events, calls modPlugin->process(), which calls ob_start() and tacks the output onto the plugin object as $this->_output.

I think any fatal error just stops things dead (possibly the PHP error has been converted to an exception that’s not handled). The code that stops the progress bar never executes.