Skip to content

Upgrading WPCS - #17

Closed
pento wants to merge 34 commits into
WordPress:masterfrom
pento:task/upgrade-wpcs
Closed

Upgrading WPCS#17
pento wants to merge 34 commits into
WordPress:masterfrom
pento:task/upgrade-wpcs

Conversation

@pento

@pento pento commented Aug 16, 2018

Copy link
Copy Markdown
Member

Running Travis tests.

@jrfnl

jrfnl commented Aug 16, 2018

Copy link
Copy Markdown
Member

@pento Is the exclude pattern the problem ? If so, what were you trying to exclude specifically there ? Is there a way to make the pattern more specific to get round the issue ? Exclude patterns are basically regular expressions, with just the one extra that * will be automatically converted to the regex .* pattern.

@pento

pento commented Aug 16, 2018

Copy link
Copy Markdown
Member Author

Yeah, the problem is that our phpcs.xml.dist has the rule <exclude-pattern>/build/*</exclude-pattern>. Travis puts everything in the /home/travis/build/WordPress/wordpress-develop folder. Per squizlabs/PHP_CodeSniffer#981, this behaviour is unlikely to change, so the workaround is to change the folder on Travis.

@jrfnl

jrfnl commented Aug 16, 2018

Copy link
Copy Markdown
Member

the problem is that our phpcs.xml.dist has the rule /build/*

But what is that rule trying to exclude ? If I understand that, then I can help you devise a better exclude-pattern which prevents the problem from occurring in the first place.

Something like the below might already be enough to fix this:

<exclude-pattern>(?<!/travis)/build/*</exclude-pattern>

@pento

pento commented Aug 16, 2018

Copy link
Copy Markdown
Member Author

It's to exclude the build directory that's created when you run grunt build: no point in checking code that's just copied from the src directory.

@jrfnl

jrfnl commented Aug 16, 2018

Copy link
Copy Markdown
Member

@pento In that case, the regex exclude pattern I posted above should do the trick.

@jrfnl

jrfnl commented Aug 16, 2018

Copy link
Copy Markdown
Member

@pento Cricky.. just thinking the < in the look behind might not be accepted in XML. You could try passing it as:

<exclude-pattern>(?&lt;!/travis)/build/*</exclude-pattern>

... and see if that works. If not, I'll come up with a different regex.

@pento

pento commented Aug 16, 2018

Copy link
Copy Markdown
Member Author

Yup, that worked. 🙂

@jrfnl

jrfnl commented Aug 16, 2018

Copy link
Copy Markdown
Member

@pento Just thinking - we could probably make it even simpler (and more easily understandable for others), by using

<exclude-pattern type="relative">^build/*</exclude-pattern>

The relative in this case, means relative to where the ruleset is placed (not relative to basepath which is only used for trimming the filepaths down).

I would give you a link to the PHPCS wiki which explains this feature, however, that page is (temporarily) inaccessible.

@pento

pento commented Aug 17, 2018

Copy link
Copy Markdown
Member Author

Okay, I'm happy with the state of this. I'm going to merge it into Core later today, we can work on getting the custom bits into WPCS 1.1, and then we can easily upgrade Core again.

@pento pento closed this Aug 17, 2018
@pento
pento deleted the task/upgrade-wpcs branch August 17, 2018 01:28
ryelle added a commit to circlecube/wordpress-develop that referenced this pull request Sep 2, 2021
…-wp-pointer

update wp-pointer colors to use custom properties
blitzy Bot pushed a commit to Blitzy-Sandbox/blitzy-wordpress that referenced this pull request Jul 8, 2026
Resolves all 24 findings from the FINAL full-project review (docs/index.md
boundary). Every fix preserves byte-identical functional output, public APIs,
hook contracts, REST routes/schemas, and enqueue semantics (minimal-diff,
evidence-first).

Code fixes (implemented):
- F-005 (CRITICAL, #3): cache-first/batch-primed prepare_item_for_response in
  class-wp-rest-posts-controller.php matching the passing sibling controllers;
  fixed a discovered attachment cache-key collision by scoping the media slice
  under object_type 'attachment-media' (281 posts + 129 attachment tests pass).
- F-006 (WordPress#12): registered-handle memoization (get_registered_handles,
  count-snapshot self-healing) in class-wp-dependencies.php (340 tests pass).
- F-003 (WordPress#9): WP_Metadata_Lazyloader $settings expanded to 'post'/'user'
  (additive; reachable via queue_objects()).
- Observability (CRITICAL, #1): install_mu_plugins() wires server-timing.php +
  clear-cache.php into the benchmark runtime in run-baseline.sh/run-optimized.sh.
- Reproducibility (CRITICAL, #2): committed representative raw inputs
  (before/after JSON) + fail-loud missing-baseline guard in
  generate-diff-report.js; report regenerates byte-identically.
- Quality gate (CRITICAL, WordPress#5): refactored two no-nested-ternary JS-lint errors
  into a formatSignificantLabel() helper (the alleged PHPStan error was
  empirically non-reproducible; composer phpstan is green).
- KPI 3 (WordPress#6): clarified the admin.test.js instrument as runtime browser-measured
  gzipped transfer (PerformanceResourceTiming.transferSize); honestly NOT met
  (17.97%), delivered via F-007 conditional loading.
- Accessibility (WordPress#21): prefers-reduced-motion accommodation in the reveal.js deck
  (Rule-4 verbatim settings preserved).

Documented Rule-2 deviations (files intentionally unchanged, with rationale):
- WordPress#4 F-009 webpack splitting (DEV-03): admin JS is Grunt-uglified; webpack emits
  only 4 independent media bundles; splitChunks would break the enqueue graph for
  zero KPI benefit. development.js split-disable is correct.
- WordPress#7 default-filters.php (DEV-04): AAP target mandates "465 registrations
  preserved"; deferral violates hook-contract preservation.
- WordPress#8 class-wp-query.php (DEV-05): memoization/priming is pre-existing WP 6.1+
  baseline; F-002 delivered in composed meta-query/wpdb/meta classes.
- WordPress#10 general-template.php, WordPress#11 script-loader.php, WordPress#13 ajax-actions.php (DEV-06):
  no byte-identical-safe, evidence-backed seam at each file's own layer.

Documentation honesty rebuild (WordPress#14-WordPress#17, WordPress#19, Rules 1-3):
- Rebuilt decision-log-and-traceability.md from git-diff ground truth (correct
  10-controller list, accurate per-feature counts, DEV-01..DEV-10, 100%
  traceability); corrected project-guide.md, technical-specifications.md,
  index.md, performance-dashboard.md, and the deck to reflect the actual
  implemented state and baseline-parity gate status.

Scope accounting (WordPress#20): three added test files + signatures.php test-alignment
(F-003, DEV-10) accounted in traceability §4.3.

Build discipline (WordPress#18): grunt build --dev succeeds and dirties zero tracked
files (compiled outputs are gitignored).

Test evidence (WordPress#19): PHPStan green; PHPCS 0 errors / 0 new warnings (BASE-parity
proven); JS lint green; full PHPUnit suite 28994 tests with only 8 pre-existing
environmental tzdata failures (deprecated zones absent from container tzdata),
all in unchanged files and baseline-identical.
blitzy Bot pushed a commit to blitzy-research/wordpress-develop that referenced this pull request Aug 8, 2026
…workstreams

Addresses all 51 findings from code review o006 (34 numbered, 11 module,
6 security). Two of the six binding targets now pass and every unmet target
improved; the four that remain short are documented against the AAP sections
that exclude the work required to close them.

Implemented, not merely disclosed:

* wp-settings.php: defer the two admin-only files the plan mandates off the
  front-end path. wp-admin/includes/plugin.php is required only when a plugin
  is active or is_admin(); WP_Site_Health is instantiated only for admin, cron
  and WP-CLI. 6,533 lines stop being tokenized on every front-end request, and
  the Site Health class map entry stops being a zero-delta entry. (WordPress#13, A2)
* capabilities.php: deliver the map_meta_cap() memoization the plan prescribes
  and the previous round withdrew. Branch-scoped to the four post arms, keyed on
  every input that can change the result including the post type's cap object,
  bypassed when a non-core map_meta_cap callback is present, and the filter still
  runs on every call. Measured -8.8% cold / -8.0% warm over 7/7 interleaved
  rounds. (WordPress#12)
* autoload.php: is_readable() replaces file_exists() at both guards so an
  existing-but-unreadable file degrades instead of raising an uncatchable
  E_COMPILE_ERROR; the path-confinement pattern is anchored with \z so a value
  carrying a trailing newline cannot pass a guard advertised as canonical;
  CompileError is re-raised while any other Error is reported under WP_DEBUG
  through wp_trigger_error(). (WordPress#15, WordPress#16, WordPress#17, S2, S3)
* formatting.php: scope the emoji gate to the front end, the only context the
  plan measured, pass the context to the filter, and restore trunk's $printed
  ordering. (WordPress#20, WordPress#21, C1)
* script-loader.php: publish the documented one-line rollback for the Command
  Palette gate and name both consequences - wp.commands/wp.coreCommands
  undefined and the Ctrl+K button absent - in the predicate's docblock.
  (WordPress#18, WordPress#19, B1)
* class-wp-object-cache.php: stop stats() emitting an advisory paragraph on the
  default path, so its public output matches trunk exactly. (WordPress#23, WordPress#22, D1)
* Gruntfile.js: move verify:build-guards out of every production build into
  precommit and prerelease, and classify ENOENT at both host-php spawn sites.
  (WordPress#24, WordPress#25)
* server-timing.php: refuse to serve the reset endpoint when the pre-existing
  unauthenticated clear-cache.php is provisioned beside it. (WordPress#29, S5)
* admin.test.js / utils.js: collect JavaScript by Content-Type as well as by
  .js pathname, which was under-counting by ~99,019 gzipped bytes in both arms
  whenever CONCATENATE_SCRIPTS is active. (WordPress#30, WordPress#31)
* generate-autoload-classmap.php: @return never on the fail-closed exit.
  Clears the one PHPStan error the file had. (WordPress#28)
* build-guards.test.js: prettier-clean. (WordPress#33)

New committed coverage for behaviour that shipped with none - 34 cases:
tests/phpunit/tests/dependencies/commandPalette.php (7),
tests/phpunit/tests/formatting/emojiGate.php (6),
tests/phpunit/tests/cache/objectCacheGroupStats.php (8),
tests/phpunit/tests/user/mapMetaCapMemoization.php (13). (B2, C2, D1)

docs/performance-optimization-report.md rewritten against a fresh before/after
pair captured under one interpreter regime with 40 samples per metric per
scenario over 18 scenarios. Every stale artifact reference, blob id and digest
is replaced; the ephemeral self-check machinery is replaced with in-tree
re-runnable commands; the emoji, files-loaded, byte-size, PHPStan/PHPCS
coverage and 216-construct claims are corrected; a Security invariants section
records Gate 7 and findings S1, S4 and S6; and a before/after loading-flow
diagram is added. (WordPress#1-WordPress#11, WordPress#14, WordPress#26, WordPress#27, WordPress#31, WordPress#32, WordPress#34, A1, A3, C3, H1, S1, S4, S6)

Verification: PHPUnit 29,165 single-site and 29,957 multisite with 0 failures
and 0 errors, warning and skip counts identical to the pre-change baseline;
QUnit 456/456; E2E exit 0; performance suite 820 passed in both arms and
compare-results.js exit 0; PHPStan exit 0 over 1,414 files; PHPCS exit 0;
production and dev builds clean with no drift and build/ byte-identical to src/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants