2.x Update function signatures for ::get_post() and ::get_posts()#2145
2.x Update function signatures for ::get_post() and ::get_posts()#2145gchtr wants to merge 16 commits into2.x-factoriesfrom
Conversation
Use these two functions throughout tests, replace instances of APIs that won’t work in the future.
|
As per #2073 (comment), I guess I should change this against the |
acobster
left a comment
There was a problem hiding this comment.
This is looking great at first glance. I'll dig into this further probably tomorrow. Thanks for adding those Helper notices, those look super helpful!
acobster
left a comment
There was a problem hiding this comment.
Looking great for the most part; please see comments.
|
@acobster I guess I should rebase this pull request against |
# Conflicts: # lib/Helper.php # tests/test-timber-pagination.php # tests/test-timber-post-getter.php
# Conflicts: # lib/Helper.php
# Conflicts: # lib/Timber.php
|
@acobster Do you want to merge this into the |
|
@gchtr let's do in |
|
@gchtr are you waiting on me for a review here? I noticed the WIP tag so I had assumed you were still at-work on this. There are a number of failing tests, mainly related to pagination. Do we need to resolve those here, or is that better done once the merge you and @acobster were discussing is complete? |
|
@jarednova I'm assuming there's going to be a lot of lifting to get these two methods working as we get them over to Factories. That work should probably still be done in |
|
@gchtr @jarednova I just realized I may have misunderstood the question. I don't really have an opinion about whether these fixes happen in Sorry, my brain has been kinda everywhere recently. Maybe you know the feeling. 🙃 |
|
@gchtr the PR has my 👍 on the substance you raise in the original ticket, but I think we should work out (not necessarily solve, but just we're on the same page on this todo you left ...):
Right now I'm imagining that most of this code can be brought over into a new class w/o too much hassle; but just wanted to make sure it wasn't lost. Another thing I encountered when doing some investigation on my local is just the number of jumps from class-to-class a call to You might already be aware or have plans for these. But just wanted to call them out so they don't bite us later! |
23c3421 to
b0d086a
Compare
Issue
Ticket: #2090, #2094 related to
Timber\Postobjects.Solution
Add
Helper::doing_it_wrong()I added aHelper::doing_it_wrong()function, that can be used in combination with a@expectedIncorrectUsagetag in the DocBlock of a test.This is helpful for functionality that will not be deprecated, but removed, like certain function parameters inTimber::get_post()andTimber::get_posts().Added in #2196.
Remove query methods that won’t work anymore
The following methods for retrieving post were removed. Yes, removed and not deprecated, because there will be no backwards compatibility.
post_type=portfolio) and added a doing-it-wrong message.Timber::get_post_from_slug()that could do this (Discussion in 2.x Documentation for API #2073).Deprecate
Timber::query_post()andTimber::query_posts()The
Timber::query_post()andTimber::query_posts()functions weren’t properly deprecated yet.Return a
PostCollectionAs per the new API, we always return a
PostCollectionwhen usingTimber::get_posts(). That’s why I changed the current implementation throughPostGetter::get_posts()to usetruefor thereturn_collectionparameter inTimber::get_posts().However, a lot of tests still break, because
Timber::get_posts()doesn’t return aPostCollection()with the ability to handle pagination yet. I guess we’ll first have to makeTimber::get_posts()use the new API before this can be merged. @acobster How would you proceed here?Impact
This will break backwards compatibility with how
Timber::get_post()andTimber::get_posts()worked before. But I added checks and warnings to help developers in the transition.Usage Changes
See #2073.
Considerations
To keep discussion in one place, I added some remarks and questions in #2073 (comment).
Testing
Yes, but work in progress.
Todo
$optionsforTimber::get_posts()Timber::get_posts()return aPostCollectionthat can handle pagination.Iterableas return type forTimber::get_posts(), see 2.x Documentation for API #2073 (comment).