Skip to content

Commit e2cc6c4

Browse files
authored
Avoid PHP Fatal when duration fields are left blank. (#3158)
If the duration fields are left blank, under PHP8 a fatal will be thrown: > E_ERROR: Uncaught TypeError: Unsupported operand types: string * int
1 parent 5e798aa commit e2cc6c4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

wp-content/plugins/wporg-learn/inc/post-meta.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ function save_workshop_meta_fields( $post_id ) {
664664

665665
$duration = filter_input( INPUT_POST, 'duration', FILTER_SANITIZE_NUMBER_INT, FILTER_REQUIRE_ARRAY );
666666
if ( isset( $duration['h'], $duration['m'], $duration['s'] ) ) {
667+
$duration = array_map( 'absint', $duration );
667668
$duration = $duration['h'] * HOUR_IN_SECONDS + $duration['m'] * MINUTE_IN_SECONDS + $duration['s'];
668669
update_post_meta( $post_id, 'duration', $duration );
669670
}

0 commit comments

Comments
 (0)