Make WordPress Core

Opened 14 years ago

Closed 11 years ago

#16472 closed defect (bug) (maybelater)

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

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

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 14 years ago.

Download all attachments as: .zip

Change History (5)

@hakre
14 years ago

#1 @markjaquith
14 years ago

  • Milestone changed from Awaiting Review to Future Release

#2 @nacin
11 years ago

  • Component changed from General to Query

#3 @wonderboymusic
11 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Future Release to 3.9

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

#4 @wonderboymusic
11 years ago

  • Milestone 3.9 deleted
  • Resolution set to maybelater
  • Status changed from new to 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.