Title: Uninstall includes invalid function
Last modified: June 18, 2021

---

# Uninstall includes invalid function

 *  Resolved [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/)
 * Hey [@shortpixel](https://wordpress.org/support/users/shortpixel/),
 * I’m trying to uninstall this plugin and the uninstallation script is failing.
 * Here is the error log:
 *     ```
       PHP Fatal error:  Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback, function "emr_uninstall" not found or invalid function name in /var/www/html/wp-includes/class-wp-hook.php:292
       Stack trace:
       #0 /var/www/html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
       #1 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action()
       #2 /var/www/html/wp-admin/includes/plugin.php(1286): do_action()
       #3 /var/www/html/wp-admin/includes/plugin.php(967): uninstall_plugin()
       #4 /var/www/html/wp-admin/includes/ajax-actions.php(4581): delete_plugins()
       #5 /var/www/html/wp-includes/class-wp-hook.php(292): wp_ajax_delete_plugin()
       #6 /var/www/html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
       #7 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action()
       #8 /var/www/html/wp-admin/admin-ajax.php(187): do_action()
       #9 {main}
         thrown in /var/www/html/wp-includes/class-wp-hook.php on line 292
       ```
   
 * Could you please resolve this?
 * Thank you!
 * Michelle

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14576111)
 * Hi Michelle,
 * Perhaps the plugin wasn’t installed properly in first place. Could you please
   remove all the files from your file system? The path is /wp-content/plugins/enable-
   media-replace.
 * Let me know if that works.
 * Best,
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14587866)
 * Hi Gerard,
 * I removed the plugin files from my server, re-installed the plugin, and the uninstallation
   script still failed.
 * I’ve edited the code and resolved the issue. Could you please make sure this 
   fix is implemented into the plugin? I found that the plugin uses a namespace,
   yet does not properly refer to this namespace when registering the uninstall 
   function.
 * Current, broken code in main plugin file:
 *     ```
       register_uninstall_hook(__FILE__, 'emr_uninstall');
   
       function emr_uninstall()
       {
               delete_option('enable_media_replace');
       }
       ```
   
 * Fixed, working code:
 *     ```
       register_uninstall_hook(__FILE__, '\EnableMediaReplace\emr_uninstall');
   
       function emr_uninstall()
       {
               delete_option('enable_media_replace');
       }
       ```
   
 * I’ve successfully uninstalled the plugin after making this change to the plugin.
 * Could this please be implemented so plugin uninstallation is possible for others?
 * Thank you!
 * Michelle
    -  This reply was modified 4 years, 11 months ago by [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/).
 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14591035)
 * Hi Michelle!
 * I actually had no issues uninstalling the plugin, and to be honest it is the 
   first time we hear about something like this.
 * Could you perhaps go to Tools > Site Health > Info and copy all the information
   from there and paste it here? I’m thinking there should be something very specific
   to your environment preventing the uninstallation from working.
 * Thank you!
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14594080)
 * Hi Gerard,
 * Providing my entire Site Health info is certainly overkill for a simple PHP namespacing
   issue.
 * However, I can tell you that I just tested installing and uninstalling Enable
   Media Replace on a clean PHP 7.4 environment and experienced no issues.
 * The environment that I experienced the issue on was running PHP 8. I then tested
   installation and uninstallation on a different PHP 8 environment. It had the 
   same issue.
 * Please try testing the plugin uninstallation and namespace fix on an environment
   running PHP 8 and let me know what you find.
 * Cheers!
 * Michelle
 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14599798)
 * Thank you, Michelle.
 * We ask for the Site Health info precisely to know more about your server set 
   up, but luckily you have already spotted the cause 🙂
 * I’ve been able to reproduce it, so I’ll forward this to our developer team and
   once it’s fixed we’ll let you know.
 * Thank you!
 *  [Jarko Piironen](https://wordpress.org/support/users/ipajen/)
 * (@ipajen)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14750394)
 * Any update on this issue? I have the same problem on Version 3.5.0 on a PHP 8.
   x
 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14751756)
 * Hi [@ipajen](https://wordpress.org/support/users/ipajen/),
 * We are still working on it, although there is no ETA. As soon as we have any 
   news we will update this thread 🙂
 * Thanks for your patience!
 *  Plugin Author [Pedro](https://wordpress.org/support/users/petredobrescu/)
 * (@petredobrescu)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14954138)
 * Hello [@ipajen](https://wordpress.org/support/users/ipajen/) and [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   and thanks for reporting this.
 * The necessary fix will come in version 3.6.0, due to be released hopefully next
   week.
 * Many thanks for your patience with this!
    Pedro

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Uninstall includes invalid function’ is closed to new replies.

 * ![](https://ps.w.org/enable-media-replace/assets/icon-256x256.png?rev=1940728)
 * [Enable Media Replace](https://wordpress.org/plugins/enable-media-replace/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/enable-media-replace/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/enable-media-replace/)
 * [Active Topics](https://wordpress.org/support/plugin/enable-media-replace/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/enable-media-replace/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/enable-media-replace/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [Pedro](https://wordpress.org/support/users/petredobrescu/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/uninstall-includes-invalid-function/#post-14954138)
 * Status: resolved