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

Improve WC order query for compatibility layer (2670) #2423

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .psalm/stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group =
/**
* HTML API: WP_HTML_Tag_Processor class
*/
class WP_HTML_Tag_Processor {
public function __construct( $html ) {}
public function next_tag( $query = null ) {}
public function set_attribute( $name, $value ) {}
public function get_updated_html() {}
namespace {
class WP_HTML_Tag_Processor {
public function __construct( $html ) {}
public function next_tag( $query = null ) {}
public function set_attribute( $name, $value ) {}
public function get_updated_html() {}
}
}

namespace Automattic\WooCommerce\Internal\DataStores\Orders {
class OrdersTableDataStore {
public static function get_orders_table_name() {}
}
}
16 changes: 10 additions & 6 deletions modules/ppcp-compat/src/PPEC/PPECHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace WooCommerce\PayPalCommerce\Compat\PPEC;

use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
use Automattic\WooCommerce\Utilities\OrderUtil;

/**
Expand Down Expand Up @@ -74,14 +75,17 @@ public static function site_has_ppec_subscriptions() {
return $has_ppec_subscriptions === 'true';
}

$wc_orders_table = OrdersTableDataStore::get_orders_table_name();

global $wpdb;
if ( class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() && isset( $wpdb->wc_orders ) ) {
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT 1 FROM {$wpdb->wc_orders} WHERE payment_method = %s",
self::PPEC_GATEWAY_ID
)
if ( $wc_orders_table && class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$query = $wpdb->prepare(
'SELECT 1 FROM %s WHERE payment_method = %s',
$wc_orders_table,
self::PPEC_GATEWAY_ID
);
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$result = $wpdb->get_var( $query );
} else {
$result = $wpdb->get_var(
$wpdb->prepare(
Expand Down
Loading