deliciousbrains / wp-migrate-db

WordPress plugin that exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer.
https://wordpress.org/plugins/wp-migrate-db/
341 stars 515 forks source link

Fatal error in wp-migrate-db-pro-compatibility.php #143

Open rosswintle opened 1 year ago

rosswintle commented 1 year ago

Hi folks,

This may be related to #128. And it's a weird edge case, so probably low priority.

I have a local dev server with an old verson of Migrate Pro (v2.0.2)

I wanted to test something with Migrate Lite, so I disabled Pro and installed the current versions of Migrate Lite from the repo (v2.5.0)

When I visited the settings page it installed wp-migrate-db-pro-compatibility.php in my mu-plugins folder.

This then fatal-errored with:

Fatal error: Uncaught Error: Call to undefined method DeliciousBrains\WPMDB\Common\Compatibility\Compatibility::register() in <path>/wp-content/mu-plugins/wp-migrate-db-pro-compatibility.php:45
Stack trace:
#0 <path>/wp-settings.php(372): include_once() 
#1 <path>/wp-config.php(78): require_once('/Users/rosswint...') 
#2 <path>/wp-load.php(50): require_once('/Users/rosswint...') 
#3 <path>/wp-admin/admin.php(34): require_once('/Users/rosswint...') 
#4 <path>/wp-admin/tools.php(40): require_once('/Users/rosswint...') 
#5 /Users/<username>/.composer/vendor/laravel/valet/server.php(234): require('/Users/<username>...') 
#6 {main}
thrown in /Users/rosswintle/db/migrate-test/wp-content/mu-plugins/wp-migrate-db-pro-compatibility.php on line 45

I can repeatedly recreate this in this WordPress install by:

I've not got time to dig into code and figure out what's going on. But hopefully this report is useful.

rosswintle commented 1 year ago

As a follow up, I've just updated and I don't see this issue with Pro v2.5.0 and Lite v2.5.0

It looks like the Lite compatibility file isn't compatible with older versions of Pro.

I'm not sure why anyone other than me would have Lite installed alongside an old version of Pro, but seems like something we could check for and not fatal on.

philwp commented 1 year ago

@rosswintle we changed the way that we call the compatibility plugin as part of some security tightening to the plugin.

If you delete the wp-migrate-db-compatibiity.php file from the mu-plugins dir and then reactivate the older version of the plugin, it will regenerate the compatibility plugin that works with the older version. This should only be an issue if the versions are on either side of 2.3.4 as this is when we made this change.

rosswintle commented 1 year ago

Fair enough. It's pretty edge-casey.

I've fixed my issue.

I reported this in case you wanted to add a test for the existence of the class/method before calling it and thus avert a fatal.