Opened 12 years ago
Closed 12 years ago
#23026 closed defect (bug) (fixed)
parent_dropdown() should verify that a post has been fetched
Reported by: | mweichert | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | minor | Version: | 3.5 |
Component: | Warnings/Notices | Keywords: | has-patch |
Focuses: | Cc: |
Description
If you call parent_dropdown() and no post has been provided or populated, then an E_NOTICE will be emitted in template.php:683 because $post is null.
The fix is to adjust line 681 from:
if ( $items ) {
to...
if ($post && $items) {
I've attached a patch.
To reproduce:
- Ensure that your server is configured to show E_NOTICE errors.
- Install NextGEN Gallery
- Go to the Manage Galleries Page
- Click on a gallery.
- Voila. ;)
Attachments (2)
Change History (11)
#1
follow-up:
↓ 4
@
12 years ago
- Component changed from Template to Warnings/Notices
- Version changed from trunk to 1.5
#2
@
12 years ago
another issue is that this function can not be used outside of the loop such as within the wp-admin.
A simple fix is to change the function argument declarations from
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
to:
function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = array() ) {
and then also change:
$post = get_post();
to
if ( empty( $post )) { $post = get_post(); }
which would allow a WP post object to be passed into the function.
Sorry I am unable to provide an SVN patch.
#3
follow-up:
↓ 5
@
12 years ago
- Milestone changed from Awaiting Review to 3.6
parent_dropdown_fix.patch looks sane.
Let's leave the enhancement from comment:2 for another ticket.
#4
in reply to:
↑ 1
;
follow-up:
↓ 6
@
12 years ago
Replying to SergeyBiryukov:
Why was this changed to Version 1.5???
That was released like 8 years ago!!!
#5
in reply to:
↑ 3
@
12 years ago
Replying to SergeyBiryukov:
parent_dropdown_fix.patch looks sane.
Let's leave the enhancement from comment:2 for another ticket.
OK I will create one
#6
in reply to:
↑ 4
;
follow-up:
↓ 7
@
12 years ago
Replying to charliespider:
Why was this changed to Version 1.5???
Version number indicates when the issue was initially introduced/reported.
parent_dropdown()
(with that particular piece of code) was introduced in 1.5: [1747].
#7
in reply to:
↑ 6
@
12 years ago
Replying to SergeyBiryukov:
Replying to charliespider:
Why was this changed to Version 1.5???
Version number indicates when the issue was initially introduced/reported.
parent_dropdown()
(with that particular piece of code) was introduced in 1.5: [1747].
ahhh ok
thank you for explaining
I have created a new ticket for my issue: http://core.trac.wordpress.org/ticket/23162
#8
@
12 years ago
- Version changed from 1.5 to 3.5
Actually, this wasn't an issue before [21735], where !empty( $post_ID )
check was removed.
parent_dropdown_fix.patch introduces a change in the behaviour: it makes parent_dropdown()
return false rather than still display the dropdown when being called outside of the loop.
23026.patch keeps the current behaviour and just fixes the notice.
Patch for template.php