Problem/Motivation

When the display_errors feature is enabled in php.ini and an AJAX request exceeds the post_max_size limit the AJAX command will not be executed. At the top of the AJAX response a PHP warning will be present: "POST Content-Length of x bytes exceeds the limit of y bytes". This invalidates the JSON and the AJAX command will not be executed.

A simple way to replicate this is by enabling display_errors and uploading a file that exceeds the post_max_size through the standard file field widget. The AJAX response that should normally show an error message is not executed and nothing seems to happen to the end user.

Proposed resolution

Maybe disable display_errors at runtime for AJAX responses, instead delegating the errors to the watchdog, or perhaps clearing the PHP output buffer before rendering the AJAX response so that the error is not present in the JSON body.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

pfrenssen created an issue. See original summary.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.

Since there has been no activity here for over 8 years we are asking if this problem persists on a currently supported version of Drupal. To help, add a comment explaining if the problem still occurs or not. Any extra detail you can provide can help others who experienced this.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

hitchshock’s picture

Status: Postponed (maintainer needs more info) » Needs review

I reproduced the same bug.
Steps:
- Drupal 11.2
- Add a file field to the content
- Try to upload the file with a size larger than the PHP upload limit
- An AJAX error occurred because of an incorrect AJAX response

<br/><b>Warning</b>:  PHP Request Startup: POST Content-Length of 262146036 bytes exceeds the limit of 209715200 bytes in <b>Unknown</b>on line<b>0</b><br />[
    {
        "command": "settings",
        "settings": {
            "pluralDelimiter": "\u0003",
            "suppressDeprecationErrors": true,
            "csp": {
                "nonce": "37TvKHzAosgh3S9Z94XopA"
            },
            "user": {
                "uid": 10671,
                "permissionsHash": "8934f3aa04d86a3fb7ad85f0f26cc491b5d38e50d32037c8e56ab62de6ddfd65"
            }
        },
        "merge": true
    },
    {
        "command": "add_js",
        "selector": "body",
        "data": [...]
    },
    {
        "command": "insert",
        "method": "prepend",
        "selector": null,
        "data": "...",
        "settings": null
    }
]

But it seems like the solution in #3494148: AJAX Response Not Sanitized For Length fixes the issue.
Can someone try to reproduce the issue and try to fix it by solution from 3494148.
This may assist others in resolving a similar issue.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

May still be the correct status.

If this gets closed please move over credit for @hitchshock to #3494148: AJAX Response Not Sanitized For Length