From 4868f94cb5888c631925e11590b52393457a5d04 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 18 Nov 2026 15:18:52 -0500 Subject: [PATCH 1/4] docs(inspections): state that HttpStatus keeps the response status --- INSPECTIONS.md | 3 ++- src/main/resources/inspectionDescriptions/XoopsHttpStatus.html | 3 ++- tools/gen_descriptions.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/INSPECTIONS.md b/INSPECTIONS.md index 67b0aea..e57ec78 100644 --- a/INSPECTIONS.md +++ b/INSPECTIONS.md @@ -307,7 +307,8 @@ without the tag (third-party MIT / GPL prose) is only noted, never rewritten. ### XoopsHttpStatus — Hard-coded HTTP status line `header('HTTP/1.0 404 Not Found')` hard-codes the protocol version. -**Fix:** `http_response_code(404)`. +**Fix:** `http_response_code(404)`. The response status is the same (still 404); only the protocol version is left +to the server. ### XoopsUnlink — unlink() without is_file() check `unlink($path)` with no `is_file()` / `file_exists()` on the same expression dominating it. A check in the enclosing diff --git a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html index 063f521..1942570 100644 --- a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html +++ b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html @@ -3,6 +3,7 @@ XOOPS: Http Status header('HTTP/1.0 404 Not Found') hard-codes the protocol version. Use -http_response_code(404). +http_response_code(404). The response status is the same (still 404); only the protocol version +is left to the server. diff --git a/tools/gen_descriptions.py b/tools/gen_descriptions.py index 8b8a9c7..172c5ee 100644 --- a/tools/gen_descriptions.py +++ b/tools/gen_descriptions.py @@ -127,7 +127,8 @@ """, "XoopsHttpStatus": r""" header('HTTP/1.0 404 Not Found') hard-codes the protocol version. Use -http_response_code(404). +http_response_code(404). The response status is the same (still 404); only the protocol version +is left to the server. """, "XoopsIncludeOnceHeader": r"""

