[wp-trac] [WordPress Trac] #59375: Plugin_Upgrader assumption causes incorrect "Activate Plugin" link after plugin installation resulting in "The plugin does not have a valid header" error
WordPress Trac
noreply at wordpress.org
Sun Sep 17 14:23:06 UTC 2023
#59375: Plugin_Upgrader assumption causes incorrect "Activate Plugin" link after
plugin installation resulting in "The plugin does not have a valid header"
error
--------------------------------+------------------------------
Reporter: michelleblanchette | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 6.3.1
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------------+------------------------------
Comment (by michelleblanchette):
The root of the problem is that `get_plugins()` is called with a different
`$plugin_folder` between the two instances discussed.
The function searches one subdirectory deep from the specified
`$plugin_folder` for PHP files with a plugin header.
`Plugin_Upgrader` uses the installed plugin dir as the root search
directory for plugins while `WP_Plugins_List_Table` uses the default
`WP_PLUGIN_DIR` as the root.
**This means that `Plugin_Upgrader` finds plugins one level deeper in the
filesystem than typically found.**
To avoid this issue, included plugin dependencies should be included a
level deeper than the wrapper plugin's root. For example:
- **Wrong:** `hello-pro/hello/hello.php`
- **Correct:** `hello-pro/lib/hello/hello.php`
We likely don't see this issue often because most dependency plugins are
included via Composer, which already nests included dependencies under a
`vendor` directory level.
However, I think the inconsistency in plugin file scanning is still
problematic as it incorrectly produces two different activation links
depending on the context.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59375#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list