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

Notice: The theme metadata is missing the required "details_url" key (when checking for plugin updates) #82

Closed
daigo75 opened this issue Jan 14, 2017 · 11 comments

Comments

@daigo75
Copy link

daigo75 commented Jan 14, 2017

I had the PUC client running fine, with version 3.x, with this simple code:

$update_checker = \PucFactory::buildUpdateChecker(
  'https://my_update_server.com',
  __FILE__,
  'my-plugin-slug'
);

I updated the PUC to version 4, and changed the code as follows:

$update_checker = \Puc_v4_Factory::buildUpdateChecker(
  'https://my_update_server.com',
  __FILE__,
  'my-plugin-slug'
);

Now the updates don't work anymore, and I get the following notice (with backtrace):

Notice: The theme metadata is missing the required "details_url" key. in C:\wamp\www\wordpress_test\wp-content\plugins\test-plugin\vendor\yahnis-elsts\plugin-update-checker\Puc\v4\Metadata.php on line 42
Call Stack
#	Time	Memory	Function	Location
1	0.0037	465760	{main}( )	..\plugins.php:0
2	0.0056	536320	require_once( 'C:\wamp\www\wordpress_test\wp-admin\admin.php' )	..\plugins.php:10
3	4.5537	82239408	do_action( )	..\admin.php:154
4	4.5538	82240096	WP_Hook->do_action( )	..\plugin.php:453
5	4.5538	82240176	WP_Hook->apply_filters( )	..\class-wp-hook.php:323
6	4.7882	86779576	call_user_func_array ( )	..\class-wp-hook.php:298
7	4.7882	86779896	Puc_v4_Scheduler->maybeCheckForUpdates( )	..\class-wp-hook.php:298
8	4.7883	86780464	Puc_v4_UpdateChecker->checkForUpdates( )	..\Scheduler.php:109
9	4.8269	86801896	Puc_v4_Theme_UpdateChecker->requestUpdate( )	..\UpdateChecker.php:204
10	4.8269	86802144	Puc_v4_UpdateChecker->requestMetadata( )	..\UpdateChecker.php:51
11	5.5554	86962080	call_user_func ( )	..\UpdateChecker.php:461
12	5.5626	87015296	Puc_v4_Theme_Update::fromJson( )	..\UpdateChecker.php:461
13	5.5626	87015960	Puc_v4_Metadata::createFromJson( )	..\Update.php:38
14	5.5632	87040920	trigger_error ( )

The trace shows that the Puc_v4_Theme_UpdateChecker gets loaded, but the updates are for a plugin, not a theme. I guess that's the reason why update notifications don't work anymore. How should I fix that?

@YahnisElsts
Copy link
Owner

That sounds like a bug. Could you tell me more about your setup? Specifically, what is the full path to the file where the update checker is initialized, what do the WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants evaluate to, and is this multisite?

If you don't want to post that information on a public site, you can contact me via email: whiteshadow@w-shadow.com

YahnisElsts added a commit that referenced this issue Jan 14, 2017
…n or a theme.

In theory, that should never happen, but the bug reported in #82 shows that it does.
@daigo75
Copy link
Author

daigo75 commented Jan 14, 2017

That's no problem at all. In fact, the data you see above is just slightly "shrunk", but it's almost correct.

  • WP_PLUGIN_DIR: C:\wamp\www\wordpress_test\wp-content\plugins
  • Plugin file: C:\Users\dev\Documents\Projects\WordPress\test-plugin\test-plugin.php

Folder C:\Users\dev\Documents\Projects\WordPress\test-plugin is symlinked to C:\wamp\www\wordpress_test\wp-content\plugins\test-plugin. The __FILE__ constant always resolves to the original path of the folder.

If it may help, the PUC 3.2 works fine with this setup.

YahnisElsts added a commit that referenced this issue Jan 14, 2017
Technically, it's possible to place a plugin anywhere outside the WordPress directory and then create a symlink inside /wp-content/plugins that points to the plugin directory. If the plugin developer then passes the real, symlink-resolved path to the PUC factory, PUC will assume it can't be a plugin because it's not inside the expected directory.
  
Semi-fixed by checking if the input file contains a valid plugin header. However, I would still recommend against using symlinks in this manner because it's likely to cause odd bugs elsewhere. For example, __FILE__ resolves symlinks but plugin_basename() doesn't. This means that the basename that WP sees and the basename you generate in your own code might not match.
@YahnisElsts
Copy link
Owner

Ah, I see. I've patched the factory class to look for valid plugin headers in addition to checking if the file is inside /wp-content/plugins. The notice should be gone now and PUC should use the correct implementation (Puc_v4_Plugin_UpdateChecker). You can use Debug Bar to verify.

Personally, I think using symlinks in that way is a recipe for trouble, but I guess it can be convenient.

@YahnisElsts
Copy link
Owner

Could you please confirm if the patch worked so that the issue can be closed?

@daigo75
Copy link
Author

daigo75 commented Jan 16, 2017

I didn't have the time to test it yet. I will let you know if it's all good as soon as I have the chance to give it a go. Thanks.

@AnthonySaunders
Copy link

I am also seeing this issue when I try to have both a theme that uses the Update Checker as well as a Plugin that uses the update checker, it references the wrong location (using the other file path).

Does this library allow for multiple separate plugins/themes to utilize the checker without interference?

@YahnisElsts
Copy link
Owner

Yes, you can have multiple plugins and/or themes using this library at the same time. You just need to make sure that they're all configured correctly. That means each plugin and theme needs a unique metadata URL and the path to the main plugin/theme file must be correct.

@AnthonySaunders
Copy link

Yes, you can have multiple plugins and/or themes using this library at the same time. You just need to make sure that they're all configured correctly. That means each plugin and theme needs a unique metadata URL and the path to the main plugin/theme file must be correct.

I believe that has been done correctly, I even went so far as to remove the declaration for FILE and replace with a direct path based on get_template_directory() and MY_PLUGIN_DIR, but the Theme still references the directory of the Plugin for Update Checker dependencies (it's using the library there instead of the one in the theme). It seems to parse the plugin directory regardless of it being a theme.

Am I supposed to use the older Theme Library for Themes instead of this library?

@YahnisElsts
Copy link
Owner

Could you perhaps post the update checker initialisation code? If you don't want to make it public, you can email me at whiteshadow@w-shadow.com

it's using the library there instead of the one in the theme

That's normal and shouldn't cause any problems by itself. As you know, it's not possible to have two classes or functions with the exact same name. So if you have multiple identical copies of the library, only one of them will be loaded.

Am I supposed to use the older Theme Library for Themes instead of this library?

That's not recommended. The older library is no longer being maintained. I'm not sure if it's fully compatible with the latest version of WordPress.

@AnthonySaunders
Copy link

Oh good golly. It seems I had my JSON file updated in the incorrect location (the WP environment json was updated, but not theme json at the API that it was receiving the package from).

I apologize sir, and I appreciate your quick and thorough responses.

@YahnisElsts
Copy link
Owner

All right, no problem.

It looks like the person who originally opened this issue has either resolved or abandoned it, so I'm just going to close it now.

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

3 participants