Zen Cart Logo
Forums / Bug Reports / [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

[Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Locked

Views: 25,753

Results 1 to 20 of 43
This thread is locked. New replies are disabled.
20 Mar 2011, 12:34 AM
#1
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,806
Plugin Contributions:
15

[Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

This continues to mess with my brain (an admittedly easy task!).

Several of our sites are getting > PHP Warning: strlen() expects parameter 1 to be string, array given in /home/site_name/public_html/includes/functions/functions_general.php on line 152

Commonalities are minimal other than all sites effected are 1.3.9h and all debug files to the cache directory are timestamped at the conclusion of an order. All have IH2 and Fual Slimbox. Some have captcha and newsletter subscription, but we get the error on sites with neither, just one, or both of those mods.:dontgetit

Whether the site is using AIM, PayPal, Ceon's offline, or some other payment module seems to make no difference. AND, only occasionally does any site throw this error. One site has 25+ orders this month with a mixture of PayPal and AIM. Only two orders (one for each) has thrown the error.

We have checked and re-checked for current PayPal and AIM files along with other payment mods.

No changes have been made to customer database settings or files gathering/forwarding customer data.

If it would JUST BREAK already, we could fix it.:frusty:

Any suggestions of other things we might check would be GREATLY appreciated.

20 Mar 2011, 1:21 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Not that I can assist but you left out php ver & mysql ver

20 Mar 2011, 1:27 AM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,709
Plugin Contributions:
56

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Try inserting above l 152:

if (is_null($value)) continue;

20 Mar 2011, 2:24 AM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,806
Plugin Contributions:
15

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Should read my sig, huh?:blush:

PHP 5.3.3 MySQL 5.0.67 for all.

20 Mar 2011, 3:15 AM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Did you try the suggestion from swguy?

Looks to be a workaround, but there must be a root cause as I have never seen this error

20 Mar 2011, 3:27 AM
#6
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,806
Plugin Contributions:
15

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

definitely a work around and will take days or weeks to see if it works, but will stick it in a couple of the more active sites.

I've come close to finding similar items in the forum, but just when you think you might have found the answer.......:lamo:

16 Apr 2011, 4:28 PM
#7
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,806
Plugin Contributions:
15

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Narrowed down to something coming from authorize.net in completing a purchase. Error was on the 13th and it's coming 25 seconds after the purchase is logged.

Odd that it doesn't happen on the 15th. Only difference I can see between the two orders is that the 15th has a different shipping from billing.

:frusty:

17 Apr 2011, 12:09 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

If the warning is triggering on strlen($value), try moving that to the end of the testing list so other conditions are parsed first.

The strlen() function wants a string, and if one of the keys holds an array, that would probably be the cause. What could the 'error' consist of?
&& ($key != 'error')
It would cease processing if $key did equal 'error'.```php
if ( (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {

18 Jun 2011, 1:21 AM
#9
wirefram avatar

wirefram

New Zenner

Join Date:
Apr 2011
Posts:
95
Plugin Contributions:
0

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

did anyone find out what to do to solve this php warming?

I am having the same problem....

:(

18 Jun 2011, 1:31 AM
#10
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,806
Plugin Contributions:
15

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Still rearing it's ugly head from time to time but have not aggressively pursued it as I can't seem to find anything that dies because of it.:dontgetit

Are you actually able to determine anything that is not working due to this error?

18 Jun 2011, 5:27 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

dbltoe:

Any suggestions of other things we might check would be GREATLY appreciated.From a diagnostics perspective, you could try to capture information about whatever the offending component is by inserting this line at line 152:```
if (is_array($value)) trigger_error('GET param found to be array: ' . print_r($value, true) . ' --- contents of GET: ' . print_r($_GET, true));


DO NOT TRY THIS IF YOU ARE USING A VERSION OLDER THAN v1.3.9a !!!!!!!!!
3 Oct 2011, 3:49 PM
#12
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

I got a debug file with this identical error today.
First error ever on the live shop.

Order confirmed at 15:19:58 (using 4b payment module, Spain)
Debug Warning at 15:20:24

ZC 1.39h
PHP Version: 5.3.8 (Zend: 2.3.0)
PHP Safe Mode: Off
PHP Memory Limit: 128M
Database: MySQL 5.0.92-community-log
HTTP Server: Apache

Main mods, IH2, Ceon Advanced Shipper, 4b payment module...a long list.

I've put in the suggested debug code.

6 Oct 2011, 3:56 PM
#13
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Ok, I got two of these today.

Order at 10:53:12
Debug at 10:54:01
Payment - Moneyorder
Shipping - Advanced Shipper

[06-Oct-2011 10:54:01] PHP Notice: GET param found to be array: Array
(
[0] => 47
)
--- contents of GET: Array
(
[main_page] => index
[action] => notify
[notify] => Array
(
[0] => 47
)

)
in /whatever/includes/functions/functions_general.php on line 152
[06-Oct-2011 10:54:01] PHP Warning: strlen() expects parameter 1 to be string, array given in /whatever/includes/functions/functions_general.php on line 1532)
Order at 11:48:57
Debug at 11:49:25
Payment - 4b (offsite credit card gateway)
Shipping - Advanced Shipper
[06-Oct-2011 11:49:25] PHP Notice: GET param found to be array: Array
(
[0] => 56
)
--- contents of GET: Array
(
[main_page] => index
[action] => notify
[notify] => Array
(
[0] => 56
)

)
in /whatever/includes/functions/functions_general.php on line 152
[06-Oct-2011 11:49:25] PHP Warning: strlen() expects parameter 1 to be string, array given in /whatever/includes/functions/functions_general.php on line 153I don't find anything I can relate to those numbers 47 and 56 in the order.

So, any more clues I can give you?

Thanks
Steve

6 Oct 2011, 4:53 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Why are you passing a [notify] in your $_GET in the first place? What addon is doing that, and why?

7 Oct 2011, 5:00 AM
#15
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Why are you passing a [notify] in your $_GET in the first place?No idea. Nothing I have actually coded myself.

I've done some searching and the only references I can find to notify and get would be in the shopping cart class, for example:

zen_redirect(zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action', 'notify', 'main_page'))));

but this is a stock file and I don't really understand what I'm looking at or for.

Can you suggest more that I can add to the debug info to help locate this? Or a construct I could search for in the code?

7 Oct 2011, 5:23 AM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

dbltoe:

Still rearing it's ugly head from time to time but have not aggressively pursued it as I can't seem to find anything that dies because of it.:dontgetit

Are you actually able to determine anything that is not working due to this error?It's only a "PHP Warning", so is not causing any script executions to fail.
Thus, it's a minor issue.

Indeed, thanks to some of torvista's debug data, I've found the cause, and it's an extremely minor issue.

dbltoe:

Several of our sites are getting:
PHP Warning: strlen() expects parameter 1 to be string, array given in /home/site_name/public_html/includes/functions/functions_general.php on line 152

Commonalities are ... all debug files to the cache directory are timestamped at the conclusion of an order.
...
AND, only occasionally does any site throw this error. One site has 25+ orders this month with a mixture of PayPal and AIM. Only two orders (one for each) has thrown the error.
It only occurs at the conclusion of an order because it's specifically triggered only when the user is presented with a list of product-notification choices and they click the submit button on that page to update those choices. (It might also trigger on the account_notifications page if they were to visit there.)

The warning is harmless, and can be safely ignored.

If it's keeping you awake at night, you could move the in_array() condition check to the beginning of the list, by changing the line from if ( (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {to```
if ( (!in_array($key, $exclude_array)) && (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {

7 Oct 2011, 5:35 AM
#17
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Personally, I would think that any error/warning causing myDebug files to be continuously created, should be corrected. Else, they will continue to eat up hosting space and at some point would need to be manually removed.

The solution posted to end all that, for those with this particular problem, will be most helpful.

7 Oct 2011, 5:46 AM
#18
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

If it's keeping you awake at night,Absolutely!

Thanks for the solution.

17 Oct 2011, 11:45 AM
#19
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

just got a new debug using modified code as above:

[17-Oct-2011 09:39:27] PHP Notice: GET param found to be array: Array
(
[0] => 280
)
--- contents of GET: Array
(
[main_page] => index
[action] => notify
[notify] => Array
(
[0] => 280
)

)
in blah..blah/includes/functions/functions_general.php on line 152

17 Oct 2011, 1:40 PM
#20
wirefram avatar

wirefram

New Zenner

Join Date:
Apr 2011
Posts:
95
Plugin Contributions:
0

Re: [Fixed v1.5.1] PHP Warning: strlen() expects parameter 1 to be string

Hi

Did you apply the modification suggested by DrByte?

I did and I no longer have the error, if you check the new beta version 1.5 this modif is applied in the file functions_general.php.

:huh: