sojomy Posted January 21, 2008 Posted January 21, 2008 I just did a clean install of osC 2.2 RC2 and I am getting a new error that I did not get in RC1 or any version before that I've used. I can't make it happen myself, but I am getting these errors sometimes. When it happens it will show up 3-5 times in the log file and it's at random times. The IP address I got from the access log at that time was 66.249.70.77 which comes back as a googlebot. Here is the error [21-Jan-2008 15:12:19] PHP Warning: array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The second argument should be either an array or an object in C:\Webroot\DOMAINNAME\includes\functions\sessions.php on line 127 In my sessions.php file, the RC1 version is return isset($_SESSION[$variable]); And the newer RC2 version is return array_key_exists($variable, $_SESSION); It seems that the error is because the array_key_exists function is called using the $_SESSION variable, and the $_SESSION variable isn't set at the time this code is run. I'm assuming that the errors I am getting are because google (or other) spiders are crawling through the site and they don't create a session variable, but I'm confused as to why. And more importantly, why was the code changed, and should it be changed back or changed to something else to not give errors when a spider visits the site?
web-project Posted January 22, 2008 Posted January 22, 2008 RC2 - release candidate, it doesn't mean the final stable release. you will get few more bugs in RC2. Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you.
user99999999 Posted January 22, 2008 Posted January 22, 2008 Try this to fix it. return (is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false); I guess this would be a reason to change it. Example#2 array_key_exists() vs isset() isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does. <?php $search_array = array('first' => null, 'second' => 4); // returns false isset($search_array['first']); // returns true array_key_exists('first', $search_array); ?>
BryceJr Posted January 25, 2008 Posted January 25, 2008 Try this to fix it. return (is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false); I'm using RC2. I tested this several times in my local machine. If "Force Cookie" is enabled/true and the customer doesn't have the site cookie present, this message shows up in several lines. Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in catalog\includes\functions\sessions.php on line 127 The warning message disappears when 1. the user clicks any link a few times within the site thus setting a cookie OR 2. "Force Cookie" is disabled/false in sessions. This is my line 127 with your fix applied(blue). I Commented the offending line (red). function tep_session_is_registered($variable) { if (PHP_VERSION < 4.3) { return session_is_registered($variable); } else { //return array_key_exists($variable, $_SESSION); return (is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false); Thanks for this fix. It works.
gomikeyp Posted February 19, 2008 Posted February 19, 2008 This didn't fix for me. I got this error after installing AJAX Attribute Manager contribution. Here's the error msg I'm getting... Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: Cannot modify header information - headers already sent by (output started at /home/sakari/public_html/catalog/admin/includes/functions/sessions.php:123) in /home/sakari/public_html/catalog/admin/attributeManager/attributeManager.php on line 71 The error msg only comes up in the Product add/edit page right above the attributes template. Please help. Thanks Michael
waitfy Posted May 6, 2008 Posted May 6, 2008 This didn't fix for me. I got this error after installing AJAX Attribute Manager contribution. Here's the error msg I'm getting... Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/sakari/public_html/catalog/admin/includes/functions/sessions.php on line 123 Warning: Cannot modify header information - headers already sent by (output started at /home/sakari/public_html/catalog/admin/includes/functions/sessions.php:123) in /home/sakari/public_html/catalog/admin/attributeManager/attributeManager.php on line 71 The error msg only comes up in the Product add/edit page right above the attributes template. Please help. Thanks Michael Me too. I have the same Warning Error msg.Did anyone can give us some help... I recieved the msg when I finish install tha AJAX Attribute Manager contribution. Thank you for any idea.
waitfy Posted May 6, 2008 Posted May 6, 2008 Me too.I have the same Warning Error msg.Did anyone can give us some help... I recieved the msg when I finish install tha AJAX Attribute Manager contribution. Thank you for any idea. I have solved it. bellow: About the 123 error ! In: admin/includes/functions/sessions.php change line 123 "return isset($_SESSION) && array_key_exists($variable, $_SESSION);" to return isset($_SESSION[$variable]);
arietis Posted May 7, 2008 Posted May 7, 2008 return isset($_SESSION[$variable]); i'm not sure you want to use this, for the reason stated in the third post in this thread by user99999999: isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does. this is likely the reason for the code to be changed to what you have now. the following code, posted previously, should work: return (is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false); if that doesn't, try using the following: return isset($_SESSION) && array_key_exists($variable, $_SESSION); this is what my code looks like, which is from a recent code release and i haven't had any problem with it. there really isn't much difference between the two, so i'm not sure why you'd be having problems with the first example. if you're still having problems, post the code you're using. there might be some other subtle difference causing the problem. it could also have something to do with the version of php you're using - so let us know which version.
Paul J. McCain Posted May 22, 2008 Posted May 22, 2008 thank you so much, I was having the same problem! I had the attributes manager and then upgraded to RC2. The second suggested fix worked! return isset($_SESSION[$variable]); Thanks! Paul
Alex Zuyev Posted July 16, 2008 Posted July 16, 2008 I had the same error and return isset($_SESSION[$variable]); helped! Thanx! Best wishes, Alex Z.
morehawes Posted November 27, 2008 Posted November 27, 2008 Same problem, this also worked for me: return isset($_SESSION[$variable]); Joe. Joe MacMan strikes again! Always backup first before listening to me!
♥FWR Media Posted November 27, 2008 Posted November 27, 2008 Same problem, this also worked for me: return isset($_SESSION[$variable]); Joe. This is not correct it should be .. return ( isset($_SESSION) && is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false ); Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
♥FWR Media Posted November 27, 2008 Posted November 27, 2008 Actually no RC2a code is correct ... return isset($_SESSION) && array_key_exists($variable, $_SESSION); What's happening is some bad code is creating a scalar variable called $_SESSION when the session is not set. Therefore $_SESSION exists but it is not an array. By breaking the code as listed in posts above you are just hiding the error with bad code. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
morehawes Posted November 27, 2008 Posted November 27, 2008 OK, thanks for the info! Joe Joe MacMan strikes again! Always backup first before listening to me!
bhbilbao Posted August 2, 2010 Posted August 2, 2010 Need urgent help with this problem. I have tried diferent methods: 1 return isset($_SESSION[$variable]); 2 return ( isset($_SESSION) && is_array($_SESSION) ? array_key_exists($variable, $_SESSION) : false ); 3 return isset($_SESSION) && array_key_exists($variable, $_SESSION); 4 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT); 5 error_reporting(0); 6 error_reporting(E_ERROR | E_WARNING | E_PARSE); Please help, I dont know what could be the correct code. My problem is with Google Index SEO, when searching the net with google if I click on See Cache versión, it appears the uggly errors reporting, in special this report. Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/6/d3086888888/htdocs/includes/functions/sessions.php on line 127 P.D: on normal view on the web there is no errors reporting, only when clickin the caché version. My php versión is 5.2, osCommerce 2.2 Milestone 2 (I dont know if I installed the 2.2rc2a, how to know this?)
Jan Zonjee Posted August 2, 2010 Posted August 2, 2010 Please help, I dont know what could be the correct code. The line 3 (see last post of FWR Media in this thread) is the one that will be in the next version. I suppose it will take a while before these cached versions will be gone from Google.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.