WordPress.org

Make WordPress Core

Changes between Initial Version and Version 7 of Ticket #15292


Ignore:
Timestamp:
03/04/2011 03:45:56 AM (7 years ago)
Author:
scribu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15292

    • Property Keywords 3.2-early has-patch added; query get_post meta meta_value removed
    • Property Owner set to dd32
    • Property Status changed from new to accepted
    • Property Milestone changed from Awaiting Review to Future Release
  • Ticket #15292 – Description

    initial v7  
    22
    33My Case:
    4 ...
     4
     5{{{
    56'meta_key' => '_menu_item_menu_item_parent',
    67'meta_value' => '0',
    7 ...
     8}}}
    89
    910wp-includes/query.php Line 2307 is:
    10 if ( ! empty($q['meta_value']) ) {
     11{{{if ( ! empty($q['meta_value']) ) {}}}
    1112
    12 But empty says that String "0" is true (look here: http://ch2.php.net/empty )
     13But empty() says that String "0" is true
    1314
    1415So the query will return all posts that have a meta-field "_menu_item_menu_item_parent" and not only the posts with "_menu_item_menu_item_parent = 0" (which means, that it's an menu root item)
    1516
    1617My solution is:
     18
     19{{{
    1720if (( ! empty($q['meta_value']) ) || ($q['meta_value'] == '0')) {
     21}}}
    1822
    1923but that's not very nice. Any better idea?