Opened 5 years ago
Closed 5 years ago
#50670 closed defect (bug) (fixed)
Upgrader implementation ignore UpgraderSkin interfaces
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | 5.5 |
| Component: | Plugins | Keywords: | reporter-feedback |
| Focuses: | Cc: |
Description
The new Upgrader implementations like Plugin_Upgrader don't stick to the interfaces they claim to use in terms of the WP_Upgrader_Skin and just directly access properties like $overwrite that are only declared for _some_ implementations.
This is a violation of the open/closed principle and cause code that already extends the UpgraderSkin to break. An example of this can be found here: https://travis-ci.org/github/wp-cli/wp-cli/jobs/708222192#L505-L511
The code should either first check whether the properties/methods that are not part of the interface are actually available or not, or it should only accept specific implementations, or an adapted interface.
Note: See
TracTickets for help on using
tickets.
Seems to happen only for themes. Caused by
Theme_Upgradermissing a conditional that is inPlugin_Upgrader. See https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-theme-upgrader.php#L97 and https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-plugin-upgrader.php#L89.What would be the best fix here? Adding
ppublic $overwrite;toWP_Upgrader_Skinor the conditional, or both? :)