Automattic\WooCommerce\Admin\API
MobileAppQRLogin::delete_claim_if_value_matches
Delete a claim option only if it still has the value this request observed.
Method of the class: MobileAppQRLogin{}
No Hooks.
Returns
true|false. True if the observed stale claim was deleted.
Usage
// private - for code of main (parent) class only $result = $this->delete_claim_if_value_matches( $claim_key, $observed_claim_value );
- $claim_key(string) (required)
- Option key used as the claim mutex.
- $observed_claim_value(string) (required)
- Claim expiry value previously read from the option.
MobileAppQRLogin::delete_claim_if_value_matches() MobileAppQRLogin::delete claim if value matches code WC 11.0.1
private function delete_claim_if_value_matches( $claim_key, $observed_claim_value ) {
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name = %s AND option_value = %s",
$claim_key,
$observed_claim_value
)
);
if ( false === $result ) {
wc_get_logger()->warning(
sprintf(
'QR login stale-claim cleanup query failed for %s: %s',
$claim_key,
$wpdb->last_error
),
array( 'source' => 'mobile-app-qr-login' )
);
}
wp_cache_delete( $claim_key, 'options' );
return (int) $result > 0;
}