Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue if separate plugins use PUC 2.0 and 2.2 on the same WordPress site #54

Closed
seyfro opened this issue Feb 14, 2016 · 3 comments
Closed

Comments

@seyfro
Copy link

seyfro commented Feb 14, 2016

Hi Yahnis,

I am using PUC 2.2 in my plugin Maps Marker Pro and a user reported an issue if the plugin UpDraftPlus is active, which uses PUC 2.0. When both plugins are active, the update check for UpDraftPlus shows the following errors when using the debug bar actions "request info" for metadata url:

Warning: The URL http://updraftplus.com/plugin-info/?installed_version=2.11.26.0&udm_action=updateinfo&sid=REPLACED&su=REPLACED&sn=REPLACED&slug=updraftplus&e=REPLACED&si=REPLACED does not point to a valid plugin metadata file. HTTP response code is 404 (expected: 200) in /wp-content/plugins/leaflet-maps-marker-pro/inc/class-plugin-update-checker.php on line 255
Failed to retrieve plugin info from the metadata URL.

If I deactivate Maps Marker Pro / PUC 2.2, the "request info" for metadata url works fine. Do you have any idea what might be causing this or how this could be solved? I guessed as our plugins use different PUC versions, there might not be any conflict?
thx for any help!
best,

Robert

@seyfro
Copy link
Author

seyfro commented Feb 14, 2016

I did some more tests and found that if I outcomment the "non-versioned variants of the update checker classes" at the end of the class, both plugins work fine:

/**
 * Create non-versioned variants of the update checker classes. This allows for backwards
 * compatibility with versions that did not use a factory, and it simplifies doc-comments.
 */
/*
if ( !class_exists('PluginUpdateChecker', false) ) {
    class PluginUpdateChecker extends PluginUpdateChecker_2_2 { }
}
if ( !class_exists('PluginUpdate', false) ) {
    class PluginUpdate extends PluginUpdate_2_2 {}
}
if ( !class_exists('PluginInfo', false) ) {
    class PluginInfo extends PluginInfo_2_2 {}
}
*/

As my plugin is named "Maps Marker Pro", my PUC class is first loaded I guess and so when PUC for "UpDraftPlus" is loaded afterwards, the code above has already loaded PUC2.2 which breaks the PUC for UpdraftPlus - at least this is what I think happens.

what would be your advice here, taking into account that multiple PUC instances with different versions might be active on a WordPress site?

@seyfro seyfro changed the title conflict if PUC 2.0 and 2.2 are used issue if separate plugins use PUC 2.0 and 2.2 on the same WordPress site Feb 14, 2016
@YahnisElsts
Copy link
Owner

Are both plugins instantiating a specific version of PUC by using e.g. new PluginUpdateChecker_2_0(...), or are they using PucFactory::buildUpdateChecker which always gives you the newest loaded version? Or some combination of both?

If both plugins explicitly ask for a specific version, there shouldn't be any conflicts (and if there are, then that's a bug in PUC). On the other hand, if a plugin uses the "give me the newest version" approach, then it must be prepared to actually support the newest version of PUC, and things may break if it does not.

I did some more tests and found that if I outcomment the "non-versioned variants of the update checker classes" at the end of the class, both plugins work fine [...]

Ah, it sounds like UpDraftPlus is using the old way to instantiate the update checker that didn't really allow for running multiple different versions at the same time. I should probably deprecate or remove those classes.

In this case, removing that code from your copy of plugin-update-checker.php would probably be the easiest solution.

@seyfro
Copy link
Author

seyfro commented Feb 14, 2016

Thanks for the prompt reply!

You seem to be right - UpDraftPlus is using the following code to load PUC:
$plug_updatechecker = new PluginUpdateChecker($this->url."/plugin-info/", WP_PLUGIN_DIR.'/'.$this->slug.'/'.$this->slug.'.php', $this->slug, 24);

while I am using

$run_PluginUpdateChecker = new PluginUpdateChecker_2_2( 
    $lmm_plugin_updater_url,
    plugin_dir_path( __FILE__ ) . 'leaflet-maps-marker.php',
    'leaflet-maps-marker-pro',
    '12',
    'leafletmapsmarkerpro_pluginupdatechecker'
);

I will remove the "non-versioned variants of the update checker classes" from my PUC class as I do not use them within my plugin and those might only conflict with other plugins.

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

No branches or pull requests

2 participants