Skip to content

fix: prevent fatal error when uninstalling the plugin - #329

Merged
justlevine merged 3 commits into
mainfrom
fix/uninstall-failure
Oct 16, 2026
Merged

justlevine merged 3 commits into
mainfrom
fix/uninstall-failure

Conversation

@Kallyan01

@Kallyan01 Kallyan01 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

What

Fixes a fatal error that stopped OneSearch from uninstalling.

Why

WordPress runs uninstall.php without loading the main plugin file, so none of the constants from onesearch.php exist at that point. The uninstaller loads the plugin's autoloader to clean up Algolia, and Autoloader::autoload() builds its paths from ONESEARCH_DIR. The result is a fatal error:

PHP Fatal error: Uncaught Error: Undefined constant "OneSearch\ONESEARCH_DIR" in .../inc/Autoloader.php:39

Related Issue(s):

How

AI Disclosure

Testing Instructions

Screenshots

N/A

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

Copilot AI balanced review requested due to automatic review settings October 12, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes correctly address the missing constant while preserving local cleanup on remote failures.

0 open findings

What changed in this PR

Prevents uninstall failures when the main plugin bootstrap and its constants are unavailable.

Changes:

  • Defines ONESEARCH_DIR before loading the autoloader.
  • Allows local cleanup to continue if Algolia cleanup fails.
File Description
uninstall.php Makes dependency loading and cleanup resilient during uninstall.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Kallyan01 Kallyan01 changed the title fix: prevent fatal error when uninstalling the plugin fix: prevent fatal error when uninstalling the plugin Oct 12, 2026
@codecov-commenter

codecov-commenter commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.27%. Comparing base (78d47cb) to head (692b534).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
uninstall.php 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #329      +/-   ##
============================================
+ Coverage     87.83%   89.27%   +1.43%     
  Complexity      667      667              
============================================
  Files            33       23      -10     
  Lines          2951     2302     -649     
  Branches        180        0     -180     
============================================
- Hits           2592     2055     -537     
+ Misses          297      247      -50     
+ Partials         62        0      -62     
Flag Coverage Δ
jest ?
unit 89.27% <0.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
uninstall.php 0.00% <0.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread uninstall.php Outdated
@Kallyan01
Kallyan01 requested a review from justlevine October 14, 2026 20:23

@justlevine justlevine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚀

@justlevine
justlevine merged commit 98bd33f into main Oct 16, 2026
18 checks passed
@justlevine
justlevine deleted the fix/uninstall-failure branch October 16, 2026 14:27
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.

4 participants