Automattic\WooCommerce\Internal\BatchProcessing
BatchProcessingController::run_scheduler_lookup
Run an Action Scheduler lookup, distinguishing "not scheduled" from a failed database query.
Action Scheduler returns the same value for both, so the database state is checked directly. $wpdb->last_error only counts when the lookup ran a query: otherwise (e.g. a custom store that bypasses $wpdb) it is left over from an earlier, unrelated query.
Метод класса: BatchProcessingController{}
Хуков нет.
Возвращает
bool|null. The lookup result, or null if the lookup failed.
Использование
// private - только в коде основоного (родительского) класса $result = $this->run_scheduler_lookup( $lookup ): ?bool;
- $lookup(callable) (обязательный)
- Callback performing the lookup.
Код BatchProcessingController::run_scheduler_lookup() BatchProcessingController::run scheduler lookup WC 11.3.0
private function run_scheduler_lookup( callable $lookup ): ?bool {
global $wpdb;
$queries_before = $wpdb->num_queries;
$result = (bool) $lookup();
$query_failed = $wpdb->num_queries > $queries_before && ! empty( $wpdb->last_error );
// When reconnecting after a lost connection fails, wpdb::query() returns false without an error but discards
// the connection handle. A later query can reconnect, so state changes would succeed on top of this failed read.
if ( $query_failed || empty( $wpdb->dbh ) ) {
return null;
}
return $result;
}