Skip to content

fix: prevent PHP errors in direct AJAX endpoints#797

Open
anonymoususer72041 wants to merge 1 commit into
opencats:masterfrom
anonymoususer72041:fix/ajax-direct-bootstrap
Open

fix: prevent PHP errors in direct AJAX endpoints#797
anonymoususer72041 wants to merge 1 commit into
opencats:masterfrom
anonymoususer72041:fix/ajax-direct-bootstrap

Conversation

@anonymoususer72041

Copy link
Copy Markdown
Contributor

This PR adds a shared AJAX bootstrap file and uses it from AJAX endpoints that may be accessed directly. Previously, some direct AJAX requests could fail because required constants or classes were not loaded before endpoint-specific code executed.

The change defines the legacy root path consistently for AJAX requests, loads the required core files, and updates affected includes to use root-based paths where needed. This avoids errors such as missing LEGACY_ROOT, missing AJAX interface classes and failed relative includes when endpoints are executed from a different working directory.

Validation was performed by linting the changed PHP files and directly executing the previously problematic template AJAX endpoints. The endpoints now return the expected not-logged-in XML response instead of producing include or bootstrap-related PHP warnings.

@ocjorge

ocjorge commented Jun 17, 2026

Copy link
Copy Markdown

I tested a similar fix in a production-like environment (Debian 12, PHP 8.4.21).
The LEGACY_ROOT bootstrap issue also affected rss/index.php which I patched
separately in my now-closed PR #809. This approach of a shared bootstrap
file is cleaner and more maintainable than individual per-file defines. LGTM.

@RussH RussH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check that ajax/bootstrap.php is included first in each direct AJAX endpoint before any legacy library includes, doesn't seem to be first in every instance.

@anonymoususer72041 anonymoususer72041 added this to the 0.11.0 milestone Jun 24, 2026
@anonymoususer72041

Copy link
Copy Markdown
Contributor Author

Thanks, I checked the changed direct AJAX endpoints again. In this branch, ajax/bootstrap.php is included before the legacy library includes in the affected endpoints.

While checking this, I also noticed that modules/install/ajax/ui.php still contains some pre-existing relative includes such as include_once('lib/SystemUtility.php') in the resume parsing path. Those lines were already present before this branch and were not introduced by this commit. Since they are a separate legacy relative-path issue rather than part of the bootstrap-order change, I would prefer to handle them in a follow-up PR to keep this fix focused.

@anonymoususer72041 anonymoususer72041 requested a review from RussH June 24, 2026 10:14
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.

3 participants