Skip to content

fix(cleanup): delete Imagify transients on deactivation and uninstall#1027

Open
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-942-cleanup-transients
Open

fix(cleanup): delete Imagify transients on deactivation and uninstall#1027
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-942-cleanup-transients

Conversation

@faisalahammad
Copy link
Copy Markdown

@faisalahammad faisalahammad commented Feb 27, 2026

Summary

Deletes imagify_check_api_version and other missing transients on plugin deactivation and uninstall, so no Imagify data is left behind in the database.

Fixes #942

Problem

The imagify_check_api_version site transient (set by Imagify_Requirements::is_api_up()) persists in the database after deactivating or deleting Imagify. A few other transients (imagify_check_licence_1, imagify_bulk_optimization_result) were also missing from cleanup hooks.

Solution

Added the missing delete_site_transient() / delete_transient() calls to both the deactivation hook and uninstall.php. This follows the existing pattern used by Bulk::delete_transients_data().

Changes

imagify.php

Before:

function imagify_deactivation() {
    if ( ! imagify_pass_requirements() ) {
        return;
    }

    /** Imagify deactivation. */
    do_action( 'imagify_deactivation' );
}

After:

function imagify_deactivation() {
    if ( ! imagify_pass_requirements() ) {
        return;
    }

    // Clean up site transients.
    delete_site_transient( 'imagify_check_api_version' );
    delete_site_transient( 'imagify_check_licence_1' );

    /** Imagify deactivation. */
    do_action( 'imagify_deactivation' );
}

Why: These site transients are set by Imagify_Requirements::is_api_up() and is_api_key_valid() but were never cleared on deactivation. Placing the cleanup before do_action( 'imagify_deactivation' ) ensures they're removed regardless of what other hooks do.

uninstall.php

Added two missing lines to the existing transient cleanup block:

 delete_site_transient( 'imagify_check_licence_1' );
+delete_site_transient( 'imagify_check_api_version' );
 delete_site_transient( 'imagify_user' );
 delete_transient( 'imagify_stat_without_next_gen' );
+delete_transient( 'imagify_bulk_optimization_result' );
 delete_transient( 'imagify_attachments_number_modal' );

Testing

Manual Testing

Test 1: Deactivation cleanup

  1. Activated Imagify, visited settings to trigger imagify_check_api_version transient
  2. Verified transient exists via Transients Manager
  3. Deactivated Imagify
  4. Result: imagify_check_api_version and imagify_check_licence_1 are deleted ✅

Test 2: Uninstall cleanup

  1. Re-activated, triggered transients again
  2. Deleted Imagify entirely
  3. Result: All Imagify transients removed from the database ✅

Screen recording

Screen recording: https://videos.faisalahammad.com/recordings/J88o1IstjuKlmsUkRyld

Plugin build

imagify-fix-issue-942.zip

- Add delete_site_transient() for imagify_check_api_version and
  imagify_check_licence_1 in imagify_deactivation()
- Add delete_site_transient( 'imagify_check_api_version' ) to uninstall.php
- Add delete_transient( 'imagify_bulk_optimization_result' ) to uninstall.php

Fixes wp-media#942
Copy link
Copy Markdown

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 improves Imagify’s cleanup behavior by removing additional transients during plugin deactivation and uninstall, addressing cases where certain cached API/license/bulk-status values were previously left in the database (Fixes #942).

Changes:

  • Delete imagify_check_api_version and imagify_check_licence_1 site transients on plugin deactivation.
  • Delete imagify_check_api_version (site transient) and imagify_bulk_optimization_result (transient) during uninstall cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
imagify.php Adds deletion of two site transients during the deactivation hook.
uninstall.php Extends uninstall transient cleanup to include API-version and bulk-result transients.

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

Comment thread imagify.php
Comment thread uninstall.php
@remyperona remyperona added this to the 2.2.8 milestone Apr 28, 2026
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.

Imagify transients shall be removed after deleting imagify

3 participants