[PHP-BUG] Bug #55650 [NEW]: !empty($_GET[$key][$subkey])) always returns false if $_GET[$key] is set

2011-09-08 Thread chris dot wisefool at gmail dot com
From: 
Operating system: Windows 6.1 build 7600 i586
PHP version:  5.3.8
Package:  Built-in web server
Bug Type: Bug
Bug description:!empty($_GET[$key][$subkey])) always returns false if 
$_GET[$key] is set

Description:

Running on PHP Version 5.3.5, EasyPHP Server Apache.
The test code on my system shows "SEARCH FILTER PARAM WAS PROVIDED" if
?search=1 
is passed for the query string but curiously not if ?search[a]=1 is
provided. 
Based on some other bug reports (#27677) I thought maybe the behavior was
correct, 
but if so then it seems a bug that when _GET is manually set to the same
value 
instead of set by PHP parsing the query string, that it gives different
results. 
So it seems a bug either way. :)


Test script:
---
http://somesite/?search=1
if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS
PROVIDED!';

# The REALLY odd thing is if I do this it does give the expected results:
$_GET 
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

1);
var_dump($_GET);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';


Expected result:

SEARCH FILTER PARAM WAS PROVIDED if ?search[filter]=1 provided
No "SEARCH FILTER PARAM WAS PROVIDED" if ?search=1

Actual result:
--
SEARCH FILTER PARAM WAS PROVIDED if ?search=1 or ?search[filter]=1 provided

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55650&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55650&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55650&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=55650&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55650&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55650&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55650&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=55650&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=55650&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=55650&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=55650&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=55650&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=55650&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=55650&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55650&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=55650&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=55650&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=55650&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=55650&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=55650&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=55650&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=55650&r=mysqlcfg



Bug #55650 [Opn]: !empty($_GET[$key][$subkey])) always returns false if $_GET[$key] is set

2011-09-08 Thread chris dot wisefool at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=55650&edit=1

 ID: 55650
 User updated by:chris dot wisefool at gmail dot com
 Reported by:chris dot wisefool at gmail dot com
 Summary:!empty($_GET[$key][$subkey])) always returns false
 if $_GET[$key] is set
 Status: Open
 Type:   Bug
 Package:Built-in web server
 Operating System:   Windows 6.1 build 7600 i586
 PHP Version:5.3.8
 Block user comment: N
 Private report: N

 New Comment:

Either the form munged part of my data (unlikely) or I pasted it in wrong. The 
line after 

if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

should be

$_GET = array('search'=>1);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

I'd edit it, but it seems you can't: you can only add comments...


Previous Comments:
--------------------
[2011-09-09 06:29:54] chris dot wisefool at gmail dot com

Description:

Running on PHP Version 5.3.5, EasyPHP Server Apache.
The test code on my system shows "SEARCH FILTER PARAM WAS PROVIDED" if 
?search=1 
is passed for the query string but curiously not if ?search[a]=1 is provided. 
Based on some other bug reports (#27677) I thought maybe the behavior was 
correct, 
but if so then it seems a bug that when _GET is manually set to the same value 
instead of set by PHP parsing the query string, that it gives different 
results. 
So it seems a bug either way. :)


Test script:
---
http://somesite/?search=1
if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

# The REALLY odd thing is if I do this it does give the expected results:
$_GET 
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

1);
var_dump($_GET);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';


Expected result:

SEARCH FILTER PARAM WAS PROVIDED if ?search[filter]=1 provided
No "SEARCH FILTER PARAM WAS PROVIDED" if ?search=1

Actual result:
--
SEARCH FILTER PARAM WAS PROVIDED if ?search=1 or ?search[filter]=1 provided






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55650&edit=1


Bug #55650 [Opn]: !empty returns false positive if subkey not set, but not if _GET is set manually

2011-09-08 Thread chris dot wisefool at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=55650&edit=1

 ID: 55650
 User updated by:chris dot wisefool at gmail dot com
 Reported by:chris dot wisefool at gmail dot com
-Summary:!empty($_GET[$key][$subkey])) always returns false
 if $_GET[$key] is set
+Summary:!empty returns false positive if subkey not set, but
 not if _GET is set manually
 Status: Open
 Type:   Bug
 Package:Built-in web server
 Operating System:   Windows 6.1 build 7600 i586
 PHP Version:5.3.8
 Block user comment: N
 Private report: N

 New Comment:

