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

Jetpack Search: Use full namespace for class_exists check for authenticated_requests to work #13244

Merged
merged 2 commits into from Aug 16, 2019

Conversation

rebeccahum
Copy link
Contributor

@rebeccahum rebeccahum commented Aug 16, 2019

Fixes #13243.

Changes proposed in this Pull Request:

If you are using aliasing to import namespaced classes, take care that class_exists will not work using the short, aliased class name - apparently whenever a class name is used as string, only the full-namespace version can be used

Therefore, class_exists( 'Client' ) will always return false. Instead, we should use the full namespace Automattic\Jetpack\Connection\Client.

Introduced in 3ed3de8 during re-factoring.

Since JP autoloads classes now, I think we might be able to just remove the check? Happy to re-commit the change if so.

Testing instructions:

  1. Assuming JP Search module is enabled, add filter to enable authenticated requests via JP:
add_filter( 'jetpack_search_es_query_args', function( $es_query_args ) {
    $es_query_args['authenticated_request'] = true;
 
    return $es_query_args;
} );
  1. Ensure es args have non-public content in search (e.g. drafts for post_type)
  2. Perform search
  3. Apply patch
  4. Perform search again and see results

Proposed changelog entry for your changes:

  • Bugfix: Authenticated requests to search will now display non-public content

@rebeccahum rebeccahum requested a review from a team as a code owner August 16, 2019 18:40
@rebeccahum rebeccahum changed the title Use full namespace for class_exists check to work as expected Jetpack Search: Use full namespace for class_exists check for authenticated_requests to work Aug 16, 2019
@jetpackbot
Copy link

jetpackbot commented Aug 16, 2019

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: September 3, 2019.
Scheduled code freeze: August 27, 2019

Generated by 🚫 dangerJS against 812881b

@rebeccahum rebeccahum added the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Aug 16, 2019
@mdawaffe
Copy link
Member

Rebased to include #13245.

@mdawaffe mdawaffe self-assigned this Aug 16, 2019
@mdawaffe mdawaffe added this to the 7.7 milestone Aug 16, 2019
Copy link
Member

@mdawaffe mdawaffe left a comment

Choose a reason for hiding this comment

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

Nice find - thanks!

@mdawaffe mdawaffe merged commit db26ba1 into master Aug 16, 2019
@mdawaffe mdawaffe deleted the rebecca/fix_13243 branch August 16, 2019 20:49
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Aug 16, 2019
@tyxla
Copy link
Member

tyxla commented Aug 19, 2019

Thank you for this! 🙇

@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Search For all things related to Search [Status] Has Changelog and removed [Status] Needs Changelog labels Aug 19, 2019
jeherve added a commit that referenced this pull request Aug 23, 2019
jeherve added a commit that referenced this pull request Aug 27, 2019
* 7.7 changelog: initial set of changes

* Changelog: add #13154

* Changelog: add #13134

* Changelog: add #12699 and many others

* Changelog: add #13127

* Changelog: add #13167

* Changelog: add #13225

* Changelog: add #13179

* Changelog: add #13173

* Changelog: add #13232

* Changelog: add #13137

* Changelog: add #13172

* Changelog: add #13182

* Changelog: add #13200

* Changelog: add #13244

* Changelog: add #13267

* Changelog: add #13204

* changelog: add #13205

* Changelog: add #13183

* Changelog: add #13278

* Changelog: add #13162

* Changelog: add #13268

* Changelog: add #13286

* Changelog: add #13273

* Changelog: add #12474

* Changelog: add #13085

* Changelog: add #13266

* Changelog: add #13306

* Changelog: add #13311

* Changelog: add #13302

* Changelog: add #13196

* Changelog: add #12733

* Changelog: add #13261

* Changelog: add #13322

* Changelog: add #13333

* Changelog: add #13335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jetpack Search: authenticated requests are not working
6 participants