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

Add updating workflow #381

Merged
merged 13 commits into from
May 3, 2015
Merged

Add updating workflow #381

merged 13 commits into from
May 3, 2015

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented May 3, 2015

Closes #192, #350, #351

The commits have been set up to facilitate easier code review as these are quite significant changes. Please see the individual commit messages for detailed information on what I've changed, how and why.

Functional highlights:

  • Updating can now be done from the TGMPA screen, both on individual plugins as well as in bulk - this will take into account WP repo updates as well as updates for plugins which are bundled or come from external sources where a minimum version is set which is higher than the current version.
  • Users will be notified of available updates.
  • TGMPA screen now has four views: all, to install, update available and to activate
  • TGMPA screen now has - on selected views - an extra column showing relevant plugin version information.
  • TGMPA screen status column will show both install/activate as well as update status (cumulative).
  • If a plugin requires a certain minimum version of a plugin and the currently installed version does not comply, activation will be blocked until the user has upgraded. If the plugin is already active, it will not be deactivated however.
    • If the required plugin version itself requires a higher WP version than the currently installed WP, upgrade will be blocked
  • The plugin action links on the WP native plugins page will reflect this too - including disabling deactivation if force_activation is true for a plugin

Branch has been tested, but further testing is very welcome /cc @duckzland @swiderski
Testing on setups with non-direct filesystem access would be much appreciated (should work, but rather would get it confirmed).

Should work with WP 3.7 and higher.

Props [Zauan/Hogash Studio], [Christian], [Franklin Gitonga], [Jason Xie], [swiderski] for the inspiration.

Screenshots:

screenshot
screenshot

jrfnl added 11 commits May 3, 2015 03:10
- `get_tgmpa_status_url()` -> url to the tgmpa page for a certain view
- `tgmpa_complete()` -> do we have actions on the registered plugins or not ?
- `is_plugin_installed()`
- `is_plugin_active()` -> similar to WP native `is_plugin_active()`
- `can_plugin_update()` -> check whether the minimum WP requirement for a plugin update has been met
- `can_plugin_activate()` -> check whether a plugin complies with an optionally set minimum version of the plugin and is currently inactive
- `get_installed_version()` -> get the version nr of an installed plugin
- `does_plugin_require_update()` -> check whether a plugin complies with an optionally set minimum version of the plugin
- `does_plugin_have_update()` -> check whether there are updates available for a plugin, required or otherwise
- `get_upgrade_notice()` -> get the upgrade notice from the plugin readme if supplied by the plugin author
- `get_plugins()` -> wrapper for WP native `get_plugins()`
Most significant changes:
- added views: 'to install', 'update available', 'to activate'
- simplified the `_gather_plugin_data()` method by abstracting parts of it to separate methods
- reverted the change to the constructor arguments from PR #227 as that breaks things, instead overload the `get_table_classes()` method which archives the same effect as PR #227 intended
- added 'version' column and a method to generate the output for it
- made column to display dependent on the chosen view
- abstracted the plugin row actions to a separate method
- made the row actions always visible (was on hover), similar to the WP native plugins table
- added upgrade notice information to a plugin row if available
Most significant changes:
- Changed the class we are overloading from WP_Upgrader to Plugin_Upgrader
- The `run()` method was a copy of the original from WP_Upgrader (not overloaded in Plugin_Upgrader) with some additional code for automatic activation. This activation code has now been abstracted to its own method which we hook into a filter within the `run()` method (yeah, I know, abusing a filter for an action, but makes for so much cleaner code). We still overload run but only to reset any potential fall-out from the filter abuse after the parent function has run.
- The `bulk_install()` method is largely a copy of the `bulk_upgrade()` method with customizations to allow for new installs rather than upgrades. This method has been updated to be completely in line with the current (4.2.1) implementation in core with clear comments on where it differs for ease of future updating.
- Removed the `plugin_info()` and `add_install_strings()` methods as those were copied from Plugin_Upgrader and as we're now extending that class, we don't need the copies anymore.
…ades.

Most significant changes:
- add install_type as part of the arguments passed so we know whether we are dealing with a bulk install or bulk update
- Both the `before()` and `after()` methods were copies of the original with only the a different title. As we can set the title as an optional argument, there was no need to copy the code, so largely simplified the overloaded methods.
- Updated the `bulk_footer()` method to be in line with the way things are done in the base class
- Deprecated two unnecessary methods
…to deal with updates as well

Most significant changes:
- Add if/else switch code to deal with both install as well as update requests
- Introduced new `inject_update_info()` method which adjusts the update_plugins transient to contain information on external and pre-packaged plugins as WP checks the transient before executing an update
- Introduced new `get_plugins_api()` method to retrieve information from the wp.org repo API and apply some minimalistic caching for that.
- Re-evaluated what information really needs to be passed to the Upgrader classes and how and implement this properly.
- Updated the `maybe_adjust_source_dir()` to deal with the changes in passed information
- Only update a plugin if the new version is compatible with the WP version installed
Most significant changes:
- Adjusted remaining functions to use the new abstracted logic methods
- Leaner loading - only hook our actions in if we actually have something to do, also allows for some simplification of the `admin_menu()` method
- activation methods now take WP version into account
- Introduced the update related text strings and aligned the text strings in example.php with the ones in the main file
- Added call to action for TGMPA native translations to the example file and created initial .pot file for people to use to send in translations. Take note: this file is to stay in the develop branch for now and should not be included in master yet.
…ion and add an update link depending on:

