Search gives no results after update and changes made to theme-functions.php
Using WPML.
If I replace
// WooCommerce search query part with old one, it works again.
This topic has 8 replies, 2 voices, and was last updated 27 minutes ago ago by Andrew Mitchell
Search gives no results after update and changes made to theme-functions.php
Using WPML.
If I replace
// WooCommerce search query part with old one, it works again.
Hello, Kristjan,
Could you please provide temporary wp-admin and FTP access? We will check what can be done to help you.
To grant WP-Admin access, please proceed to create a new user account with an administrator role through your WordPress Dashboard. Once the account is established, you may securely transmit the username and password to us via the Private Content section designated for this purpose.
For FTP access, we require the following details: FTP host, FTP username, FTP password, FTP port, and FTP encryption type. If you need assistance in creating these credentials, please reach out to your hosting provider who will guide you through the process.
Best Regards,
8Theme’s Team
The problem was that when the old SKU search code was converted to use prepare(), the SQL structure changed slightly: a closing parenthesis was added too early inside the prepared fragment.
Line 880 should be:
“,
not
)”,
I’d also use
$s = trim( wp_unslash( $wp_the_query->query_vars[‘s’] ?? ” ) );
on line 857
Also your recent patch fixed the SQL grouping issue and improved the SKU search branch by using prepare() and esc_like().
However, the search is still not fully hardened against SQL injection, because the variation search block still concatenates the raw search term into SQL LIKE ‘%$s%’ conditions.
See more info I posted in this topic: https://www.8theme.com/topic/new-sql-injection-vulnerability-discovered/#post-434516
Hello, Kristjan,
The functions wp_unslash() and trim() are not required in this case. The value used here is not the raw data from $_GET, but rather query_vars[‘s’] from the WordPress query object. Therefore, adding an extra wp_unslash() would be redundant and provide no practical benefit.
Similarly, trim() is also unnecessary: the current search logic already works correctly with this value, and forcibly trimming spaces would alter the query’s behavior. In other words, adding wp_unslash() and trim() in this line appears to be excessive data normalization rather than a necessary safeguard or correction.
Best regards,
8Theme’s Team
You still have to remove the )
This breaks the product search with WPML.
The prepared SQL string should be left open since the remaining parentheses are closed later by the appended SQL
$where .= “) )”;
Hello, Kristjan,
We have made the necessary changes to the file wp-content/themes/xstore/framework/theme-functions.php.
These changes will also be included in the next theme update.
Best regards,
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up