Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New Bug in RC2?


sojomy

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

  • 2 months later...
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.

Link to comment
Share on other sites

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]);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 4 months later...
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 );

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 year later...

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?)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...