Skip to content

[codex] Fix Push MD toolkit loading and clone blockers#49

Merged
artpi merged 5 commits into
trunkfrom
codex/fix-toolkit-function-redeclare
May 15, 2026
Merged

[codex] Fix Push MD toolkit loading and clone blockers#49
artpi merged 5 commits into
trunkfrom
codex/fix-toolkit-function-redeclare

Conversation

@artpi
Copy link
Copy Markdown
Contributor

@artpi artpi commented May 15, 2026

Summary

Fixes the Push MD activation and clone blockers found while testing on WordPress.com staging.

  • Makes PHP Toolkit standalone function files safe to load when another plugin has already loaded the same toolkit functions.
  • Updates Push MD's toolkit bootstrap paths to avoid Composer autoload-file redeclaration crashes.
  • Returns Git protocol error responses for /info/refs failures instead of opaque REST 500s.
  • Exports WordPress posts/pages with empty slugs using stable ID-based fallback paths, e.g. post/post-4937.md, to avoid post/.md collisions.
  • Keeps those fallback paths stable while content remains slugless, without writing fallback names back into WordPress slugs; stale fallback pushes are rejected once WordPress assigns a real slug.
  • Makes the Push MD bootstrap compatibility tests avoid Windows cmd.exe quoting failures.

Root Cause

WordPress.com SH (wpcomsh) already bundles wp-php-toolkit/filesystem, so Push MD's bundled toolkit could redeclare namespaced helper functions during activation. After activation was fixed, authenticated clone exposed two runtime issues: /info/refs errors were surfaced as REST 500s, and draft posts with empty slugs collided on the same export path.

The follow-up fallback-path fix avoids treating generated filenames such as post/post-4937.md as desired WordPress slugs. If WordPress later assigns a canonical slug, Push MD now asks the user to pull the slug-based path before editing rather than silently moving content back to the generated fallback path.

The Windows CI failure came from passing inline PHP snippets through php -r inside a shell command. The tests now write a temporary PHP script and invoke PHP with shell bypassing enabled on Windows.

Validation

  • vendor/bin/phpunit -c phpunit.xml
  • vendor/bin/phpunit -c phpunit.xml components/Filesystem/Tests/FunctionsTest.php
  • vendor/bin/phpunit -c phpunit.xml --filter PMD_Bootstrap_Compatibility_Test plugins/push-md/Tests/
  • vendor/bin/phpunit -c phpunit.xml plugins/push-md/Tests/
  • vendor/bin/phpunit -c phpunit.xml components/Filesystem/Tests/ components/Git/Tests/ components/Zip/Tests/ components/DataLiberation/Tests/ components/Encoding/Tests/
  • composer test
  • php -l plugins/push-md/class-pmd-plugin.php && php -l plugins/push-md/Tests/ExportPathTest.php
  • php -l plugins/push-md/Tests/BootstrapCompatibilityTest.php && php -l components/Filesystem/Tests/FunctionsTest.php
  • vendor/bin/phpcs -d memory_limit=1G plugins/push-md/class-pmd-plugin.php plugins/push-md/Tests/ExportPathTest.php
  • vendor/bin/phpcs -d memory_limit=1G plugins/push-md/Tests/BootstrapCompatibilityTest.php components/Filesystem/Tests/FunctionsTest.php
  • git diff --check
  • rebuilt dist/plugins/push-md.zip and /Users/artpi/Desktop/push-md.zip
  • installed/tested on staging and confirmed git clone succeeds into ~/Desktop/site-title

Note: repo-wide composer lint still exits on pre-existing warning-level findings outside this change; scoped PHPCS for touched files passes.

@artpi artpi changed the title [codex] Fix toolkit function redeclare handling [codex] Fix Push MD toolkit loading and clone blockers May 15, 2026
@artpi artpi marked this pull request as ready for review May 15, 2026 13:01
@artpi artpi self-assigned this May 15, 2026
@artpi artpi requested a review from adamziel May 15, 2026 13:42
@artpi artpi merged commit fe84056 into trunk May 15, 2026
43 of 44 checks passed
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.

1 participant