WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

#16472 closed defect (bug) (maybelater)

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

Reported by: 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 3 years ago.

Download all attachments as: .zip

Change History (5)

hakre3 years ago

comment:1 markjaquith3 years ago

  • Milestone changed from Awaiting Review to Future Release

comment:2 nacin3 months ago

  • Component changed from General to Query

comment:3 wonderboymusic3 months 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

comment:4 wonderboymusic3 months 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.