-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
2.x Deprecate Timber\PostClassMap filter and rename it to timber/post/classmap #2293
Conversation
@gchtr I don't think it's necessary to go too deep on the deprecation protections here (beyond what you've done already). The way classes are handled with Factories means so many changes that I don't think a single "missing" Would you like me to develop tests here or do you already have that covered? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to make sure we have proper tests in place ...
👍
@jarednova Currently, you could only add tests for the deprecation of the filter, but not how the post class map actually works, because Coby is still working on that. But I’d be glad if you could add the tests for the deprecation. |
The Class Map filters are all tested at the Factory layer. We don't have any My main concern in this area is what happens when someone returns a class name from a |
@acobster if I'm following you here correctly, I think the place to go is with ...
Since it's a fatal error, an exception would feel most appropriate. In the docs for WordPress's |
@gchtr for some reason this is triggering a ton of ...
warnings in PHPUnit. I'm trying to rope through and figure out where that's originating, but can't seem to track it down. Is this worth time? or does the forthcoming work from @acobster (perhaps) render that irrelevant? |
Discussion is a bit scattered. I guess we discussed this in #2073 (comment) and then further in #2196, which led to this issue for the future: #2210.
I would really wait for the rest of the post factories to be implemented first, and then come back to see how we do error handling. I only wanted to work alongside Coby. There are a few other pull requests that also need to wait for other functionality. I’m going to add |
23c3421
to
b0d086a
Compare
FYI I updated the base branch here just to compare with the bleeding-edge Post API. We can still move forward with this (or not) however we choose. @gchtr I think the TODOs for this PR boil down to:
cc @jarednova |
…-filter # Conflicts: # lib/Factory/PostFactory.php
By matching the variable name in the DocBlock, we get better type hinting support in the DocBlock in certain IDEs
I had to merge in the current version of the
Could we add a call to the deprecated filter right before we use the /**
* Filters the class(es) used for different post types.
*
* @deprecated 2.0.0, use `timber/post/classmap`
*/
if ( 'deprecated' !== apply_filters( 'Timber\PostClassMap', 'deprecated' ) ) {
\Timber\Helper::deprecated(
'The `Timber\PostClassMap` filter',
'the `timber/post/classmap` filter',
'2.0.0'
);
}
// ...
$classmap = …
Should be okay now.
I’d be glad if you could add that! |
2.x factories NOTE: THIS DOES NOT CONTAIN UP TO DATE DOCS ABOUT THE NEW API The 2.x-docs-api API branch (PR #2073) is where overall API changes for 2.x are being tracked and discussed. At time of writing these are the tasks remaining before the 2.0 API/docs are production-ready: * Deprecate Timber\PostClassMap filter and rename it to timber/post/classmap. Currently, it’s called timber/post/post_class in the 2.x branch. #2293 * Determine what happens when a timber/*/classmap filter callback returns something other than a CoreInterface. (Probably should throw an exception rather than just letting it TypeError.) - also #2293 * Finalize type declarations #1863 * Implement the new PagesMenu API. #2292 * Implement ::get_image() and ::get_attachment() top-level methods and corresponding Twig functions. #2333 #2342
# Conflicts: # lib/PostGetter.php
@acobster @jarednova I could still use some feedback on my recent comment, so we can finalize this 😊. By merging in the current 2.x branch, we lost the |
@gchtr I see - just some extra guardrails around the new hooks, warning of the old usage. Makes sense! I will add that in along with the Exceptions, probably some time next week. |
@jarednova This is now good for another review. I added my proposal from #2293 (comment) and added a test to make sure it works as expected. And I added the remaining todo as a separate issue in #2487 so that it doesn’t get lost. |
This looks good! (and feels like how it should have now always been). Thanks for pulling in some of those lingering notes and capturing #2487 for the future |
Ticket: #2073
This pull request handles the following todo in #2073.
The filter
timber/post/post_class
was added in the2.x
way earlier, so it’s safe to remove it.Considerations
I guess were not exactly deprecating the
Timber\PostClassMap
filter, because it will not work the way it did before. We can also consider usingHelper::doing_it_wrong()
instead. On the other hand, when upgrading to2.0
, you will want to remove all notices that will appear, including the notices about deprecated hooks. So maybe it doesn’t really matter.What do you think?
Testing
Not yet.Now added.