when throttling is active, in addition to front-end pages, ACT requests returning json packets are also throttled.
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start by reading the throttling guard around line 340 of system/ee/libraries/Core.php, which currently excludes REQ == 'CP', and the banish() method in system/ee/libraries/Throttling.php that builds the current plain-text/404/redirect response. Reproduce with a low max_page_loads/time_interval pair, then hit an ACT endpoint with X-Requested-With: XMLHttpRequest to see the non-JSON body. Decide between the two proposed fixes on the thread — the simpler REQ == 'ACTION' && AJAX_REQUEST exclusion in Core.php, or a JSON 429 response in banish() — and verify AJAX-driven control panel elements no longer break; done means an AJAX ACT call gets a usable response instead of plain text.
由索引模型根據 Issue 內容生成。
描述
Description of the problem
ExpressionEngine throttling currently applies to ACT requests and appears to return responses intended for normal page requests (plain text/redirect/404), even when the request is AJAX and expects JSON.
This causes AJAX driven elements in CP pages to fail when throttling is triggered.
This in turn causes problems for some add-ons (e.g. JCOGS Image Pro) that use ACT based AJAX requests to generate dynamic parts of some control panel pages.
A better response would be either for throttling to return an API-safe response to AJAX/JSON-accepting requests, or to simply allow ACT based AJAX requests to run.
How To Reproduce
Steps to reproduce the behaviour:
- Enable throttling in EE settings.
- Configure low values (example):
max_page_loads = 2time_interval = 5lockout_time = 30
- Call an
ACTendpoint repeatedly using AJAX (X-Requested-With: XMLHttpRequest) expecting JSON. - Observe that after threshold is exceeded, response body is plain text/404/redirect style rather than JSON.
Error Messages
Plaintext:"You have exceeded the allowed page load frequency."
Environment Details:
- Version: 7.5.21
- PHP Version 8.2.30.
Possible Solution
It appears that the throttling code makes no attempt to identify AJAX requests.
- One solution would be to modify the
banish()method insystem/ee/libraries/Throttling.phpto include a check to see if call being processed is both an ACT request (REQ='ACTION')and an AJAX request (AJAX_REQESTdefined) and use this to generate a fourth type of output with appropriate HTTP headers and message body ... for example:- HTTP
429 Too Many Requests Content-Type: application/json; charset=utf-8- JSON body with a stable error shape such as:
- HTTP
{
"status": "error",
"error": "Request throttled. Please try again later.",
"error_code": "throttled"
}
- A second (better, and easier) solution would be to exclude AJAX based ACT from throttling - along lines of current exclusion of CP activities by changing the conditional on line 340 of
system/ee/libraries/Core.phpto includeREQ='ACTION'andAJAX_REQEST- e.g.if (REQ != 'CP' && ! (REQ == 'ACTION' && AJAX_REQUEST)) {
- 主要語言
- PHP
- 星號
- 505
- 分支
- 135
- 平均合併
- 3 天 7 小時
- 30 天內合併 PR
- 7
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ExpressionEngine/ExpressionEngine 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
ExpressionEngine/ExpressionEngine#5453 ·
維護者通常 1 天內回覆
-
RTE Custom Stylesheet causes warning: Trying to access array offset on value of type bool可能已有人在做 @Yulyaswan 於 11 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
ExpressionEngine/ExpressionEngine#5406 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
ExpressionEngine/ExpressionEngine#5381 ·
維護者通常 1 天內回覆
-
Bug: Accepted
難度 2/5 1-3 小時 新手友好度 66/100
ExpressionEngine/ExpressionEngine#5117 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
ExpressionEngine/ExpressionEngine#5066 · 1 則留言 ·
維護者通常 1 天內回覆
查看 ExpressionEngine/ExpressionEngine 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
nextcloud/sharelisting#624 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
FriendsOfFlarum/synopsis#16 ·
-
bug javascript
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
simplesamlphp/simplesamlphp#2693 · 1 個 reaction ·