Skip to content

Commit 56d0189

Browse files
arraypressclaude
andcommitted
Run the coding standards, and fix what they found
These four ran php -l and the test suite in CI and nothing else, so the WordPress sniffs had never been applied. Adding phpcs surfaced real defects, not just formatting: clear_cache() deleted the _transient_<prefix>_* option rows with a raw DELETE. The matching _transient_timeout_<prefix>_* rows do not carry that prefix, so the LIKE never saw them and every cached lookup orphaned one options row, permanently. It now selects the names and calls delete_transient(), which removes both halves, fires the delete_transient_* hooks, and clears the entry from an external object cache. The same copy-pasted bug was in wp-ipinfo, wp-ipqualityscore and wp-proxycheck. wp-ipqualityscore also forwarded $_SERVER['HTTP_USER_AGENT'] and HTTP_ACCEPT_LANGUAGE straight into the outbound query. WordPress slashes the superglobals, so a header containing a quote was reported to IPQualityScore with a backslash the visitor never sent; it is now unslashed and sanitised. Its date range used date() rather than gmdate(), so a site running ahead of UTC asked for a range ending tomorrow. in_array() calls now pass $strict. A __() call built its message by interpolating a variable into the msgid, which cannot be translated at all; that value moved into a placeholder. Translator comments added throughout, and placeholders ordered where there is more than one. Parameters named after reserved keywords are renamed the way core renamed them ($default -> $default_value). The abstract private method in email-blocklist's CustomLists trait is suppressed rather than changed: private abstract is illegal on a class but legal in a trait, and the sniff does not distinguish the two. Verified it runs on 8.5 before suppressing. CI now runs composer lint and composer format:check alongside the tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tk8y5eZa3CHVVSM6nVxsJw
1 parent 5d0814b commit 56d0189

18 files changed

Lines changed: 4105 additions & 1121 deletions

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
- name: Lint
3737
run: find src tests -name '*.php' -print0 | xargs -0 -n1 -P4 php -l > /dev/null
3838

39+
- name: Coding standards
40+
run: composer lint
41+
42+
- name: Formatting
43+
# Separate from the lint: a clean lint does not mean a clean format
44+
# check, and a green build has to mean both.
45+
run: composer format:check
46+
3947
- name: Tests
4048
# Checked for output, not just exit status. Anything that exits during
4149
# autoload takes phpunit with it before it runs, and the step passes

‎composer.json‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"config": {
2222
"optimize-autoloader": true,
2323
"sort-packages": true,
24-
"preferred-install": "dist"
24+
"preferred-install": "dist",
25+
"allow-plugins": {
26+
"dealerdirect/phpcodesniffer-composer-installer": true
27+
}
2528
},
2629
"minimum-stability": "stable",
2730
"support": {
@@ -42,14 +45,20 @@
4245
"ip-information"
4346
],
4447
"require-dev": {
45-
"phpunit/phpunit": "^12.0"
48+
"phpunit/phpunit": "^12.0",
49+
"phpcompatibility/phpcompatibility-wp": "^2.1",
50+
"squizlabs/php_codesniffer": "^3.13.5",
51+
"wp-coding-standards/wpcs": "^3.4"
4652
},
4753
"autoload-dev": {
4854
"psr-4": {
4955
"ArrayPress\\IPInfo\\Tests\\": "tests/"
5056
}
5157
},
5258
"scripts": {
53-
"test": "phpunit"
59+
"test": "phpunit",
60+
"lint": "phpcs",
61+
"format": "phpcbf --standard=phpcs-format.xml.dist",
62+
"format:check": "phpcs --standard=phpcs-format.xml.dist"
5463
}
5564
}

0 commit comments

Comments
 (0)