Zen Cart Logo
Forums / General Questions / PHP warnings suddenly start appearing in the log folder

PHP warnings suddenly start appearing in the log folder

Views: 1,881

Results 1 to 20 of 27
11 Mar 2015, 11:30 AM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

PHP warnings suddenly start appearing in the log folder

Yesterday just as I uploaded one file, php warnings started appearing in the log folder. Not error messages, warnings. I've seen this happen in one other website and was never able to figure it out. In that case, I couldn't pinpoint when it started. I ended up simply writing a script to empty out those logs with a cron job to keep the number of files to a low amount.

In this case, I can pinpoint the minute this started and it happened at the same time that I uploaded some files. There is nothing in those files I uploaded that would start this as I have used them many times before.

php version is 5.3.29. Nothing looks out of the norm. There are two installations of zc that are connecting to one database and the warnings are showing in both log folders. I made no changes to one cart at all. The installation I uploaded the files to is a default set of 1.5.1 with some template changes - no core changes and the file I uploaded that has the same time stamp is just a template file. I tried removing it but it didn't stop this from happening.

I really have to figure this out this time - cart owner is not going to accept my stop gap measure of log file deletion.

11 Mar 2015, 11:36 AM
#2
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: PHP warnings suddenly start appearing in the log folder

delia:

Yesterday just as I uploaded one file, php warnings started appearing in the log folder. Not error messages, warnings. I've seen this happen in one other website and was never able to figure it out. In that case, I couldn't pinpoint when it started. I ended up simply writing a script to empty out those logs with a cron job to keep the number of files to a low amount.

In this case, I can pinpoint the minute this started and it happened at the same time that I uploaded some files. There is nothing in those files I uploaded that would start this as I have used them many times before.

php version is 5.3.29. Nothing looks out of the norm. There are two installations of zc that are connecting to one database and the warnings are showing in both log folders. I made no changes to one cart at all. The installation I uploaded the files to is a default set of 1.5.1 with some template changes - no core changes and the file I uploaded that has the same time stamp is just a template file. I tried removing it but it didn't stop this from happening.

I really have to figure this out this time - cart owner is not going to accept my stop gap measure of log file deletion.

What is the contents of the log file?

you can use this module myDEGUB Backtrace to obtain more information about erors

11 Mar 2015, 11:39 AM
#3
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: PHP warnings suddenly start appearing in the log folder

delia:

...In this case, I can pinpoint the minute this started and it happened at the same time that I uploaded some files. There is nothing in those files I uploaded that would start this as I have used them many times before.

Obvious questions:

What happens if you get these new files off the server?
Is it possible to do this without breaking cart functionality?
Are you still getting the same warnings after deletion of these new files?

11 Mar 2015, 11:51 AM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

[11-Mar-2015 07:06:12 America/New_York] #1 substr() called at [/home/scrappin/public_html/includes/functions/functions_general.php:1039]
#2 zen_trunc_string() called at [/home/scrappin/public_html/includes/modules/scrappin_stuff/product_listing.php:178]
#3 include(/home/scrappin/public_html/includes/modules/scrappin_stuff/product_listing.php) called at [/home/scrappin/public_html/includes/templates/scrappin_stuff/templates/tpl_modules_product_listing.php:12]
#4 require(/home/scrappin/public_html/includes/templates/scrappin_stuff/templates/tpl_modules_product_listing.php) called at [/home/scrappin/public_html/includes/templates/scrappin_stuff/templates/tpl_index_product_list.php:93]
#5 require(/home/scrappin/public_html/includes/templates/scrappin_stuff/templates/tpl_index_product_list.php) called at [/home/scrappin/public_html/includes/modules/pages/index/main_template_vars.php:217]
#6 require(/home/scrappin/public_html/includes/modules/pages/index/main_template_vars.php) called at [/home/scrappin/public_html/includes/templates/scrappin_stuff/common/tpl_main_page.php:151]
#7 require(/home/scrappin/public_html/includes/templates/scrappin_stuff/common/tpl_main_page.php) called at [/home/scrappin/public_html/index.php:97]

I can delete the files but they aren't new. The files were there - I just uploaded changed files. Getting rid of them leaves me with this only:
[11-Mar-2015 07:46:47 America/New_York] PHP Warning: substr() expects parameter 3 to be long, string given in /home/scrappin/public_html/m/includes/functions/functions_general.php on line 1016

I uploaded a fresh version of functions_general.php straight out of the zip file but that didn't stop it.

It was 1.5.1 I had the problem with before as well. I will be upgrading the other cart shortly but I was not hired to do it for this one.

11 Mar 2015, 12:02 PM
#5
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: PHP warnings suddenly start appearing in the log folder

the function substr() expects the third parameter to be a of the type "long". You are sending type "string". Try to find out why tpl_index_product_list.php is sending the variable of the type string on line 93

11 Mar 2015, 12:17 PM
#6
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

Since it's happening in both installations, I don't how it can be caused by specific files. That's the real mystery here, I believe.

How come you conclude the tpl_index_product_list.php is the culprit? Those files do look to be the same in both installations - the default files.

11 Mar 2015, 12:22 PM
#7
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: PHP warnings suddenly start appearing in the log folder

sorry, looked at the wrong line

it should be /home/scrappin/public_html/includes/modules/scrappin_stuff/product_listing.php line 178. This is where zen_trunc_string() is called

11 Mar 2015, 1:14 PM
#8
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

okay, when I took the product listing out I was still left with this:

[11-Mar-2015 07:46:47 America/New_York] PHP Warning: substr() expects parameter 3 to be long, string given in /home/xxxxx/public_html/m/includes/functions/functions_general.php on line 1016

11 Mar 2015, 1:39 PM
#9
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

But the weirdest part of this is how the warnings started showing in the installation where I had made no changes at all. It all started in both at the same time.

Now I'm wondering if having the two separate installations with the same database could have something to do with it. I've never seen it happen before though.

11 Mar 2015, 1:40 PM
#10
swguy avatar

swguy

Administrator

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

Re: PHP warnings suddenly start appearing in the log folder

Can you get a traceback on this so we can see the calling line?

11 Mar 2015, 1:43 PM
#11
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

Shall I email you to avoid looking stupid? :smile:

what's a traceback?

11 Mar 2015, 1:56 PM
#12
swguy avatar

swguy

Administrator

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

Re: PHP warnings suddenly start appearing in the log folder

It's the call stack to show how zen_trunc_string() was called. If you look at your first log, it has a full call stack so you can see what leads up to the failure. In this case, we need to see who's calling zen_trunc_string() and how so we can figure out what's going wrong.

11 Mar 2015, 2:03 PM
#13
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

The very first log file in the set of file where I did upload changes is only the last error I posted - repeated 9 times. The other set of error logs in the cart I did not upload files to is unchanged from the start from my first post here. That's all that's shown up.

12 Mar 2015, 12:37 PM
#14
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

After searching the forum for the error, I found this: http://www.zen-cart.com/showthread.php?176804-Fixed-v1-5-1-PHP-Warning-strlen()-expects-parameter-1-to-be-string

I also put my files back up on the server and it did not change. At first I was getting the whole set of errors down to the files I was working on at the time. Now just the strlen error in the new installation.

I checked to make sure I had not uploaded anything new to the first set of files. So there was no changes to that cart where the full error is still occuring with every refresh of the product listing - and there are 10 lines of the strlen length error - and yes, the page is displaying 10 products.

Replacing the files modules/product_listing.php, tpl_modules_product_listing.php, and tpl_columnar_display.php with the defaults makes no difference.

In the other installation of zen cart the error remains as follows. I really think this looks odd though with the number prefaced by a pound sign by the way.

[12-Mar-2015 08:31:22 America/New_York] #1 substr() called at [/home/scrappin/public_html/includes/functions/functions_general.php:1016]
#2 zen_trunc_string() called at [/home/scrappin/public_html/includes/modules/scrappin_stuff/product_listing.php:178]
#3 include(/home/xxx/public_html/includes/modules/domain/product_listing.php) called at [/home/scrappin/public_html/includes/templates/domain/templates/tpl_modules_product_listing.php:12]
#4 require(/home/xxxx/public_html/includes/templates/domain/templates/tpl_modules_product_listing.php) called at [/home/scrappin/public_html/includes/templates/domain/templates/tpl_index_product_list.php:93]
#5 require(/home/xxxx/public_html/includes/templates/domain/templates/tpl_index_product_list.php) called at [/home/domain/public_html/includes/modules/pages/index/main_template_vars.php:217]
#6 require(/home/xxxx/public_html/includes/modules/pages/index/main_template_vars.php) called at [/home/scrappin/public_html/includes/templates/domain/common/tpl_main_page.php:151]
#7 require(/home/xxxxx/public_html/includes/templates/domain/common/tpl_main_page.php) called at [/home/domain/public_html/index.php:97]

I made sure the functions_general.php in that cart was the correct version for 1.5.1.

Is it possible that the host made changes to the server that could create these problems? They started happening at the same time in both installations what now looks like out of the blue. I'm not coming up with what changes they could make that would create problems - I don't think the php version changed.

12 Mar 2015, 6:42 PM
#15
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

And proof positive. I installed another default 1.5.1 version on the website in a separate folder and it's throwing the strlen error. Must be something specific either to that database or server.

12 Mar 2015, 7:08 PM
#16
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: PHP warnings suddenly start appearing in the log folder

What happens if you switch to the "classic" template? Line 178 of the Zen Cart v1.5.1 version of /includes/modules/product_listing.php is highlighted below (and it's a comment)?

    // add description and match alternating colors
    //if (PRODUCT_LIST_DESCRIPTION > 0) {
    //  $rows++;
[B]    //  if ($extra_row == 1) {[/B]
    //    $list_box_description = "productListing-data-description-even";
    //    $extra_row=0;
    //  } else {
    //    $list_box_description = "productListing-data-description-odd";
    //    $extra_row=1;
    //  }
    //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
    //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
    //}
    $listing->MoveNext();
12 Mar 2015, 7:12 PM
#17
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

The one I just installed defaults to template_default - no custom template in that version.

12 Mar 2015, 7:27 PM
#18
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: PHP warnings suddenly start appearing in the log folder

Well, then, how about you post the contents a little before and after your v1.5.1 version of the file?

12 Mar 2015, 7:49 PM
#19
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: PHP warnings suddenly start appearing in the log folder

playing dumb here again - contents of error logs?

No change, new version in new folder with same database

[12-Mar-2015 08:24:05 America/New_York] PHP Warning: substr() expects parameter 3 to be long, string given in /home/xxxxx/public_html/m/includes/functions/functions_general.php on line 1016

12 Mar 2015, 7:51 PM
#20
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: PHP warnings suddenly start appearing in the log folder

Sorry, please post the contents of your /includes/modules/product_listing.php -- around 20 lines before and after line 178 (and highlight line 178, please).