Reworded bug summary to be more descriptive and succinct


Previous Comments:

[2011-09-09 06:39:54] chris dot wisefool at gmail dot com

Either the form munged part of my data (unlikely) or I pasted it in wrong. The 
line after 

if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

should be

$_GET = array('search'=>1);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

I'd edit it, but it seems you can't: you can only add comments...

--------------------
[2011-09-09 06:29:54] chris dot wisefool at gmail dot com

Description:

Running on PHP Version 5.3.5, EasyPHP Server Apache.
The test code on my system shows "SEARCH FILTER PARAM WAS PROVIDED" if 
?search=1 
is passed for the query string but curiously not if ?search[a]=1 is provided. 
Based on some other bug reports (#27677) I thought maybe the behavior was 
correct, 
but if so then it seems a bug that when _GET is manually set to the same value 
instead of set by PHP parsing the query string, that it gives different 
results. 
So it seems a bug either way. :)


Test script:
---
http://somesite/?search=1
if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

# The REALLY odd thing is if I do this it does give the expected results:
$_GET 
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

1);
var_dump($_GET);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';


Expected result:

SEARCH FILTER PARAM WAS PROVIDED if ?search[filter]=1 provided
No "SEARCH FILTER PARAM WAS PROVIDED" if ?search=1

Actual result:
--
SEARCH FILTER PARAM WAS PROVIDED if ?search=1 or ?search[filter]=1 provided






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55650&edit=1


Bug #55650 [Opn->Csd]: !empty returns false positive if subkey not set, but not if _GET is set manually

2011-09-09 Thread chris dot wisefool at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=55650&edit=1

 ID: 55650
 User updated by:chris dot wisefool at gmail dot com
 Reported by:chris dot wisefool at gmail dot com
 Summary:!empty returns false positive if subkey not set, but
 not if _GET is set manually
-Status: Open
+Status: Closed
 Type:   Bug
 Package:Built-in web server
 Operating System:   Windows 6.1 build 7600 i586
 PHP Version:5.3.8
 Block user comment: N
 Private report: N

 New Comment:

After slightly changing my code example to:

'1');
var_dump($_GET);
if (!empty($_GET['search']['filter']))
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

The results do seem consistent with the behavior as explained in #27677 (I see 
that the behavior didn't occur when set manually because I was setting 'search' 
to 1 NOT '1' and the subscripting behavior only occurred with strings. 

So it seems the behavior is correct per PHP's documentation, just not my 
assumptions based on that documentation. It means to test for a subkey you have 
to use the longer !empty($_GET['search']) && array_key_exists('filter', 
$_GET['search']) && is_array($_GET['search']['filter']), but hey, that's life :)

So I'm closing the bug.


Previous Comments:

[2011-09-09 06:42:33] chris dot wisefool at gmail dot com

Reworded bug summary to be more descriptive and succinct


[2011-09-09 06:39:54] chris dot wisefool at gmail dot com

Either the form munged part of my data (unlikely) or I pasted it in wrong. The 
line after 

if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

should be

$_GET = array('search'=>1);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

I'd edit it, but it seems you can't: you can only add comments...


[2011-09-09 06:29:54] chris dot wisefool at gmail dot com

Description:

Running on PHP Version 5.3.5, EasyPHP Server Apache.
The test code on my system shows "SEARCH FILTER PARAM WAS PROVIDED" if 
?search=1 
is passed for the query string but curiously not if ?search[a]=1 is provided. 
Based on some other bug reports (#27677) I thought maybe the behavior was 
correct, 
but if so then it seems a bug that when _GET is manually set to the same value 
instead of set by PHP parsing the query string, that it gives different 
results. 
So it seems a bug either way. :)


Test script:
---
http://somesite/?search=1
if (!empty($_GET['search']['filter'])) echo 'SEARCH FILTER PARAM WAS PROVIDED!';

# The REALLY odd thing is if I do this it does give the expected results:
$_GET 
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';

1);
var_dump($_GET);
if (!empty($_GET['search']['filter'])) 
   echo 'SEARCH FILTER PARAM WAS NOT PROVIDED!';


Expected result:

SEARCH FILTER PARAM WAS PROVIDED if ?search[filter]=1 provided
No "SEARCH FILTER PARAM WAS PROVIDED" if ?search=1

Actual result:
--
SEARCH FILTER PARAM WAS PROVIDED if ?search=1 or ?search[filter]=1 provided






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55650&edit=1