Zen-Cart and PHP 5.3.0 FixES

651 views
Skip to first unread message

Joe Suttle

unread,
Sep 25, 2009, 6:14:32 PM9/25/09
to apache2
Lewis and all,

I now have Zen-Cart working on my system (WSeB, Apache 2.2.13, php 5.3.0 and mySQL 5.1.36)

The problems had to do with the changes made to or more specifically in PHP 5.3.0. Those changes made the code in Zen-Cart fail. Did the following things, and now have Zen-Cart back up and working. Thanks to Lewis for making me test this, since I would have waited a couple of months before doing anything with the cart.

Thanks to several Zen-Cart "masters" for finding what needed to be changed. You can use any text search engine to find the other occurances of 'date_diff' and change them as shown in the following:

= = = = =
- Prefix 'set_magic_quotes_runtime' with '@' in application_top.php (there are two files with this name, one in includes and one in /admin/includes). There are other uses of set_magic_quotes_runtime in the code, but I'll deal with them as I come to them.

- Replace "ereg('thing', $other)" with "preg_match('/thing/', $other)", as noted by Andy Whittaker.
        one file that has a problem is includes/classes/db/mysql/query_factory.php
        Calls such as "ereg('^[0-9]', $key)" need to be replaced by "preg_match('/^[0-9]/', $key)" in several places,
             note the / / surrounding the string."

- 'date_diff' is now a keyword in PHP 5.3.0 (http://th2.php.net/manual/en/function.date-diff.php) so change the function to something like zen_date_diff in:
          admin/orders.php
          admin/includes/header.php
          admin/includes/modules/orders_download.php
          admin/includes/functions/general.php
          includes/modules/payment/paypal/paypal_functions.php
          includes/functions/functions_general.php

= = = = =

-- 
Joe Suttle * IBM Warp Certified System Expert * Member of IEEE
joes...@attglobal.net                    http://www.joesuttle.com/blog
Richmond, California                           http://www.warpedbox.com/
+----------------------------------------------------------------------+
      "We learn something every day, and lots of times it's that
      what we learned the day before was wrong." -- Bill Vaughan
+----------------------------------------------------------------------+
Using the power  |  WSeB, Apache, Weasel, FileStar
 of OS/2, Linux  |  Lotus SmartSuite, Firefox, Thunderbird, Kompozer
     and XP Pro  |  OpenSuse, Adtran, MySQL, PHP
+----------------------------------------------------------------------+

Lewis G Rosenthal

unread,
Sep 25, 2009, 8:04:53 PM9/25/09
to apa...@googlegroups.com
On 09/25/09 06:14 pm, Joe Suttle thus wrote :

> Lewis and all,
>
> I now have Zen-Cart working on my system (WSeB, Apache 2.2.13, php
> 5.3.0 and mySQL 5.1.36)
>
> The problems had to do with the changes made to or more specifically
> in PHP 5.3.0. Those changes made the code in Zen-Cart fail. Did the
> following things, and now have Zen-Cart back up and working. Thanks to
> Lewis for making me test this, since I would have waited a couple of
> months before doing anything with the cart.
>
> Thanks to several Zen-Cart "masters" for finding what needed to be
> changed. You can use any text search engine to find the other
> occurances of 'date_diff' and change them as shown in the following:
>
<snip>

Thanks, Joe. This is all very good information to have. Now to see
whether your system behaves any better and how these mods turn out once
you start seeing some traffic.

Cheers.

--
Lewis
-------------------------------------------------------------
Lewis G Rosenthal, CNA, CLP, CLE
Rosenthal & Rosenthal, LLC www.2rosenthals.com
Need a managed Wi-Fi hotspot? www.hautspot.com
Secure, stable, operating system www.ecomstation.com
-------------------------------------------------------------

Stilarsen

unread,
Oct 29, 2009, 10:51:08 AM10/29/09
to Apache for OS/2

> - Replace "ereg('thing', $other)" with "preg_match('/thing/', $other)",
> as noted by Andy Whittaker.

Hi, where can i find this file? In which file can i find that line?

Thank you

Lewis G Rosenthal

unread,
Oct 29, 2009, 4:35:33 PM10/29/09
to apa...@googlegroups.com
On 10/29/09 10:51 am, Stilarsen thus wrote :

>
>> - Replace "ereg('thing', $other)" with "preg_match('/thing/', $other)",
>> as noted by Andy Whittaker.
>>
>
> Hi, where can i find this file? In which file can i find that line?
>
>
I haven't scanned my files, though you will likely encounter those
statements in multiple places. FWIW, the thread which Joe referenced is
apparently here:

http://www.zen-cart.com/forum/showthread.php?p=774374

Just scan your Zen-Cart tree and/or do a search/replace via Perl or
something, and you'll find those lines. Joe: you didn't mention which
version of ZC you've got installed; I'm assuming 1.3.8...

Cheers/2

Joe Suttle

unread,
Oct 30, 2009, 3:48:06 PM10/30/09
to apa...@googlegroups.com
Lewis G Rosenthal wrote:
> Just scan your Zen-Cart tree and/or do a search/replace via Perl or
> something, and you'll find those lines. Joe: you didn't mention which
> version of ZC you've got installed; I'm assuming 1.3.8...
>
> Cheers/2
>
>
That is correct Lewis. Thanks for jogging my memory. It is 1.3.8.

Seems that when it rains, it pours. Not only did I have web server
problems (presently resolved), wife broke her leg, and I am the resident
nurse/driver/cook for 4.5 more weeks (at least), - just call me "Mr. Mom".

kevin

unread,
Nov 1, 2009, 4:56:09 AM11/1/09
to Apache for OS/2
Hi everyone,

I was pointed in this direction for a fix to my Zen Cart by my hosting
company who have upgraded to PHP 5.3 without even telling me.

I have done all that has been suggested and the site is now working
but the admin control panel is not. I get the following errors:

*****************************
Deprecated: Assigning the return value of new by reference is
deprecated in /customers/rosecottagebalmsandsoap.co.uk/
rosecottagebalmsandsoap.co.uk/httpd.www/includes/functions/
functions_email.php on line 161

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
includes/functions/functions_email.php:161) in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
includes/functions/sessions.php on line 108

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
includes/functions/functions_email.php:161) in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
includes/functions/sessions.php on line 108

Deprecated: Function ereg_replace() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
includes/functions/sessions.php on line 112

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Deprecated: Function eregi() is deprecated in /customers/
rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
admin/includes/classes/language.php on line 100

Warning: Cannot modify header information - headers already sent by
(output started at /customers/rosecottagebalmsandsoap.co.uk/
rosecottagebalmsandsoap.co.uk/httpd.www/includes/functions/
functions_email.php:161) in /customers/rosecottagebalmsandsoap.co.uk/
rosecottagebalmsandsoap.co.uk/httpd.www/admin/includes/init_includes/
init_templates.php on line 36

Warning: Cannot modify header information - headers already sent by
(output started at /customers/rosecottagebalmsandsoap.co.uk/
rosecottagebalmsandsoap.co.uk/httpd.www/includes/functions/
functions_email.php:161) in /customers/rosecottagebalmsandsoap.co.uk/
rosecottagebalmsandsoap.co.uk/httpd.www/admin/includes/functions/
general.php on line 21
*****************************

(admin folder name changed for security reasons.

Any ideas on how to fix this??

Thanks,

Kevin

On Sep 26, 12:04 am, Lewis G Rosenthal <lgrosent...@2rosenthals.com>
wrote:
> On 09/25/09 06:14 pm, Joe Suttle thus wrote :> Lewis and all,
>
> > I now haveZen-Cart working on my system (WSeB, Apache 2.2.13, php
> > 5.3.0 and mySQL 5.1.36)
>
> > The problems had to do with the changes made to or more specifically
> > in PHP 5.3.0. Those changes made the code inZen-Cart fail. Did the
> > following things, and now haveZen-Cart back up and working. Thanks to
> > Lewis for making me test this, since I would have waited a couple of
> > months before doing anything with the cart.
>
> > Thanks to severalZen-Cart "masters" for finding what needed to be

Lewis G Rosenthal

unread,
Nov 1, 2009, 1:44:58 PM11/1/09
to apa...@googlegroups.com
Hi, Kevin...

On 11/01/09 04:56 am, kevin thus wrote :
> Hi everyone,
>
> I was pointed in this direction for a fix to my Zen Cart by my hosting
> company who have upgraded to PHP 5.3 without even telling me.
>
> I have done all that has been suggested and the site is now working
> but the admin control panel is not. I get the following errors:
>
> *****************************
> Deprecated: Assigning the return value of new by reference is
> deprecated in /customers/rosecottagebalmsandsoap.co.uk/
> rosecottagebalmsandsoap.co.uk/httpd.www/includes/functions/
> functions_email.php on line 161
>
> Warning: session_start() [function.session-start]: Cannot send session
> cookie - headers already sent by (output started at /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> includes/functions/functions_email.php:161) in /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> includes/functions/sessions.php on line 108
>
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> includes/functions/functions_email.php:161) in /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> includes/functions/sessions.php on line 108
>
>
Have you read thoroughly
http://www.zen-cart.com/forum/showthread.php?p=774374 ? It sounds like
magic quotes are still enabled (for one). If the rest of the site is
working, then search your admin files for "set_magic_quotes_runtime" and
prefix with "@".

What would also help would be knowing your ZC version and some pertinent
data from phpinfo() (magic quotes, etc.).
> Deprecated: Function ereg_replace() is deprecated in /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> includes/functions/sessions.php on line 112
>
>
Again, per Andy Whittaker's post referenced above:

> Calls such as ereg('^[0-9]', $key) need to be replaced by
> preg_match('/^[0-9]/', $key) in several places; note the / /
> surrounding the string.


> Deprecated: Function eregi() is deprecated in /customers/
> rosecottagebalmsandsoap.co.uk/rosecottagebalmsandsoap.co.uk/httpd.www/
> admin/includes/classes/language.php on line 100
>
>
ZC has forked much of its code from OS Commerce, the original project.
This page should help:

http://devthought.com/tumble/2009/06/fix-ereg-is-deprecated-errors-in-php-53/

<snip>
> *****************************
>
> (admin folder name changed for security reasons.
>
> Any ideas on how to fix this??
>
>
Hope the above is of some help.

I still run my ZC installations under PHP 4, simply because they have
not officially supported PHP 5 (in any flavor) up to this point (unless
I missed an announcement somewhere). I know that many people have had
good results with pre-5.3 builds of PHP 5, but I've tried to stick with
what's supported in that regard.

Cheers.

<snip>

Lewis G Rosenthal

unread,
Nov 1, 2009, 1:46:21 PM11/1/09
to apa...@googlegroups.com
Hi, Joe...

On 10/30/09 03:48 pm, Joe Suttle thus wrote :
> Lewis G Rosenthal wrote:
>
>> Just scan your Zen-Cart tree and/or do a search/replace via Perl or
>> something, and you'll find those lines. Joe: you didn't mention which
>> version of ZC you've got installed; I'm assuming 1.3.8...
>>
>> Cheers/2
>>
>>
>>
> That is correct Lewis. Thanks for jogging my memory. It is 1.3.8.
>
> Seems that when it rains, it pours. Not only did I have web server
> problems (presently resolved), wife broke her leg, and I am the resident
> nurse/driver/cook for 4.5 more weeks (at least), - just call me "Mr. Mom".
>
>
Geez... Sorry to hear of your run of bad luck, buddy.

On the bright side, things could always be worse. All the best to the
misses for a speedy recovery.

Andrew

unread,
Nov 4, 2009, 10:33:51 AM11/4/09
to Apache for OS/2


On Oct 29, 8:35 pm, Lewis G Rosenthal <lgrosent...@2rosenthals.com>
wrote:
> Just scan your Zen-Cart tree and/or do a search/replace via Perl or
> something, and you'll find those lines. Joe: you didn't mention which
> version of ZC you've got installed; I'm assuming 1.3.8...

You can do this using the Developers Tool Kit under Zencarts Admin
panel. Use the "Look-up in all files" and enter the function name in
the "Key or Name:" input and select "All files - Catalog/Admin" in the
dropdown.

Lewis G Rosenthal

unread,
Nov 8, 2009, 9:48:53 PM11/8/09
to apa...@googlegroups.com
Hi...

On 11/04/09 10:33 am, Andrew thus wrote :
Of course, if the admin panel is broken, as Kevin seems to indicate,
then this method won't quite yield the desired result... ;-)

waldo kitty

unread,
Nov 8, 2009, 11:19:12 PM11/8/09
to apa...@googlegroups.com
Lewis G Rosenthal wrote:
> Hi...
>
> On 11/04/09 10:33 am, Andrew thus wrote :
>> On Oct 29, 8:35 pm, Lewis G Rosenthal <lgrosent...@2rosenthals.com>
>> wrote:
>>
>>> Just scan your Zen-Cart tree and/or do a search/replace via Perl or
>>> something, and you'll find those lines. Joe: you didn't mention which
>>> version of ZC you've got installed; I'm assuming 1.3.8...
>>>
>> You can do this using the Developers Tool Kit under Zencarts Admin
>> panel. Use the "Look-up in all files" and enter the function name in
>> the "Key or Name:" input and select "All files - Catalog/Admin" in the
>> dropdown.
>>
>>
> Of course, if the admin panel is broken, as Kevin seems to indicate,
> then this method won't quite yield the desired result... ;-)
>

that's why the made mc and other tools that can/do search out the specific text
strings and point out which files they reside in :P :)
Reply all
Reply to author
Forward
0 new messages