Skip to content

Photon: Do not image_downsize for REST API requests in the edit context - #10592

Merged
mdawaffe merged 10 commits into
masterfrom
fix/gutenphoton
Nov 20, 2018
Merged

mdawaffe merged 10 commits into
masterfrom
fix/gutenphoton

Conversation

@kraftbj

@kraftbj kraftbj commented Nov 9, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #10580

Changes proposed in this Pull Request:

  • Return out of image_downsize early for REST API edit context requests to media endpoints

Testing instructions:

  • See issue above.

Proposed changelog entry for your changes:

  • Improved compatibility for the image CDN with the new WordPress Block Editor.

@kraftbj
kraftbj requested a review from a team November 9, 2018 20:37
@jetpackbot

jetpackbot commented Nov 9, 2018 •

Copy link
Copy Markdown
Collaborator

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: December 4, 2018.
Scheduled code freeze: November 27, 2018

Generated by 🚫 dangerJS

@jeherve jeherve added Bug When a feature is broken and / or not performing as intended [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Status] Needs Review This PR is ready for review. [Pri] High labels Nov 9, 2018
@jeherve jeherve added this to the 6.7.1 milestone Nov 9, 2018

@mdawaffe mdawaffe left a comment

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.

Some thoughts inline.

Comment thread class.photon.php Resolved
Comment thread class.photon.php Resolved
@kraftbj kraftbj added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Nov 9, 2018
@kraftbj kraftbj added [Status] Needs Testing We need to add this change to the testing call for this month's release and removed [Status] In Progress labels Nov 13, 2018
@kraftbj

kraftbj commented Nov 13, 2018

Copy link
Copy Markdown
Contributor Author

Based on the docs, it should be an instance of the class checked as populated by the $endpoints property of the class. I need to hand this one off for testing and getting across the finish line. Thanks for your work on this!

@mdawaffe mdawaffe self-assigned this Nov 14, 2018
We're not checking for the right value.

Also, in theory, `$handler` could be any callable.
…ng `?context=edit` REST requests.

Fix some PHPDoc.
Clean the `Jetpack_Photon` state before each test.

The singleton/static class property make it annoying to clean the state.
@mdawaffe mdawaffe added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Testing We need to add this change to the testing call for this month's release labels Nov 14, 2018

@jeherve jeherve left a comment

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.

PHP 5.2 is causing us some issues here :(

// static variable.
// l337 h4X0Ring required:
$instance = new ReflectionProperty( 'Jetpack_Photon', '__instance' );
$instance->setAccessible( true );

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.

This makes our PHP 5.2 tests trip:

Fatal error: Call to undefined method ReflectionProperty::setAccessible() in wp-content/plugins/jetpack/tests/php/test_class.jetpack_photon.php on line 35

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.

That's sad :(

http://php.net/manual/en/reflectionproperty.setaccessible.php PHP 5.3+

I'm not sure what to do here, then. We're only using that code to make the Jetpack_Publicize class testable - not to implement any functionality.

We could skip the tests for PHP 5.2, but that seems sketchy.

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.

06e261d may "fix" it.

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.

I am afraid the tests are still failing :( Travis won't let us merge that one.

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.

OK - I'll look into it more later. Thanks for the ping!

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.

Looks like it's working as of ea220aa.

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 15, 2018
The singleton/static class property make it annoying to test, and is only
possible in PHP 5.3+

http://php.net/manual/en/reflectionproperty.setaccessible.php
@jeherve jeherve removed this from the 6.7.1 milestone Nov 15, 2018
@jeherve jeherve added this to the 6.8 milestone Nov 15, 2018
The version of PHPUnit we're running on TravisCI is very old and doesn't
support `@requires`.
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 15, 2018

@jeherve jeherve left a comment

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.

It seems to work well in my tests. 🚢

@mdawaffe
mdawaffe merged commit 43629b9 into master Nov 20, 2018
@ghost ghost removed the [Status] Ready to Merge Go ahead, you can push that green button! label Nov 20, 2018
@mdawaffe
mdawaffe deleted the fix/gutenphoton branch November 20, 2018 00:40
jeherve pushed a commit that referenced this pull request Nov 20, 2018
…xt (#10592)

Photon: Do image_downsize for REST API requests on the wp/v2/media endpoint in the edit context.

For tests, we need to clean the `Jetpack_Photon` state before each test, which is annoying because of the singleton/static class property. Unfortunately, the tests are not compatible with PHP 5.3, though the feature is.
@jeherve

jeherve commented Nov 20, 2018

Copy link
Copy Markdown
Member

Cherry-picked to branch-6.8 in f2133f0

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

Labels

Bug When a feature is broken and / or not performing as intended [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Pri] High

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants