Opened 12 years ago
Closed 12 years ago
#24034 closed defect (bug) (fixed)
Filtering show_post_format_ui and returning false results in a fatal error
Reported by: | tlovett1 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Post Formats | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Title says it all. Filtering and returning false results in this error on the post edit screen:
Catchable fatal error: Object of class CLASS_ADDING_FILTER could not be converted to string in /srv/www/trunk/wp-admin/edit-form-advanced.php on line 409
My patch simple declares $post_format_options outside of the if statement. Since the variable was getting checked with empty() and it wasn't initialized, it was passing through the check resulting in a fatal error.
Attachments (1)
Change History (6)
#1
@
12 years ago
I see how this could be a notice, but I think I'm missing how it fatals. Could you give us a snippet of code with the filter that triggers this?
#2
@
12 years ago
An empty()
check doesn't require the variable to be initialized.
From the error message, looks like you're redefining the $post_format_options
global with your class.
#3
@
12 years ago
Yep, just caught this. False alarm. I globalized a variable $post_format_options in a plugin. The variable should still be moved outside the conditional, however. It is very possible people will globalize a variable called $post_format_options.
#4
@
12 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 3.6
Reproduced the error with this snippet:
add_filter( 'show_post_format_ui', '__return_false' ); $post_format_options = new stdClass;
patch-post-format-filter-fix.diff makes sense to me.
Patch moves $post_format_options outside of if statement checking show_post_format_ui filter