Skip to content

Conversation

@obenland
Copy link
Member

Follow-up to #1683

Proposed changes:

  • Move require_once statement for wp-admin/includes/file.php to the method where get_home_path() is actually called
  • Fixes fatal error: "Call to undefined function get_home_path()"

Bug: The LiteSpeed Cache integration loads wp-admin/includes/file.php in the append_with_markers() method, but get_home_path() is called in get_htaccess_file_path(). When get_htaccess_file_path() is called directly (without going through append_with_markers() first), the file isn't loaded, causing a fatal error.

Fix: Move the require_once statement from append_with_markers() to get_htaccess_file_path(), right before get_home_path() is used. This ensures the dependency is always loaded before use.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

Review the code change to verify:

  1. The require_once ABSPATH . 'wp-admin/includes/file.php'; statement is now in get_htaccess_file_path() where get_home_path() is called
  2. The statement was removed from append_with_markers() where it wasn't directly needed
  3. This ensures the dependency is loaded before use in all code paths

Changelog entry

  • Automatically create a changelog entry from the details below.

Move require_once statement for wp-admin/includes/file.php from append_with_markers() to get_htaccess_file_path() where get_home_path() is actually called. This ensures the dependency is loaded before use, preventing fatal errors when get_htaccess_file_path() is called directly.
Copilot AI review requested due to automatic review settings October 28, 2025 20:46
@obenland obenland self-assigned this Oct 28, 2025
@obenland obenland requested a review from pfefferle October 28, 2025 20:46
@github-actions github-actions bot added the [Focus] Compatibility Ensuring the plugin plays well with other plugins label Oct 28, 2025
@obenland obenland added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Oct 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the placement of a require_once statement that ensures the WordPress get_home_path() function is available. The statement is moved from the append_with_markers() method to the get_htaccess_file_path() method, which is the actual function that uses get_home_path().

Key Changes:

  • Moved the require_once statement for wp-admin/includes/file.php from append_with_markers() to get_htaccess_file_path()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Added a require_once statement for 'wp-admin/includes/file.php' to guarantee WP_Filesystem() is declared before calling it. This prevents potential errors if the function is not already available.
@obenland obenland merged commit fc46599 into trunk Oct 29, 2025
13 checks passed
@obenland obenland deleted the fix/litespeed-cache-wp-cli branch October 29, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Compatibility Ensuring the plugin plays well with other plugins Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants