WC_Helper_Updater::should_use_cached_update_data
Validates cached update data and checks if it matches the expected hash.
Ensures the cached data is properly structured and corresponds to the current payload to prevent fatal errors and avoid stale cache returns.
Метод класса: WC_Helper_Updater{}
Хуков нет.
Возвращает
bool. True if the data is valid and hash matches, false otherwise.
Использование
$result = WC_Helper_Updater::should_use_cached_update_data( $data, $hash );
- $data(разное) (обязательный)
- The data retrieved from the transient.
- $hash(строка) (обязательный)
- The expected hash to compare against.
Список изменений
| С версии 10.3.6 | Введена. |
Код WC_Helper_Updater::should_use_cached_update_data() WC Helper Updater::should use cached update data WC 11.1.2
private static function should_use_cached_update_data( $data, $hash ) {
if ( ! is_array( $data ) ) {
return false;
}
if ( ! isset( $data['hash'], $data['products'] ) ) {
return false;
}
if ( ! is_string( $data['hash'] ) || ! is_array( $data['products'] ) ) {
return false;
}
return hash_equals( $hash, $data['hash'] );
}