Skip to content

Move code from plugins install endpoint to new Plugins Library#8464

Merged
ockham merged 9 commits intomasterfrom
add/plugins-library
Jan 8, 2018
Merged

Move code from plugins install endpoint to new Plugins Library#8464
ockham merged 9 commits intomasterfrom
add/plugins-library

Conversation

@ockham
Copy link
Copy Markdown
Contributor

@ockham ockham commented Jan 5, 2018

Some prep work for #8450 #8482. De-duplicate all the things!

Move:

  • the Jetpack_Automatic_Install_Skin helper class to _inc/lib/class.jetpack-automatic-install-skin.php
  • some static helper methods from Jetpack_JSON_API_Plugins_Install_Endpoint to Jetpack_Plugins in _inc/lib/plugins.php.

To test: Make sure all affected endpoints still work. Note that Jetpack_Automatic_Install_Skin is used by a few other endpoints (grep to verify!):

  • Plugin installation (from WP.org): POST to /sites/%s/plugins/%s/install (try woocommerce)
  • Theme installation (from WP.org): POST to /sites/%s/themes/%s/install (try twentyseventeen) -- see note at bottom
  • Plugin installation (via upload): POST to /sites/%s/plugins/%s/new -- use Calypso to test (wordpress.com/plugins/upload/:site)
  • Theme installation (via upload): POST to /sites/%s/themes/%s/new -- use Calypso to test (wordpress.com/themes/upload/:site)

Note:

  • /sites/%s/themes/%s/install doesn't work at all, returns a 404. However, that behavior seems to be preexisting!

@ockham ockham self-assigned this Jan 5, 2018
@ockham ockham requested review from AnnaMag and tyxla January 5, 2018 11:39
@ockham ockham requested a review from a team as a code owner January 5, 2018 11:39
@ockham ockham force-pushed the add/plugins-library branch from 16bbfdc to d367156 Compare January 5, 2018 11:40
@ockham ockham force-pushed the add/plugins-library branch from d367156 to 4df2bb8 Compare January 5, 2018 11:43
*/
public static function install_plugin( $slug ) {
if ( is_multisite() && ! current_user_can( 'manage_network' ) ) {
return new WP_Error( 'not_allowed', 'You are not allowed to install plugins on this site.' );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this error message something the user would see? If so, then it should be translatable.

}

protected static function generate_wordpress_org_plugin_download_link( $plugin_slug ) {
return "https://downloads.wordpress.org/plugin/{$plugin_slug}.latest-stable.zip";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The curly braces are not needed here since the expression is simply a string.

}

protected static function get_slug_from_file_path( $plugin_file ) {
// Simular to get_plugin_slug() method.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "Simular".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You folks both probably meant "Similar" 😉

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

@oskosk oskosk added this to the 5.8 milestone Jan 5, 2018
@ockham ockham requested a review from oskosk January 8, 2018 10:29
@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 8, 2018

Ready for review!

Copy link
Copy Markdown
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful work 👍 ❤️

  • Plugin installation (from WP.org): ✅
  • Theme installation (from WP.org): ✅ (tested with twentyseventeen-wpcom)
  • Plugin installation (via upload): ✅
  • Theme installation (via upload): ✅

Verified no other endpoints use the install skin.

Other than an indentation issue, this LGTM 👍


$result = $upgrader->install( $zip_url );

if ( is_wp_error( $result ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something seems to have happened with the indentation here and on the following lines.

@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 8, 2018

Thanks @tyxla! Indentation should be fixed as of 7814897.

@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 8, 2018

I can haz review pls @oskosk and/or @eliorivero? 😁

@oskosk
Copy link
Copy Markdown
Contributor

oskosk commented Jan 8, 2018

/sites/%s/themes/%s/install doesn't work at all, returns a 404. However, that behavior seems to be preexisting!

Tested it and it does work. It's the endpoint used by Calypso. When testing on the dev console, just don't scope the request to v1.2.

v1 or v1.1 should work.

Copy link
Copy Markdown
Contributor

@oskosk oskosk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests great! 🎉 LGTM

There's a little tiny codestyle issue involving a lack of spaces around an array index which I'm not commenting about in the code because I really don't care.

🚢

@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 8, 2018

Thanks a lot for reviewing @tyxla and @oskosk!

@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 11, 2018

@jeherve and @oskosk Would this be an okay Changelog entry?

Move:

  • the Jetpack_Automatic_Install_Skin helper class to _inc/lib/class.jetpack-automatic-install-skin.php
  • some static helper methods from Jetpack_JSON_API_Plugins_Install_Endpoint to Jetpack_Plugins in _inc/lib/plugins.php.

@jeherve
Copy link
Copy Markdown
Member

jeherve commented Jan 11, 2018

That's a bit too verbose, but don't worry about it! The label is mostly there for us, to help us build the changelog; we will come up with something as we go through all the PRs with that label at once.

Thanks a lot for giving us a headstart though!

@jeherve jeherve added [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release and removed [Status] Needs Changelog [Status] Needs Review This PR is ready for review. [Status] Needs Testing We need to add this change to the testing call for this month's release labels Jan 29, 2018
jeherve added a commit that referenced this pull request Jan 29, 2018
zinigor pushed a commit that referenced this pull request Jan 30, 2018
* Changelog 5.8: create base for changelog.

* Update 5.8 release post link

* fix 5.8 release date

* Updates to plugin description

* Changelog: add #8499

* Changelog: add #8506

* Changelog: add #8509

* Changelog: add #8516

* Changelog: add #8517

* Changelog: add #8523

* Changelog: add #8547

* Changelog: add #8496

* Changelog: add #8584

* Changelog: add #8595

* Changelog: add #8445

* Changelog: add #8431

* Changelog: add #8284

* Changelog: add #8270

* Changelog: add #8124

* Changelog: add #8581

* Changelog: add #8463

* Changelog: add #8568 (#8646)

* Updates to testing list and changelog

* Changelog: add #8443

* Changelog: add #8459

* Changelog: add #8469

* Changelog: add #8464

* Changelog: add #8478 and #8479

* Changelog: add #8483

* Changelog: add #8488

* Changelog: add #8513

* Changelog: add #8555

* Changelog: add #8565

* Changelog: add #8601

* Changelog: add #8612

* Changelog: add first pass at Search items.

* Changelog: add more info to help test Search.

* Changelog: add #8144

* Changelog: add #8313

* Changelog: add #8419

* Changelog: add #8465

* Changelog: add #8515

* Changelog: add #8587

* Changelog: add #8591

* Changelog: add #8659

* Changelog: add #8661

* Changelog: add #8671

* Changelog: add 5.7.1 to archived changelog too.

* Reverted changes to readme, removed entry about backups.
@anomiex anomiex mentioned this pull request May 15, 2023
3 tasks
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.

5 participants