Fix four defects found by real-WordPress integration testing - #4
Merged
Conversation
Installed the v2.0.0 release ZIP into a fresh WordPress 7.0.3 with a
mocked Procore API and exercised every surface. Four defects surfaced
that the unit suite structurally cannot catch, because it shims the
WordPress functions involved.
Pagination was sent to endpoints that have none. Every request carried
page=1, including /projects/{id} and /me. Beyond being meaningless on
the wire, it varied the cache key for what was the same request.
Pagination now applies only where the registry marks an endpoint
paginated, and an explicitly requested page is still honoured.
The REST proxy ignored the configured default company. The route
declares company_id as an integer defaulting to 0, and the client
treated a supplied zero as a deliberate choice rather than an omission,
so the site default never applied and every proxied request failed with
a missing-company error. A zero identifier now falls back to the
configured default, which also makes the proxy behave like shortcodes.
Translations loaded before init. Shortcode definitions carry translated
titles and were built on plugins_loaded, so WordPress 6.7+ emitted a
_load_textdomain_just_in_time notice and silently dropped translations.
Registration is deferred to init, where add_shortcode belongs anyway.
WP-CLI subcommands did not match the documentation. They registered as
cache_clear, cache_warm and reset_token because WP-CLI derives names
from methods and does not convert underscores. Added @subcommand
annotations so the documented hyphenated forms work.
Regression tests added for the two API-layer defects. The other two are
registration-time behaviours that only a real WordPress exhibits.
Verified after the fixes, in the live install: all 24 shortcode
invocations render, no PHP notices or warnings, the token request goes
to login.procore.com, single-record URLs carry no pagination, caching
suppresses the second HTTP call, a simulated outage serves stale cache,
the REST proxy returns records, all six admin tabs render without
leaking the secret or token, the 1.x migration re-encrypts the secret
and discards the stale token, and uninstall removes all 10 options.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Installed the v2.0.0 release ZIP into a fresh WordPress 7.0.3 with a mocked Procore API and exercised every surface. Four defects surfaced that the unit suite structurally cannot catch — it shims the very WordPress functions involved.
Defects
page=1sent to every endpoint, including single-record ones like/projects/{id}and/mecompany_idwas passed explicitlyinit_load_textdomain_just_in_timenotice on WP 6.7+, and translations silently droppedwp procore-connect cache-clear— the documented form — did not existOn #2: the route declares
company_idas an integer defaulting to0, andClient::fetch()usedisset(), so a supplied zero read as a deliberate choice rather than an omission. Zero now falls back to the site default, which also aligns the proxy with shortcode behaviour.On #4: WP-CLI derives subcommand names from method names and does not convert underscores. Fixed with
@subcommandannotations rather than renaming methods.Tests
Regression tests added for the two API-layer defects (62 tests, 277 assertions, all green). Defects 3 and 4 are registration-time behaviours only a real WordPress exhibits, so they are covered by the integration run rather than the unit suite.
Verified in the live install after fixing
login.procore.com— the headline 1.x fix, confirmed livekeep_datahonouredwp procore-connect testpasses all 6 stages and probes all 16 endpoints🤖 Generated with Claude Code