- activate: whether the plugin complies with minimum required version
- deactivate: 'force_activation' setting
- update link: whether an update is required by the theme
@KingYes
Copy link
Contributor

KingYes commented May 3, 2015

+1 good job

@jrfnl jrfnl mentioned this pull request May 3, 2015
@duckzland
Copy link

@jrfnl got a bug :
click begin updating -> click return to plugin installer -> do bulk install submit -> click return to dashboard = you got "You do not have sufficient permissions to access this page."

@GaryJones
Copy link
Member

General comment - do all of the new methods need to be public? Could some be protected?

@jrfnl
Copy link
Contributor Author

jrfnl commented May 3, 2015

General comment - do all of the new methods need to be public? Could some be protected?

Unfortunately yes. For the TGMPA class methods - nearly all of them are also called from the List_Table/Bulk_Installer/Bulk_Skin classes and therefore those need to be public.

For the new methods in the List_Table class - the ones overloading methods in the WP native class have to be public for the code to be compatible with WP < 4.x The scope keywords were left off in the WP versions before that time, so you'd get a E_STRICT warning about the scope being wrong if they are not public.

@nomansbeauty
Copy link

great work guys, we will test it out soon. Thanks 👍

@jrfnl
Copy link
Contributor Author

jrfnl commented May 3, 2015

@jrfnl got a bug :
click begin updating -> click return to plugin installer -> do bulk install submit -> click return to dashboard = you got "You do not have sufficient permissions to access this page."

@duckzland I've looked into this and believe I've been able to reproduce the issue and fix it. Could you please test again ?

@jrfnl
Copy link
Contributor Author

jrfnl commented May 3, 2015

@GaryJones Thanks for reviewing. I've made the necessary adjustments & pushed.

GaryJones added a commit that referenced this pull request May 3, 2015
@GaryJones GaryJones merged commit c1e822f into develop May 3, 2015
This was referenced May 3, 2015
@GaryJones GaryJones deleted the feature/192-add-updating-workflow branch May 3, 2015 22:40
@duckzland
Copy link

@jrfnl I've tested it and seems its working as intended, I think it is better to stop testing untill the code is ready for testing as now it seems that too much changes going on.

@jrfnl
Copy link
Contributor Author

jrfnl commented May 9, 2015

@duckzland Thanks for testing.

What do you mean by :

I think it is better to stop testing untill the code is ready for testing as now it seems that too much changes going on.

Since this PR was merged beginning of the week, nothing has changed which should impact users.

@duckzland
Copy link

@jrfnl so it is ready for testing with no more major changes and just for bug hunting for 2.5.0 release at this stage?

@jrfnl
Copy link
Contributor Author

jrfnl commented May 10, 2015

From my point of view, I don't expect any more big changes for the 2.5.0 release, so yes, testing is very welcome.

@steveboj
Copy link

I found an issue with packaged plugins that have uppercase letters in their slug, e.g. 'LayerSlider'. and 'Ultimate_VC_Addons'. The install and update options both failed with no errors for these plugins, but worked perfectly when I converted them to lowercase.

Everything else I tested worked very well.

@BassemN
Copy link

BassemN commented May 11, 2015

@steveboj I have the same issue

@jrfnl
Copy link
Contributor Author

jrfnl commented May 11, 2015

@steveboj @BassemN Is this only when updating or also when first installing the package from a bundled plugin ? If the latter - please open a separate issue.

@steveboj
Copy link

@jrfnl This is happening on first install and when updating. I have just created a separate issue #401

@steveboj
Copy link

I'm having trouble getting the new update function working with multiple bundled plugins from zip files:

Scenario 1: I click the "update" link for an individual plugin and I receive the "The plugin is at the latest version." message.

Scenario 2: I click the "update" link for a plugin and I see the success messages, but when I return to the updater page it says that plugin still needs to be updated. I click the "update" link again, but this time it shows me the "The plugin is at the latest version." message. When I check the plugins folder it still contains the old copy of the plugin.

Scenario 3: I use the bulk "update" function and it goes through each plugin saying they have been updated successfully, but when I return to the plugins page it shows me none of the plugins have been updated. When I try to update any of them individually, I get the "The plugin is at the latest version." message.

Scenario 4: I click the "update" link for an individual plugin in the list and it updates perfectly.

Has anyone else experienced anything similar?

@jrfnl
Copy link
Contributor Author

jrfnl commented May 12, 2015

@steveboj Updating with bundled plugins can only be done by setting a minimum required version of the plugin in the settings file - the version array key. Set this to the new version bundled and things should be fine.

TGMPA cannot obtain information about the version nr of bundled plugins, so we need to rely on the information you provide in the settings file to determine if there is an update.

[Edit] Oh and make sure the bundled version actually has the correct version nr in the plugin header and such as otherwise WP will still give us the wrong version nr to work with.

@steveboj
Copy link

@jrfnl The versions numbers seem to all be correctly setup. I'll test some more and see if I can find any more clues. Let me know if you think of anything else that could cause this type of issue.

@jrfnl
Copy link
Contributor Author

jrfnl commented May 12, 2015

@steveboj Great - any more clues you can give me to track down why it's not working for you, would be helpful. Insight into your settings and possibly copies of the offending .zip files could help too (old version + new version).
If the issue persists - please open a separate issue for this to keep it on the radar (this issue is closed).

@nomansbeauty
Copy link

Seems like new changes works well. Any idea, when the new version or stable release is coming? To be used in production.

@GaryJones
Copy link
Member

When it's ready - hopefully, before the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrading the package plugins
7 participants