Skip to content

Docs info route can fatal on duplicate bootstrap #110

Description

@chubes4

Problem

The 24-hour PHP error report contains a real fatal from the API plugin:

Cannot redeclare function extrachill_api_register_docs_info_routes() (previously declared in .../extrachill-api/inc/routes/docs/docs-info.php) in .../extrachill-api/inc/routes/docs/docs-info.php:15

Count: 1 in the last 24 hours.

Unlike the other current fatal signatures, this one is not from WP_CLI eval; it terminates while loading a plugin route file.

Code evidence

  • extrachill-api.php:73-90 recursively loads every PHP file below inc/routes/ with require_once $file->getRealPath().
  • inc/routes/docs/docs-info.php:10-15 registers a global callback and declares it unconditionally.
  • A repository grep finds only this declaration and the recursive loader, so the second load likely comes from a duplicate plugin bootstrap or a path-identity/symlink mismatch that bypasses PHP's require_once identity.

Investigation

  1. Capture request/runtime context for this signature and determine how the plugin or route file is loaded twice.
  2. Make plugin bootstrap idempotent at the owning boundary rather than adding scattered function_exists() workarounds to route files.
  3. Audit whether other global route declarations share the same fatal risk.

Acceptance

  • Reproducing a duplicate bootstrap does not redeclare route callbacks or fatal.
  • Normal REST route registration still occurs exactly once.
  • Add a focused regression test for duplicate bootstrap/path loading if the test surface supports it.

Constraints

Use the smallest owner-level fix. Do not introduce a new route registry or wrapper abstraction; WordPress hooks and the existing plugin singleton should remain the primitives.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions