8000 Fix PostIterator, if post is null by rubas · Pull Request #2918 · timber/timber · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix PostIterator, if post is null #2918

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

Merged
merged 6 commits into from
Feb 23, 2024
Merged

Fix PostIterator, if post is null #2918

merged 6 commits into from
Feb 23, 2024

Conversation

rubas
Copy link
Contributor
@rubas rubas commented Feb 8, 2024

Related: #2917

Issue

$post can be null, which breaks the code.

@rubas rubas changed the title Update PostsIterator.php Fix PostIterator, if post is null Feb 8, 2024
@nlemoine
Copy link
Member
nlemoine commented Feb 8, 2024

Thank you @rubas for this PR.

We still support PHP 7.4 so $post?->setup(); syntax will not work. Can you adapt your PR to match 7.4 requirements?

@Levdbas Levdbas added the 2.0 label Feb 8, 2024
@Levdbas Levdbas added this to the 2.1.0 milestone Feb 8, 2024
@rubas
Copy link
Contributor Author
rubas commented Feb 8, 2024

protected null|Post $last_post;

The support for union type was only introduced in PHP 8.0.

@rubas
Copy link
Contributor Author
rubas commented Feb 8, 2024

The failed coding standard test is outside of this PR. I'm happy to push a fix...

1) tests/test-timber-cache.php

    ---------- begin diff ----------
@@ -329,7 +329,7 @@
         $clear = $loader->clear_cache_timber(Timber\Loader::CACHE_OBJECT);
         $this->assertTrue($clear);
         $works = true;
-      
+
         if (isset($wp_object_cache->cache[Timber\Loader::CACHEGROUP])
             && !empty($wp_object_cache->cache[Timber\Loader::CACHEGROUP])) {
             $works = false;
    ----------- end diff -----------


Applied checkers:

 * PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer

@Levdbas
Copy link
Member
Levdbas commented Feb 8, 2024

Thank you @rubas for taking this on. This might fix #2859 as well?

@nlemoine
Copy link
Member
nlemoine commented Feb 8, 2024

for coding standards, you just need to run composer run cs:fix. But you can leave the failing test file or fix it. We'll take care of it later.

@rubas
Copy link
Contributor Author
rubas commented Feb 8, 2024

Thank you @rubas for taking this on. This might fix #2859 as well?

Correct. This is the same bug.

Copy link
Member
@nlemoine nlemoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rubas. This is almost good for me.

Can you add the nullable type to $last_post and a test case for this?

Co-authored-by: Nicolas Lemoine <nico.lemoine@gmail.com>
@nlemoine nlemoine self-requested a review February 23, 2024 11:31
Copy link
Member
@nlemoine nlemoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all good, thanks @rubas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0