Closed anoblet closed 2 years ago
Hmm, just remove the strong WP_Query
type for time being, then, so it'll accept anything.
@lkraav When I remove the WP_Query
type, the request returns an empty array. No errors in the console or in the server logs.
The orders endpoint also returns an empty array when enabling the protected_content
feature.
Hey @anoblet ,
I actually get the same empty array with ElasticPress turned off, can you confirm/deny the same on your end?
As for wp-json/wc/v3/orders with protected content enabled I don't have any problems. I am using the latest version of ElasticPress and latest version of Woocommerce. Can you try updating Woocommerce? as it seems it is far behind 5.8.0
@oscarssanchez
I removed the strong type from ElasticPress.php
and investigated a little further and found that there is a problem with the orderby
parameter in the request.
Users feature enabled:
/wp-json/wc/v3/customers?order=desc&orderby=id&page=1&per_page=50
(Empty)
/wp-json/wc/v3/customers?order=desc&page=1&per_page=50
(Works)
Protected Content feature enabled:
/wp-json/wc/v3/orders?customer=80&order=desc&orderby=id&page=1&per_page=50
(Empty)
/wp-json/wc/v3/orders?customer=80&order=desc&page=1&per_page=50
(Works)
If either feature is disabled, or the orderby
parameter is not supplied, the request will work.
Maybe related @anoblet https://github.com/10up/ElasticPress/pull/2435
@lkraav That's a great find!
I wonder if a similar fix could work for the orders endpoint?
@lkraav I tried the fix in that PR and still got an empty result set when using the orderby
parameter.
I can confirm the bug happens with the orderby parameter!
Hi @anoblet ,
Long story short, the problem seems to be related to Woocommerce. I have opened https://github.com/woocommerce/woocommerce/issues/31294 in regard.
This ends up adding "**"
to the WP_User_Query()
which in turn will format the EP query to a match
query instead of a match_all
(which by the way should also not be triggered by default, as ep_integrate
won't be set to true
unless there's a search param, or you explicitly set the ep_integrate
param to true
)
You could probably use something like this as a workaround until that issue is fixed:
add_filter(
'woocommerce_rest_customer_query',
function ( $wp_user_query_args ) {
if ( '**' === $wp_user_query_args['search'] ) {
unset( $wp_user_query_args['search'] );
}
return $wp_user_query_args;
}
);
Describe the bug
After enabling the users feature, when trying to
GET
from the/customers
REST endpoint we receive the error:Disabling the users feature allow us to perform this request without error.
Steps to Reproduce
wp elasticpress activate-feature users
wp elasticpress index
/wp-json/wc/v3/customers
Expected behavior We get a list of customers
Screenshots
Environment information
Site Health Info:
` ### wp-core ###version: 5.7 site_language: en_US user_language: en_US timezone: +00:00 permalink: /%postname%/ https_status: false multisite: false user_registration: 0 blog_public: 1 default_comment_status: open environment_type: production user_count: 80 dotorg_communication: true
wp-paths-sizes
wordpress_path: /workspaces/cxl-wpstarter/public/wp wordpress_size: 50.28 MB (52718585 bytes) uploads_path: /workspaces/cxl-wpstarter/public/wp-content/uploads uploads_size: 0.00 B (0 bytes) themes_path: /workspaces/cxl-wpstarter/public/wp-content/themes themes_size: 288.02 MB (302008984 bytes) plugins_path: /workspaces/cxl-wpstarter/public/wp-content/plugins plugins_size: 234.93 MB (246341939 bytes) database_size: 134.73 MB (141278734 bytes) total_size: 707.96 MB (742348242 bytes)
wp-active-theme
name: CXL Institute (conversionxl-institute) version: 2021.03.04 author: leho@cxl.com author_website: (undefined) parent_theme: Hybrid Base Dynamic (CXL Institute) (hybrid-base-dynamic-conversionxl-institute) theme_features: core-block-patterns, theme-layouts, hybrid-core-template-hierarchy, get-the-image, breadcrumb-trail, cleaner-gallery, automatic-feed-links, post-formats, post-thumbnails, menus, pure-css, align-wide, sensei, woocommerce, woocommerce-subscriptions, title-tag, html5, widgets theme_path: /workspaces/cxl-wpstarter/public/wp-content/themes/conversionxl-institute
wp-parent-theme
name: Hybrid Base Dynamic (CXL Institute) (hybrid-base-dynamic-conversionxl-institute) version: 2020.09.17 author: Justin Tadlock, Leho Kraav author_website: https://conversionxl.com/institute/ theme_path: /workspaces/cxl-wpstarter/public/wp-content/themes/hybrid-base-dynamic-conversionxl-institute
wp-plugins-active (26)
AutomateWoo: version: 5.3.0, author: WooCommerce CXL Institute: version: 2020.08.23, author: Leho Kraav Debug Bar ElasticPress: version: 2.1.0, author: 10up Disable All WordPress Updates: version: 1.6.7, author: Oliver Schlöbe Disable Emojis (GDPR friendly): version: 1.7.2, author: Ryan Hellyer ElasticPress: version: 3.6.3, author: 10up FacetWP: version: 3.7.4, author: FacetWP, LLC Hybrid Core (4.0) - restore schema.org support: version: 2017.12.21, author: Leho Kraav Less Rewrite Rules: version: 2015.05.01, author: Leho Kraav Nav Menu Collapse: version: 2.1.0, author: Robert Noakes Post Meta Inspector: version: 1.1.1, author: Daniel Bachhuber, Automattic Pure CSS Theme Features: version: 1.6.2pl20161003, author: Leho Kraav Query Monitor: version: 3.6.7, author: John Blackbourn Remove jQuery Migrate: version: 1.0.2, author: Hendy Tarnando REST API Log: version: 1.6.8, author: Pete Nelson Sensei LMS: version: 2.4.0, author: Automattic Sensei LMS Course Progress: version: 2.0.3, author: Automattic Stream: version: 3.6.2, author: XWP Teams for WooCommerce Memberships: version: 1.5.2, author: SkyVerge User Switching: version: 1.5.6, author: John Blackbourn & contributors WooCommerce: version: 4.9.2, author: Automattic WooCommerce Memberships: version: 1.21.4, author: SkyVerge WooCommerce Sequential Order Numbers: version: 1.9.5, author: SkyVerge WooCommerce Stripe Gateway: version: 4.9.0, author: WooCommerce WooCommerce Subscriptions: version: 3.0.13, author: WooCommerce WordPress Bug #14050 Hotfix: version: 2016.03.15, author: Leho Kraav
wp-plugins-inactive (12)
BadgeOS (git): version: 1.4.11, author: LearningTimes BadgeOS Sensei Add-On: version: 1.0.4, author: Credly Classic Editor: version: 1.6, author: WordPress Contributors CXL JWPlayer: version: 2020.06.02, author: Kyle Brodeur, Paul Kirspuu, Leho Kraav FacetWP - Relevanssi integration: version: 0.7.2, author: FacetWP, LLC Gutenberg: version: 10.1.1, author: Gutenberg Team Pco Kint: version: 1.0.10, author: Peytz & Co (Patrick Hesselberg) Relevanssi Always Exclude Private Posts: version: 2016.08.30, author: Leho Kraav Relevanssi Premium: version: 2.14.4, author: Mikko Saari Rename wp-login.php: version: 2.6.0, author: Ella van Durpe Toolbar Theme Switcher: version: 1.4, author: Andrey "Rarst" Savchenko Yoast SEO Premium: version: 15.9, author: Team Yoast
wp-media
image_editor: false imagick_module_version: Not available imagemagick_version: Not available file_uploads: File uploads is turned off post_max_size: 8M upload_max_filesize: 2M max_effective_size: 2 MB max_file_uploads: 20 gd_version: not available ghostscript_version: not available
wp-server
server_architecture: Linux 5.4.72-microsoft-standard-WSL2 x86_64 httpd_software: PHP 7.4.21 Development Server php_version: 7.4.21 64bit php_sapi: cli-server max_input_variables: 1000 time_limit: 30 memory_limit: -1 max_input_time: 60 upload_max_filesize: 2M php_post_max_size: 8M curl_version: 7.64.0 OpenSSL/1.1.1d suhosin: false imagick_availability: false pretty_permalinks: false
wp-database
extension: mysqli server_version: 10.3.29-MariaDB-0+deb10u1 client_version: mysqlnd 7.4.21
wp-constants
WP_HOME: http://localhost:8080 WP_SITEURL: http://localhost:8080/wp WP_CONTENT_DIR: /workspaces/cxl-wpstarter/public/wp-content WP_PLUGIN_DIR: /workspaces/cxl-wpstarter/public/wp-content/plugins WP_MEMORY_LIMIT: 40M WP_MAX_MEMORY_LIMIT: -1 WP_DEBUG: false WP_DEBUG_DISPLAY: false WP_DEBUG_LOG: true SCRIPT_DEBUG: false WP_CACHE: false CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_LOCAL_DEV: undefined DB_CHARSET: utf8 DB_COLLATE: undefined
wp-filesystem
wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable
epio_autosuggest
wp-starter
autoload-path: /workspaces/cxl-wpstarter/public/vendor/autoload.php base-path: /workspaces/cxl-wpstarter env-cache-file: /workspaces/cxl-wpstarter/.env.cached.php env-cache-enabled: true cached-env: true env-type: development env-php-file: undefined early-hooks-file: undefined wp-env-type: production ssl_fix: false register-core-themes: false
`
Additional context