Skip to content

Commit ef3168c

Browse files
chore: ensure post_id is not lost when constructing Box with invalid post ID
1 parent 421c451 commit ef3168c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/class-box.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ public function __construct($post)
4343
{
4444
// fetch post if it hasn't been fetched yet
4545
if (! $post instanceof WP_Post) {
46-
$post = get_post($post);
46+
$post_id = $post;
47+
$post = get_post($post_id);
4748

4849
if ($post === null) {
49-
throw new \InvalidArgumentException('No post found with ID ' . $post);
50+
throw new \InvalidArgumentException('No post found with ID ' . $post_id);
5051
}
5152
}
5253

0 commit comments

Comments
 (0)