You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a serial number is set to 'available' status (via the UI or through the Key class), the order_id is set to 0 and the order_date should be set to NULL (see Key.php line 518). However, this does not happen because wp_array_slice_assoc() is used during the save() method in the parent Model class, and this function cannot handle keys in the input array that are set to NULL (probably a WP bug, it uses isset() on the input array, which returns false if a key exists but is set to null).
This can be resolved with the following patch (I can't submit a PR because Model.php is not in this repo):
--- ../wc-serial-numbers/lib/Lib/Model.php 2023-08-31 23:59:24.424829309 -0700+++ lib/Lib/Model.php 2023-09-02 12:48:06.633619770 -0700@@ -467,7 +467,7 @@ abstract class Model {
*/
do_action( $this->get_hook_prefix() . '_pre_update', $this, $changes );
- $data = wp_array_slice_assoc( $changes, $this->get_core_data_keys() );+ $data = $this->array_slice_assoc( $changes, $this->get_core_data_keys() );
/**
* Filters the data to be updated in the database.
@@ -503,6 +503,10 @@ abstract class Model {
return true;
}
+ function array_slice_assoc($array,$keys) {+ return array_intersect_key($array,array_flip($keys));+ }+
/**
* Deletes the object from database.
*
When a serial number is set to 'available' status (via the UI or through the Key class), the order_id is set to 0 and the order_date should be set to NULL (see Key.php line 518). However, this does not happen because wp_array_slice_assoc() is used during the save() method in the parent Model class, and this function cannot handle keys in the input array that are set to NULL (probably a WP bug, it uses isset() on the input array, which returns false if a key exists but is set to null).
This can be resolved with the following patch (I can't submit a PR because Model.php is not in this repo):
See the Notes section at https://www.php.net/manual/en/function.array-slice.php for more info about this solution.
The text was updated successfully, but these errors were encountered: