architecture: extract Cardea_Comment_Gate, single version source, unified excludes, shared e2e fixtures - #3
Merged
Conversation
…fied excludes, shared e2e fixtures
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2 (security). Fixes the architecture findings from the review in #1 (A1-A6) and is behavior-neutral (same suite results, no new findings).
Changes
A1 + A2 —
Cardea_Coreis now a pure PoW domain (includes/class-cardea-core.php, newincludes/class-cardea-comment-gate.php): the comment-form gate (preprocess_comment), the REST gate (rest_pre_insert_comment), all$_POSTreads andwp_diecalls moved to a newCardea_Comment_Gateclass that usesCardea_Core.Cardea_Coreno longer touches any request superglobal orwp_die— it holds challenge generation, HMAC signing, difficulty, time window, the challenge-string builder, the solution verifier, the replay store, and thecardea/v1/challengeREST endpoint.A3 — single source of truth for the version: the PHPUnit bootstrap now parses
CARDEA_VERSIONfrom thecardea.phpheader (preg_match('/^\s*\*\s*Version:\s*(\S+)/m', ...)/ falls back0.0.0) instead of re-typing it. The two copies can no longer drift.A4 — dead PSR-4 mapping removed:
composer.jsondropped theautoloadblock that mappedCardea\\ontoincludes/while the files declare no namespace. (See pushback below on namespacing itself.)A5 — one exclusion list (
Makefile):EXCLUDE_DIRS/EXCLUDE_FILES/EXCLUDE_GLOBSfeed bothmake package(zip) andmake sync-svn(rsync). Verified:make packagestill produces the same 13-filedist/cardea.zip;make -n sync-svnunchanged against the 1.0.1 SVN working copy.A6 — e2e fixtures: six duplicated Playground bootstraps (5 specs) now use
tests/e2e/support/playground.js(startPlayground({ login, postTitle, extraRunPHP })); WP version overridable viaWP_VERSIONenv (defaultlatest).Pushback (per #1)
Cardea_Core/Cardea_Comment_Gateto aCardea\\namespace is an unnecessary compat-breaking diff for a released plugin (hooks/objects are referenced by class name across the plugin and in tests). The dead autoload mapping is removed; the namespacing itself is deferred (or declined).Test evidence
Full suite green (Docker,
make test+make lint):tests/phpunit/Cardea_Comment_Gate_Test.php(17 tests, incl. mock-WP_REST_RequestREST parity);Cardea_Core_Test.phpstays pure domain (16 tests)NonceVerificationscoping fix surfaced by the new file)