Make WordPress Core

Opened 16 years ago

Closed 13 years ago

#16472 closed defect (bug) (maybelater)

set_query_var() / get_query_var() does not work for NULL values

Reported by: hakre Owned by:
Priority: normal Milestone:
Component: Query Version:
Severity: normal Keywords: has-patch needs-unit-tests
Cc: Focuses:

Description

Setting a query var to NULL will convert it into an empty string:

$name = 'test';
$value = NULL;
set_query_var($name, $value);
$get = get_query_var($name);
echo $value === $get ? 'same' : 'different';
var_dump($get);

This will output "different" and showing that the query var now is an empty string.

Attachments (1)

16472.patch​ (425 bytes ) - added by hakre 16 years ago.

Download all attachments as: .zip

Change History (5)

#1 @markjaquith
16 years ago

  • Milestone Awaiting Review → Future Release

#2 @nacin
13 years ago

  • Component General → Query

#3 @wonderboymusic
13 years ago

  • Keywords needs-unit-tests added
  • Milestone Future Release → 3.9

I have gotten bitten by this (null + isset()) a few times recently

#4 @wonderboymusic
13 years ago

  • Milestone 3.9
  • Resolution → maybelater
  • Status new → closed

This change breaks 100 unit tests. I can't even fathom the unintended side effects this would introduce. In most cases, we check ! empty() anyway, so null and empty string are evaluated the same.

Note: See TracTickets for help on using tickets.