Reports include or require of header.php / footer.php From e800996824234f58b85c4a77a726a1fdfdd648d7 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 18 Nov 2026 15:52:48 -0500 Subject: [PATCH 2/4] fix(inspections): offer the HttpStatus quick fix only where no other status line is set --- CHANGELOG.md | 9 ++++ INSPECTIONS.md | 9 +++- .../inspections/XoopsSmallFixInspections.kt | 31 ++++++++++--- .../XoopsHttpStatus.html | 12 ++++- .../org/xoops/support/XoopsQuickFixTest.kt | 20 +++++++++ .../HttpStatus/dynamic/modules/demo/ajax.php | 7 +++ .../guard/modules/demo/include/feed.after.php | 8 ++++ .../guard/modules/demo/include/feed.php | 8 ++++ .../statusfield/modules/demo/ajax.php | 6 +++ .../HttpStatus/twolines/modules/demo/ajax.php | 6 +++ tools/gen_descriptions.py | 12 ++++- tools/gen_fixtures.py | 44 +++++++++++++++++++ 12 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 src/test/resources/fixtures/HttpStatus/dynamic/modules/demo/ajax.php create mode 100644 src/test/resources/fixtures/HttpStatus/guard/modules/demo/include/feed.after.php create mode 100644 src/test/resources/fixtures/HttpStatus/guard/modules/demo/include/feed.php create mode 100644 src/test/resources/fixtures/HttpStatus/statusfield/modules/demo/ajax.php create mode 100644 src/test/resources/fixtures/HttpStatus/twolines/modules/demo/ajax.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd28c9..4dbafc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ Marketplace plugin `org.xoops.plugin.support`. Versions 0.4.0 to 0.7.2 below are rebuild; it ships as **1.0.0 Alpha 4**, the successor of the 1.0.0 Alpha 3 release of the previous code base (https://github.com/XOOPS/phpstorm-plugin). +## Unreleased + +- **HttpStatus** offers `http_response_code(404)` as a quick fix only when every other `header()` call of the file + sends a plain `Name: value` field other than `Status:`. `http_response_code()` does not replace a status line that + an earlier `header('HTTP/…')` or `header('Status: …')` call stored in the same request, and some server APIs then + send that earlier status (seen with CGI, and for an `HTTP/` line with PHP's built-in server). A file with a second + status line, or with a computed `header()` argument, is reported without a fix. The description states that the + status code sent by the replacement is the same. + ## 1.0.0-alpha.5 — 1.0.0 Alpha 5 — Marketplace release 2026-10-26 False positives from a run over three newbb trees (`280test1/htdocs/modules/02/01inspections`, 2026-10-26), each diff --git a/INSPECTIONS.md b/INSPECTIONS.md index e57ec78..81cdddb 100644 --- a/INSPECTIONS.md +++ b/INSPECTIONS.md @@ -307,8 +307,13 @@ without the tag (third-party MIT / GPL prose) is only noted, never rewritten. ### XoopsHttpStatus — Hard-coded HTTP status line `header('HTTP/1.0 404 Not Found')` hard-codes the protocol version. -**Fix:** `http_response_code(404)`. The response status is the same (still 404); only the protocol version is left -to the server. +**Fix:** `http_response_code(404)`. The status code sent is the same (still 404); the protocol version is left to the +server and a custom reason phrase is not kept. One exception: `http_response_code()` does not replace a status line +that an earlier `header('HTTP/…')` or `header('Status: …')` call stored in the same request. On some server APIs +(seen with CGI, and for an `HTTP/` line with PHP's built-in server) that earlier status is then the one sent. The fix is therefore offered +only when every other `header()` call of the file sends a plain `Name: value` field other than `Status:`. A file with a second status line, or with a computed +`header()` argument, is reported without a fix: convert its status lines together. A status line set in another file +of the same request is not seen. ### XoopsUnlink — unlink() without is_file() check `unlink($path)` with no `is_file()` / `file_exists()` on the same expression dominating it. A check in the enclosing diff --git a/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt b/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt index 27587cc..161c86e 100644 --- a/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt +++ b/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt @@ -1,5 +1,6 @@ package org.xoops.support.inspections +import com.intellij.codeInspection.LocalQuickFix import com.intellij.codeInspection.ProblemDescriptor import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder @@ -67,7 +68,13 @@ class AddAllowedClassesFix : XoopsFix() { } } -/** `header('HTTP/1.0 404 Not Found')` → `http_response_code(404)`. */ +/** + * `header('HTTP/1.0 404 Not Found')` → `http_response_code(404)`. + * + * `http_response_code()` sets the code but keeps a status line an earlier `header('HTTP/…')` stored, and CGI and + * the built-in server then send that line. The fix is offered only where no other `header()` call of the file + * can store one. + */ class XoopsHttpStatusInspection : XoopsInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { return object : PhpElementVisitor() { @@ -75,19 +82,29 @@ class XoopsHttpStatusInspection : XoopsInspection() { if (!Php.isCall(reference, "header") || reference is MethodReference || skipConvention(reference.containingFile)) return if (reference.parameters.size != 1) return val code = statusOf(reference) ?: return - holder.registerProblem( - reference, - "XOOPS: hard-coded HTTP status line — use http_response_code($code)", - ProblemHighlightType.WEAK_WARNING, - HttpResponseCodeFix(), - ) + val fixable = onlyStatusLine(reference) + val advice = if (fixable) "use http_response_code($code)" + else "http_response_code($code) keeps a status line another header() call of this file may set; convert them together" + val fixes = if (fixable) arrayOf(HttpResponseCodeFix()) else emptyArray() + holder.registerProblem(reference, "XOOPS: hard-coded HTTP status line — $advice", ProblemHighlightType.WEAK_WARNING, *fixes) } } } companion object { private val status = Regex("""(?i)^HTTP/\d(?:\.\d)?\s+(\d{3})\b""") + /** + * `Name: value`, the one argument shape that provably is not a status line (`"$proto 403"` is not provable). + * `Status:` is the CGI spelling of one and outlives `http_response_code()` the same way. + */ + private val field = Regex("""^(?!(?i:status)\s*:)[A-Za-z][A-Za-z0-9-]*\s*:""") fun statusOf(call: FunctionReference): String? = Php.firstStringArg(call)?.let { status.find(it)?.groupValues?.get(1) } + + /** Every other `header()` call of the file sends a plain `Name: value` field. */ + fun onlyStatusLine(call: FunctionReference): Boolean = + Php.calls(call.containingFile, "header").all { other -> + other === call || other is MethodReference || Php.firstStringArg(other)?.let { field.containsMatchIn(it) } == true + } } } diff --git a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html index 1942570..01409bb 100644 --- a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html +++ b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html @@ -3,7 +3,15 @@ XOOPS: Http Status header('HTTP/1.0 404 Not Found') hard-codes the protocol version. Use -http_response_code(404). The response status is the same (still 404); only the protocol version -is left to the server. +http_response_code(404). The status code sent is the same (still 404); the protocol version is left +to the server and a custom reason phrase is not kept. +

One exception: http_response_code() does not replace a status line that an earlier +header('HTTP/…') or header('Status: …') call stored in the same request. +On some server APIs (seen with CGI, and for an HTTP/ line with PHP's built-in server) that earlier +status is then the one sent.

+

The quick fix is therefore offered only when every other header() call of the file sends a plain +Name: value field other than Status:. A file with a second status line, or with a +computed header() argument, is reported without a fix: convert its status lines together. A status line set in another file of the +same request is not seen.

diff --git a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt index 3625ef5..28fd77b 100644 --- a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt +++ b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt @@ -329,6 +329,26 @@ class XoopsQuickFixTest : BasePlatformTestCase() { check(XoopsHttpStatusInspection(), "HttpStatus/status", "modules/demo/images/index.php", 1, "Replace with http_response_code", "modules/demo/images/index.after.php") + /** `header('Content-Type: …')` calls beside the status line cannot store one: the fix stays. */ + fun testHttpStatusLineBesidePlainFields() = + check(XoopsHttpStatusInspection(), "HttpStatus/guard", "modules/demo/include/feed.php", 1, + "Replace with http_response_code", "modules/demo/include/feed.after.php") + + /** `http_response_code()` keeps an earlier `header('HTTP/1.1 200 OK')` line, so neither call gets the fix. */ + fun testHttpStatusLineTwiceIsReportedWithoutFix() = + check(XoopsHttpStatusInspection(), "HttpStatus/twolines", "modules/demo/ajax.php", 2, + "Replace with http_response_code", "modules/demo/ajax.php", remaining = 2) + + /** `header('Status: 403 Forbidden')` is the CGI status field and survives `http_response_code()` as well. */ + fun testHttpStatusLineBesideStatusFieldIsReportedWithoutFix() = + check(XoopsHttpStatusInspection(), "HttpStatus/statusfield", "modules/demo/ajax.php", 1, + "Replace with http_response_code", "modules/demo/ajax.php", remaining = 1) + + /** A computed or interpolated `header()` argument may be a status line: reported without the fix. */ + fun testHttpStatusLineBesideDynamicHeaderIsReportedWithoutFix() = + check(XoopsHttpStatusInspection(), "HttpStatus/dynamic", "modules/demo/ajax.php", 1, + "Replace with http_response_code", "modules/demo/ajax.php", remaining = 1) + fun testSetcookie() = check(XoopsSetcookieInspection(), "Setcookie/cookie", "modules/demo/class/U.php", 1, "Replace setcookie()", "modules/demo/class/U.after.php") diff --git a/src/test/resources/fixtures/HttpStatus/dynamic/modules/demo/ajax.php b/src/test/resources/fixtures/HttpStatus/dynamic/modules/demo/ajax.php new file mode 100644 index 0000000..40c5e39 --- /dev/null +++ b/src/test/resources/fixtures/HttpStatus/dynamic/modules/demo/ajax.php @@ -0,0 +1,7 @@ +header('HTTP/1.0 404 Not Found') hard-codes the protocol version. Use -http_response_code(404). The response status is the same (still 404); only the protocol version -is left to the server. +http_response_code(404). The status code sent is the same (still 404); the protocol version is left +to the server and a custom reason phrase is not kept. +

One exception: http_response_code() does not replace a status line that an earlier +header('HTTP/…') or header('Status: …') call stored in the same request. +On some server APIs (seen with CGI, and for an HTTP/ line with PHP's built-in server) that earlier +status is then the one sent.

+

The quick fix is therefore offered only when every other header() call of the file sends a plain +Name: value field other than Status:. A file with a second status line, or with a +computed header() argument, is reported without a fix: convert its status lines together. A status line set in another file of the +same request is not seen.

""", "XoopsIncludeOnceHeader": r"""

Reports include or require of header.php / footer.php diff --git a/tools/gen_fixtures.py b/tools/gen_fixtures.py index ffe9421..6a68cc7 100644 --- a/tools/gen_fixtures.py +++ b/tools/gen_fixtures.py @@ -879,6 +879,50 @@ class U F["HttpStatus/status/modules/demo/images/index.after.php"] = r""" Date: Wed, 18 Nov 2026 16:12:51 -0500 Subject: [PATCH 3/4] fix(inspections): withhold the HttpStatus quick fix beside an http_response_code() setter --- CHANGELOG.md | 13 +++++++------ INSPECTIONS.md | 9 +++++---- .../support/inspections/XoopsSmallFixInspections.kt | 13 +++++++++---- .../inspectionDescriptions/XoopsHttpStatus.html | 5 +++-- .../kotlin/org/xoops/support/XoopsQuickFixTest.kt | 5 +++++ .../HttpStatus/latersetter/modules/demo/ajax.php | 6 ++++++ tools/gen_descriptions.py | 5 +++-- tools/gen_fixtures.py | 8 ++++++++ 8 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 src/test/resources/fixtures/HttpStatus/latersetter/modules/demo/ajax.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dbafc3..c4d20c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,15 @@ Marketplace plugin `org.xoops.plugin.support`. Versions 0.4.0 to 0.7.2 below are rebuild; it ships as **1.0.0 Alpha 4**, the successor of the 1.0.0 Alpha 3 release of the previous code base (https://github.com/XOOPS/phpstorm-plugin). -## Unreleased +## 1.0.0-alpha.6 — 1.0.0 Alpha 6 — NOT RELEASED - **HttpStatus** offers `http_response_code(404)` as a quick fix only when every other `header()` call of the file - sends a plain `Name: value` field other than `Status:`. `http_response_code()` does not replace a status line that - an earlier `header('HTTP/…')` or `header('Status: …')` call stored in the same request, and some server APIs then - send that earlier status (seen with CGI, and for an `HTTP/` line with PHP's built-in server). A file with a second - status line, or with a computed `header()` argument, is reported without a fix. The description states that the - status code sent by the replacement is the same. + sends a plain `Name: value` field other than `Status:` and the file has no `http_response_code(n)` setter. + `http_response_code()` does not replace a status line that an earlier `header('HTTP/…')` or `header('Status: …')` + call stored in the same request, and some server APIs then send that earlier status (seen with CGI, and for an + `HTTP/` line with PHP's built-in server). A file with a second status line, a setter, or a computed `header()` + argument is reported without a fix. The description states that the status code sent by the replacement is the + same. ## 1.0.0-alpha.5 — 1.0.0 Alpha 5 — Marketplace release 2026-10-26 diff --git a/INSPECTIONS.md b/INSPECTIONS.md index 81cdddb..bc413ac 100644 --- a/INSPECTIONS.md +++ b/INSPECTIONS.md @@ -310,10 +310,11 @@ without the tag (third-party MIT / GPL prose) is only noted, never rewritten. **Fix:** `http_response_code(404)`. The status code sent is the same (still 404); the protocol version is left to the server and a custom reason phrase is not kept. One exception: `http_response_code()` does not replace a status line that an earlier `header('HTTP/…')` or `header('Status: …')` call stored in the same request. On some server APIs -(seen with CGI, and for an `HTTP/` line with PHP's built-in server) that earlier status is then the one sent. The fix is therefore offered -only when every other `header()` call of the file sends a plain `Name: value` field other than `Status:`. A file with a second status line, or with a computed -`header()` argument, is reported without a fix: convert its status lines together. A status line set in another file -of the same request is not seen. +(seen with CGI, and for an `HTTP/` line with PHP's built-in server) that earlier status is then the one sent. The fix +is therefore offered only when every other `header()` call of the file sends a plain `Name: value` field other than +`Status:` and the file has no `http_response_code(n)` setter. A file with a second status line, a setter, or a +computed `header()` argument is reported without a fix: convert its status lines together. A status line set in +another file of the same request is not seen. ### XoopsUnlink — unlink() without is_file() check `unlink($path)` with no `is_file()` / `file_exists()` on the same expression dominating it. A check in the enclosing diff --git a/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt b/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt index 161c86e..10e96c0 100644 --- a/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt +++ b/src/main/kotlin/org/xoops/support/inspections/XoopsSmallFixInspections.kt @@ -84,7 +84,7 @@ class XoopsHttpStatusInspection : XoopsInspection() { val code = statusOf(reference) ?: return val fixable = onlyStatusLine(reference) val advice = if (fixable) "use http_response_code($code)" - else "http_response_code($code) keeps a status line another header() call of this file may set; convert them together" + else "this file sets the status elsewhere too and http_response_code($code) does not replace a stored status line; convert them together" val fixes = if (fixable) arrayOf(HttpResponseCodeFix()) else emptyArray() holder.registerProblem(reference, "XOOPS: hard-coded HTTP status line — $advice", ProblemHighlightType.WEAK_WARNING, *fixes) } @@ -100,10 +100,15 @@ class XoopsHttpStatusInspection : XoopsInspection() { private val field = Regex("""^(?!(?i:status)\s*:)[A-Za-z][A-Za-z0-9-]*\s*:""") fun statusOf(call: FunctionReference): String? = Php.firstStringArg(call)?.let { status.find(it)?.groupValues?.get(1) } - /** Every other `header()` call of the file sends a plain `Name: value` field. */ + /** + * Every other `header()` call of the file sends a plain `Name: value` field, and nothing sets the code with + * `http_response_code(n)`: after `header('HTTP/1.0 404 …')` that setter is ignored, after the fix it would win. + */ fun onlyStatusLine(call: FunctionReference): Boolean = - Php.calls(call.containingFile, "header").all { other -> - other === call || other is MethodReference || Php.firstStringArg(other)?.let { field.containsMatchIn(it) } == true + Php.calls(call.containingFile, "header", "http_response_code").all { other -> + other === call || other is MethodReference || + if (Php.isCall(other, "header")) Php.firstStringArg(other)?.let { field.containsMatchIn(it) } == true + else other.parameters.isEmpty() } } } diff --git a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html index 01409bb..3b9f026 100644 --- a/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html +++ b/src/main/resources/inspectionDescriptions/XoopsHttpStatus.html @@ -10,8 +10,9 @@ On some server APIs (seen with CGI, and for an HTTP/ line with PHP's built-in server) that earlier status is then the one sent.

The quick fix is therefore offered only when every other header() call of the file sends a plain -Name: value field other than Status:. A file with a second status line, or with a -computed header() argument, is reported without a fix: convert its status lines together. A status line set in another file of the +Name: value field other than Status: and the file has no +http_response_code(n) setter. A file with a second status line, a setter, or a computed +header() argument is reported without a fix: convert its status lines together. A status line set in another file of the same request is not seen.

diff --git a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt index 28fd77b..f8d2f02 100644 --- a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt +++ b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt @@ -344,6 +344,11 @@ class XoopsQuickFixTest : BasePlatformTestCase() { check(XoopsHttpStatusInspection(), "HttpStatus/statusfield", "modules/demo/ajax.php", 1, "Replace with http_response_code", "modules/demo/ajax.php", remaining = 1) + /** A later `http_response_code(500)` is ignored after the status line and would win after the fix. */ + fun testHttpStatusLineBesideCodeSetterIsReportedWithoutFix() = + check(XoopsHttpStatusInspection(), "HttpStatus/latersetter", "modules/demo/ajax.php", 1, + "Replace with http_response_code", "modules/demo/ajax.php", remaining = 1) + /** A computed or interpolated `header()` argument may be a status line: reported without the fix. */ fun testHttpStatusLineBesideDynamicHeaderIsReportedWithoutFix() = check(XoopsHttpStatusInspection(), "HttpStatus/dynamic", "modules/demo/ajax.php", 1, diff --git a/src/test/resources/fixtures/HttpStatus/latersetter/modules/demo/ajax.php b/src/test/resources/fixtures/HttpStatus/latersetter/modules/demo/ajax.php new file mode 100644 index 0000000..83cd803 --- /dev/null +++ b/src/test/resources/fixtures/HttpStatus/latersetter/modules/demo/ajax.php @@ -0,0 +1,6 @@ +HTTP/ line with PHP's built-in server) that earlier status is then the one sent.

The quick fix is therefore offered only when every other header() call of the file sends a plain -Name: value field other than Status:. A file with a second status line, or with a -computed header() argument, is reported without a fix: convert its status lines together. A status line set in another file of the +Name: value field other than Status: and the file has no +http_response_code(n) setter. A file with a second status line, a setter, or a computed +header() argument is reported without a fix: convert its status lines together. A status line set in another file of the same request is not seen.

""", "XoopsIncludeOnceHeader": r""" diff --git a/tools/gen_fixtures.py b/tools/gen_fixtures.py index 6a68cc7..9cbd43b 100644 --- a/tools/gen_fixtures.py +++ b/tools/gen_fixtures.py @@ -914,6 +914,14 @@ class U header('HTTP/1.0 404 Not Found'); } """ +# The stored 404 line outlives the later setter; after the fix the setter would win. Reported, no fix. +F["HttpStatus/latersetter/modules/demo/ajax.php"] = r""" Date: Wed, 18 Nov 2026 16:12:51 -0500 Subject: [PATCH 4/4] chore(tools): sync gen_fixtures.py with the committed fixtures --- tools/gen_fixtures.py | 77 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/tools/gen_fixtures.py b/tools/gen_fixtures.py index 9cbd43b..e898e9a 100644 --- a/tools/gen_fixtures.py +++ b/tools/gen_fixtures.py @@ -128,6 +128,7 @@ class Baz extends \XoopsObject require dirname(__DIR__, 2) . '/mainfile.php'; """ F["RootPathGuard/rootpage/modules/demo/functions.php"] = r"""getVar('url'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '">' . $obj->getVar('title') . ''; - $html .= "getVar('image_name'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "'>"; + $html = '' . $obj->getVar('title') . ''; + $html .= "getVar('image_name') . "'>"; $html .= ''; $html .= 'x'; $title = constant('CO_DEMO_FB') . $GLOBALS['xoopsModule']->getVar('dirname'); @@ -633,6 +634,19 @@ class BlockForm extends \XoopsForm $x = 1; } $a = $_REQUEST['a']; +if (isset($_POST[$name])) { + $dyn = 1; +} +if (isset($_POST['submit'], $_POST['passwd'])) { + $both = 1; +} +if (!isset($_POST['step'], $_SESSION['req'])) { + $mixed = 1; +} +$ok = isset($_GET['a'], $_GET['b']); +if (isset($_POST)) { + $always = 1; +} """ F["Superglobal/keyed/modules/demo/include/ajax.after.php"] = r""" $v) { $copy[$k] = $v; } @@ -825,6 +855,9 @@ class Item extends XoopsObject $m = 3; } $all = Request::get('POST', Request::MASK_ALLOW_RAW | Request::MASK_NO_TRIM); +if (empty(Request::get('POST', Request::MASK_ALLOW_RAW | Request::MASK_NO_TRIM))) { + $none = 1; +} foreach (Request::get('default', Request::MASK_ALLOW_RAW | Request::MASK_NO_TRIM) as $k => $v) { $copy[$k] = $v; } @@ -850,12 +883,22 @@ class Item extends XoopsObject class U { - public function defaults($field, string $x): array + public function defaults($field, string $x, array $row): array { + $out = []; $a = unserialize($field->getVar('field_default', 'n')); + foreach ($a as $k => $v) { + $out[$k] = $v; + } $b = unserialize($x, ['allowed_classes' => false]); + $search = unserialize($row['search']); + $search->add(new \Criteria('x', 1)); + $ret['search'] = unserialize($row['search']); + if (is_array(unserialize($x))) { + $out[] = count(unserialize($x)); + } - return [$a, $b]; + return [$out, $b, $search, $ret]; } } """ @@ -863,12 +906,22 @@ class U class U { - public function defaults($field, string $x): array + public function defaults($field, string $x, array $row): array { + $out = []; $a = unserialize($field->getVar('field_default', 'n'), ['allowed_classes' => false]); + foreach ($a as $k => $v) { + $out[$k] = $v; + } $b = unserialize($x, ['allowed_classes' => false]); + $search = unserialize($row['search']); + $search->add(new \Criteria('x', 1)); + $ret['search'] = unserialize($row['search']); + if (is_array(unserialize($x, ['allowed_classes' => false]))) { + $out[] = count(unserialize($x, ['allowed_classes' => false])); + } - return [$a, $b]; + return [$out, $b, $search, $ret]; } } """ @@ -934,6 +987,7 @@ class U F["Setcookie/cookie/modules/demo/class/U.php"] = r""" -

+

on XOOPS

""" F["FileHeader/inlinehtml/modules/demo/class/Snippet.after.php"] = r""" -

+

on XOOPS

""" F["FileHeader/ccby/modules/demo/include/ajax_rating.php"] = r"""