Skip to content

Commit 640b5b9

Browse files
authored
t531: fix set_demo_behavior fatal TypeError on PHP 8 when null passed via attributes() (#914)
1 parent 69feaf4 commit 640b5b9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

inc/models/class-product.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,10 +1361,14 @@ public function get_demo_behavior(): string {
13611361
*
13621362
* @since 2.5.0
13631363
*
1364-
* @param string $behavior Either 'delete_after_time' or 'keep_until_live'.
1364+
* @param string|null $behavior Either 'delete_after_time' or 'keep_until_live'. Null is ignored (default applied at read time).
13651365
* @return void
13661366
*/
1367-
public function set_demo_behavior(string $behavior): void {
1367+
public function set_demo_behavior($behavior) {
1368+
1369+
if (null === $behavior) {
1370+
return;
1371+
}
13681372

13691373
$this->meta[ self::META_DEMO_BEHAVIOR ] = $behavior;
13701374

0 commit comments

Comments
 (0)