[wp-hackers] Re: Revision 2616: Bad cat ID cleanup

Kimmo Suominen kimmo+key+wordpress.c4f53f at suominen.com
Fri May 27 14:56:02 GMT 2005


On 5/27/05, m at wordpress.org <m at wordpress.org> wrote:
>
> function single_cat_title($prefix = '', $display = true ) {
>     $cat = intval( get_query_var('cat') );
>     if( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {

If the query variable 'cat' was non-numeric (e.g. 'ALL'), after applying
intval to it it would be 0 (zero).

Uppercasing the result of intval() would never match 'ALL' (or any
other string), so the comparison is actually a constant false, i.e. the
condition after && is always true.

>From what I understand the code still works correctly, but that second
condition could just be removed due to being a constant.  (The !empty()
check is sufficient due to all strings becoming zero in the intval()
call.)

In addition, it could be noted that passing 'all' or any other string
(or zero) as 'cat' in the query variables results in all categories
being shown.

Regards,
+ Kim
-- 
<A HREF="http://kimmo.suominen.com/">Kimmo Suominen</A>



More information about the wp-hackers mailing list