php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41540 A probable solution for the Mysterious Warning Message.
Submitted: 2007-05-30 11:53 UTC Modified: 2007-06-01 06:43 UTC
From: essem76 at yahoo dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.2.2 OS: Windows Server 2000
Private report: No CVE-ID: None
 [2007-05-30 11:53 UTC] essem76 at yahoo dot com
Description:
------------
If that iritating warning occurs then check the mistyped PHP variables assigned to session variable.
I faced the same problem and half an hour after getting on my nerves I found the typing mistake and the nasty warning disappeared.
As there aren't many articles when I googled, I thought this might be help someone..

Reproduce code:
---------------
<?php
session_start();
function checkArrEmpty($arr){
	$flag = false;
	if(is_array($arr)) {
		foreach($arr as $val){
			if($val == ""){
				$flag = true; break;
			}
		}
	}
	return $flag;
}
if(!$_SESSION['blnFormDataValid']){
	$arrUserData = $_SESSION['arrFormData'];
}

if(isset($_POST['btnAdd'])){
	$arrFormData = $_POST;
	if(!checkArrEmpty($arrFormData)){
		$_SESSION['blnFormDataValid'] = true;
		$_SESSION['arrFormData'] = "";	//header("location: XTemp.php");	//exit();
	}
	else{//THE following nasty variable mistyped (look for small case d in data) is creating a hell.
		//Simply replace $arrFormdata to $arrFormData and see the difference.
		$_SESSION['arrFormData'] = $arrFormdata;
		$_SESSION['blnFormDataValid'] = false;
	}
}
?>
<form id="frmUser" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<label>First Name: </label><input type="text" name="fName" value="<?php echo $arrUserData['fName']; ?>" /><br/>
	<label>Last Name: </label><input type="text" name="lName" value="<?php echo $arrUserData['lName']; ?>" /><br/>
	<input type="submit" name="btnAdd" value="add" />
</form>

Expected result:
----------------
The code is expected to check the server side validations of the form inputs failing which will generate the same form but with the partially filled values this time.

Actual result:
--------------
The following warning is displayed even in PHP 5.2.0:-

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-30 12:06 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2007-06-01 05:23 UTC] essem76 at yahoo dot com
The thing is that a null value assignment to a session variable is perfectly acceptable. But an already uninitialized php variable can not be assigned to a session variable!! I can't understand why? But..
Also the warning message is also confusing as I am already using version 5.2.0
 [2007-06-01 06:14 UTC] essem76 at yahoo dot com
Here is the stripped down code generating the same problem..
So please discard all the previous and consider only this.

<?php
/* Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 */
//CAN ANYONE HELP ME FINDOUT WHERES THE PROBLEM??!??
session_start();
$arrFormData = $_POST;
$_SESSION['arrFormData'] = $arr;//$arrFormData;//phpinfo();
?>
<form id="frmUser" method="post">
	First Name: <input type="text" name="fName" /> <br/>
	Last Name: <input type="text" name="lName" /> <br/>
	<input type="submit" name="btnAdd" value="add" />
</form>
 [2007-06-01 06:43 UTC] tony2001@php.net
http://php.net/session

Unknown: Your script possibly relies on a session
side-effect which existed until PHP 4.2.3. Please be advised that the
session extension does not consider global variables as a source of
data, unless register_globals is enabled. 
*********You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively.*************
 [2010-11-06 19:07 UTC] scrivimi at mosconimatteo dot com
Warning: Unknown: Your script possibly relies on a session side-effect which 
existed until PHP 4.2.3. Please be advised that the session extension does not 
consider global variables as a source of data, unless register_globals is enabled. 
You can disable this functionality and this warning by setting 
session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown 
on line 0

i'm only 14. i don't understand it....
 [2010-11-06 19:07 UTC] scrivimi at mosconimatteo dot com
Warning: Unknown: Your script possibly relies on a session side-effect which 
existed until PHP 4.2.3. Please be advised that the session extension does not 
consider global variables as a source of data, unless register_globals is enabled. 
You can disable this functionality and this warning by setting 
session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown 
on line 0

i'm only 14. i don't understand it....
 [2010-12-13 20:08 UTC] jaguilar at addax dot cc
Hi, I had the same problem, and in my case it was here
$arrFormData and here $_SESSION['arrFormData']
The thing is having the same variable name. In my case it happened on a $_GET 
array, but I guess it should be similar. Give it a try on renaming the 
$arrFormData variable to something else and let us know if it worked.
 [2011-11-14 14:44 UTC] claudio dot galdiolo at gmail dot com
I disabled the warning adding these lines to my .htaccess (read http://www.php.net/manual/en/configuration.changes.php).

<IfModule mod_php5.c>
	php_value session.bug_compat_42 "0"
	php_value session.bug_compat_warn "0"
</IfModule>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC