Opened 6 years ago
Closed 6 years ago
#44428 closed defect (bug) (duplicate)
update_object_term_cache
Reported by: | sllimrovert | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.6 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
I have a situation where I want to limit access to terms based on some meta about the current user. There's a filter ( 'get_terms_args' ) for when I call get_terms()
that I can use to prevent that from returning the terms I don't want to let them have. However, I also want to prevent when calling get_term
on a specific term.
There's a filter in there called 'get_term'
that I can use. I return null
when the user doesn't have access to it.
With that filter in place, if I call get_posts()
, I get a fatal error within the update_object_term_cache()
function.
I've attached a test case which shows the error.
1) FeedsByTag\test\TermObjectCache::testObjectTermCache Trying to get property of non-object /Users/trevor/Sites/dev/wordpress-develop/src/wp-includes/taxonomy.php:3183
The bug exists in 4.9.6.
It does NOT occur in master
, so something has fixed this for the 5.0 release.
Attachments (1)
Change History (6)
#1
@
6 years ago
- Summary changed from wp_queue_posts_for_term_meta_lazyload to update_object_term_cache
#3
in reply to:
↑ 2
@
6 years ago
Replying to boonebgorges:
Hi @sllimrovert - Thanks for the ticket and for the test!
Have a look at [43049] #42691 - it's likely that this is what fixed the bug in trunk.
Yes, that's likely what fixed it in trunk. Will that be released on a 4.9.x release, or waiting until 5.0?
No matter for me really, I used the pre_get_posts
filter to always set $query->query_vars['update_post_term_cache']
to false for my use case.
Feel free to close this if you feel that's appropriate.
#5
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #42691.
Thanks, @sllimrovert !
Unless there's a clamoring for an earlier fix, it's likely that this will wait until 5.0. If it looks like that release will be delayed significantly, I'll see about advocating for a backport.
Unit test for issue