Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error when get_posts with wrong ID in array #2859

Closed
theamnesic opened this issue Dec 1, 2023 · 2 comments
Closed

Fatal error when get_posts with wrong ID in array #2859

theamnesic opened this issue Dec 1, 2023 · 2 comments

Comments

@theamnesic
Copy link

Expected Behavior

When using get_posts with array like this : {% for item in get_posts( [ 1503, 543, 3220 ] ) %}, Timber display posts and ignore if the ID doesn't exists.

Actual behavior

Fatal error if an ID doesn't exists:

Fatal error: Uncaught Error: Call to a member function setup() on null in /Users/g/Sites/g/vendor/timber/timber/src/PostsIterator.php:49 Stack trace: #0 /Users/g/Sites/g/vendor/twig/twig/src/Environment.php(361) : eval()'d code(105): Timber\PostsIterator->current() #1

Steps to reproduce behavior

Loop with an array width get_posts with a wrong ID.

Notes

No response

What version of Timber are you using?

2.0.0

What version of WordPress are you using?

6.4.1

What version of PHP are you using?

8.1.13

How did you install Timber?

Installed or updated Timber through Composer

@Levdbas Levdbas added this to the 2.0.1 milestone Dec 14, 2023
@Levdbas
Copy link
Member

Levdbas commented Dec 15, 2023

I tried this myself and can confirm this behavior. PostsIterator seems not to like null posts.

@Levdbas Levdbas modified the milestones: 2.0.1, 2.1.0 Feb 1, 2024
@Levdbas
Copy link
Member

Levdbas commented Feb 9, 2024

Should be fixed by #2918

@Levdbas Levdbas closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants