Zen Cart Logo

Php 7

Views: 4,961

Results 1 to 20 of 20
3 Dec 2015, 6:23 PM
#1
cstdenis avatar

cstdenis

New Zenner

Join Date:
Jul 2006
Posts:
19
Plugin Contributions:
0

Php 7

With php 7 about to be released, anybody known what Zen Cart's compatibility with it is? I'd love to take advantage of it's new performance boost.

Will 1.5.4 work under php 7, or do we need to wait for 1.5.5?

3 Dec 2015, 8:41 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Php 7

cstdenis:

With php 7 about to be released, anybody known what Zen Cart's compatibility with it is? I'd love to take advantage of it's new performance boost.

Will 1.5.4 work under php 7, or do we need to wait for 1.5.5?

Based on the server requirements page:

Version

Zen Cart v1.2.x through v1.3.6 are compatible with PHP 4.3.2 - 4.4.x. They are NOT compatible with PHP 5.
Zen Cart v1.3.7-v1.3.8a are compatible with PHP 4.3.2 through PHP 5.2.x, but not PHP 5.3.
Zen Cart v1.3.9 series is compatible with PHP 5.2.10 thru PHP 5.3.x.
Zen Cart v1.5.0 is compatible with PHP 5.2.14 thru PHP 5.3.x. Requires patches to work with PHP 5.4, and upgrading is a better idea.
Zen Cart v1.5.1 is compatible with PHP 5.2.14 thru PHP 5.3.x. Requires some patches to work with PHP 5.4, and upgrading is a better idea.

(* NOTE: v1.5.2, v1.5.3 may technically work with as low as 5.2.14 but will be less secure, so should use PHP 5.3.7 or greater.)

Zen Cart v1.5.2 is compatible with PHP 5.3.7* thru PHP 5.6
Zen Cart v1.5.3 is compatible with PHP 5.3.7* thru PHP 5.6
.
Zen Cart v1.5.4 is designed for PHP 5.5 and PHP 5.6 (and is compatible with PHP 5.3.7* and PHP 5.4 if really necessary, with some bugfix patches applied)
.
Zen Cart v1.5.5 is designed for PHP 5.5 and PHP 5.6 (optionally as far back as PHP 5.3.7* if really necessary for temporary upgrading purposes)

The following is in-development and not officially released yet. Details subject to change:
Zen Cart v1.6.0 is designed for PHP 5.6 and PHP 7 (but is expected to be compatible with PHP 5.4.2+ and PHP 5.5 too)

It looks like PHP v7 won't be included until after ZC 1.5.5

4 Dec 2015, 6:50 AM
#3
frank18 avatar

frank18

Deceased

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

Re: Php 7

cstdenis:

With php 7 about to be released, anybody known what Zen Cart's compatibility with it is? I'd love to take advantage of it's new performance boost.

Will 1.5.4 work under php 7, or do we need to wait for 1.5.5?

Good point.

I have PHP 7 in my PHP selector on the server, if I get some time I might install a vanilla ZC 1.5.4 or 1.5.5 (alpha/beta whatever) and try to run it under PHP 7.

6 Dec 2015, 1:38 AM
#4
frank18 avatar

frank18

Deceased

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

Re: Php 7

frank18:

Good point.

I have PHP 7 in my PHP selector on the server, if I get some time I might install a vanilla ZC 1.5.4 or 1.5.5 (alpha/beta whatever) and try to run it under PHP 7.

Just installed a vanilla ZC 1.5.4 with demo products on PHP Version 7.0.0RC7, server LiteSpeed V6.8 .

Had no issues at all (other than mucking up my DB password :blush: ) - the installation ran smooth-as and the store loads fast.

As you can see from above, the PHP version is an RC and no official release.

Anyway, so far so good.

6 Dec 2015, 1:54 PM
#5
lat9 avatar

lat9

Administrator

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

Re: Php 7

One of the "big" changes that will be required for PHP 7 is due to the deprecation (i.e. removal of support) of PHP-4-style class-constructor naming.

That is, a PHP class that uses the following format for its initialization

class my_class {
  function [B]my_class[/B] { ...
  }

  ...
}

will require recoding to use the following format:

class my_class {
  function [B]__construct[/B] { ...
  }

  ...
}
9 Dec 2015, 4:06 PM
#8
swguy avatar

swguy

Administrator

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

Re: Php 7

lat9:

One of the "big" changes that will be required for PHP 7 is due to the deprecation (i.e. removal of support) of PHP-4-style class-constructor naming.

This is just a warning in PHP7 though right? I'm sure you can disable the warning until these things are fixed in the base, in mods, etc.

9 Dec 2015, 4:43 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Php 7

swguy:

This is just a warning in PHP7 though right? I'm sure you can disable the warning until these things are fixed in the base, in mods, etc.

Emits E_DEPRECATED when encountered, which generally speaking would be a warning, yes. Conditions would be if no __construct() exists, then E_DEPRECATED, if __construct() exists but after a function of the same name as the class (previous constructor method) then also E_DEPRECATED. If __construct() exists before a function of the same name, then the first function is treated as the constructor, the second function is treated as a normal method... There are some other details involved, but the above was basically captured from: https://wiki.php.net/rfc/remove_php4_constructors

9 Dec 2015, 5:56 PM
#10
lat9 avatar

lat9

Administrator

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

Re: Php 7

swguy:

This is just a warning in PHP7 though right? I'm sure you can disable the warning until these things are fixed in the base, in mods, etc.
It's "just a warning" that will fill your /logs folder with debug-log files until the issue(s) are corrected, especially if the class-file is included on each page-load.

You can't disable just that PHP warning and I don't suggest disabling warnings in general as they tend to be predictors of bad things to come!

10 Dec 2015, 12:05 AM
#11
swguy avatar

swguy

Administrator

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

Re: Php 7

LOL fair enough. Thanks for updating this in your contribs. Once MAMP releases a version with PHP7 I will do likewise.

10 Dec 2015, 12:25 AM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Php 7

swguy:

LOL fair enough. Thanks for updating this in your contribs. Once MAMP releases a version with PHP7 I will do likewise.

Not saying need to un out and make the change, but if touching the files in the mean time, __construct would work just as well on pretty much anything runniing PHP 5.x and above (yes, I know there is a lower limit, but can't remember now what it is/was). I've been moving that way relatively recently.

10 Dec 2015, 7:31 PM
#13
drbyte avatar

drbyte

Sensei

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

Re: Php 7

mc12345678:

Not saying need to un out and make the change, but if touching the files in the mean time, __construct would work just as well on pretty much anything runniing PHP 5.x and above (yes, I know there is a lower limit, but can't remember now what it is/was). I've been moving that way relatively recently.
Usually just renaming the function to __construct is enough ..... but, double check your code to be sure that you don't ever directly call that function from code either inside or outside that class.

For example, in ZC the Admin object_info class gets called in numerous files via pInfo->objectInfo() ... so, we've rewritten (and are rewriting the v160 rewrite of) the class to have both a __construct() and an objectInfo() function ... which makes it PHP7 compatible and also backward-compatible to PHP5.

11 Dec 2015, 12:55 AM
#14
swguy avatar

swguy

Administrator

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

Re: Php 7

The MAMP team just announced that they'd be releasing a new MAMP with PHP7 in the next 10 days!

https://twitter.com/mamp_en/status/673846269643726848

11 Dec 2015, 1:32 PM
#16
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Php 7

DrByte:

Usually just renaming the function to __construct is enough ..... but, double check your code to be sure that you don't ever directly call that function from code either inside or outside that class.

For example, in ZC the Admin object_info class gets called in numerous files via pInfo->objectInfo() ... so, we've rewritten (and are rewriting the v160 rewrite of) the class to have both a __construct() and an objectInfo() function ... which makes it PHP7 compatible and also backward-compatible to PHP5.

I appear to have some sort of bran fog today, thought about wating to post back, but might as well get the ball rolling... Trying to understand if in fact the reverse compatibilty isn't really wth PHP 5 in general, but instead wth older ZC versions (ie. "This" file will work on ZC versions that are compatible wth Php 5.x and PHP 7...) Such that the older code that still calls the previous constructor doesn't need to be modified (as much) to work wth the newer version(s)... Otherwse I don't see the potential compatibility issue of leaving out the function by the name of the class when referring to PHP 5 (brain fog part at the moment)...

11 Dec 2015, 10:41 PM
#17
drbyte avatar

drbyte

Sensei

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

Re: Php 7

mc12345678:

I appear to have some sort of bran fog today, thought about wating to post back, but might as well get the ball rolling... Trying to understand if in fact the reverse compatibilty isn't really wth PHP 5 in general, but instead wth older ZC versions (ie. "This" file will work on ZC versions that are compatible wth Php 5.x and PHP 7...) Such that the older code that still calls the previous constructor doesn't need to be modified (as much) to work wth the newer version(s)... Otherwse I don't see the potential compatibility issue of leaving out the function by the name of the class when referring to PHP 5 (brain fog part at the moment)...
I don't think I fully understand what you're saying.

PHP5 will understand __construct() just fine. So will PHP7.

What PHP7 and 8 are moving towards is not automatically treating a class method of "foo" inside class named "foo" as the constructor. Instead, it will ignore the "foo" method and assume the class has no constructor if no __construct() method exists. To create the same functionality as PHP5, the __construct() method can simply call $this->foo(); to accomplish the old behaviour.

10 May 2016, 12:26 AM
#18
mustang80 avatar

mustang80

New Zenner

Join Date:
May 2016
Location:
Bulgaaria
Posts:
28
Plugin Contributions:
0

Re: Php 7

This is my website http://hopshop.bg/, .this is product page http://hopshop.bg/index.php?main_page=product_info&cPath=15&products_id=7187. added a contact form on products and quick order, but does not work on php 7 .... this is the code:

My Version Zen Cart 1.5.5a

<! ------------------------------------------------ --------------------------------------->
<? Php echo "Quick order with a click of product: .. (* for this product on this page): >>"?> <B> <? Php echo $ products_name; ?> <? Php echo "... Price"?>
<! - Bof Product Price block ->
<? Php
####echo $ one_time. ((Zen_has_product_attributes_values ​​((int) $ _ GET [ 'products_id']) and $ flag_show_product_info_starting_at == 1)? TEXT_BASE_PRICE: ''). zen_get_products_display_price ((int) $ _ GET [ 'products_id']);
?>
<! - Eof Product Price block ->
</ B>
<? Php
// Contact Form via email // itbg.eu // Dev7 //
$ Gg = 'http: //';
$ Ggg = $ products_name;
$ Gggg = $ one_time. ((Zen_has_product_attributes_values ​​((int) $ _ GET [ 'products_id']) and $ flag_show_product_info_starting_at == 1)? TEXT_BASE_PRICE: ''). zen_get_products_display_price ((int) $ _ GET [ 'products_id']);
$ Contact_email = $ _POST [ 'EmailAddress'];
$ Contact_subject = $ _POST [ 'Subject'];
$ Contact_name = $ _POST [ 'FullName'];
$ Contact_message = $ _POST [ 'Message'];
$ Mydate = date ( 'l, F d Y g: i A', time () + 240);
$ To = "[email protected]"; // E-mail to which messages will be sent //
$ Message. = "Address:". $ Address. "\ R \ n";
$ Subject = "HopShop-Order:". $ Ggg. "\ R \ n". "Name:". $ Contact_name. "\ R \ n". "Tel:". $ Contact_subject. "\ R \ n"; // // Subject
$ Message = "From HopShop.Bg ---- Tel: 0878843093 \ r \ n \ r \ n" // text message //
. "Product: $ products_name \ r \ n". "Price: $ gggg \ r \ n"
. "Model: $ products_model; \ r \ n"
. "Link product ordered: $ gg {$ _ SERVER [ 'SERVER_NAME']} {$ _ SERVER [ 'REQUEST_URI']} \ r \ n"
. "------------------------------------------------ ------------------------------- \ r \ n "
. "------------------------------------------------ ------------------------------- \ r \ n "
. "Name: $ contact_name \ r \ n"
. "Phone client: $ contact_subject \ r \ n"
. "Shipping Address (+ Other information on order): \ r \ n \ r \ n $ contact_message \ r \ n"
. "------------------------------------------------ ------------------------------- \ r \ n "
. "------------------------------------------------ ------------------------------- \ r \ n "
. "Date: $ mydate \ r \ n"
. "From IP: {$ _SERVER [ 'REMOTE_ADDR']} \ r \ n \ r \ n";
$ Headers = "From: $ contact_name <$ contact_email> \ n"
. "Content-type: text / plain; charset = UTF-8 \ n"
. "Reply-To: $ contact_email \ n"
. "X-Mailer: PHP /". Phpversion ();
if (empty ($ contact_name) || empty ($ contact_email) || empty ($ contact_subject) || empty ($ contact_message)) {
?>

<Form id = "contact" method = "post" action = ""> <br/>
<Div id = "from">
Full name: <br /> <input type = "text" name = "FullName" size = "25" /> <br/>
</ Div>
E-mail: <br/> <input type = "text" name = "EmailAddress" size = "25" /> <br/>
Phone: <br /> <input type = "text" name = "Subject" size = "25" /> <br/>
Delivery address (or Econt office)
<br/> <textarea rows = "6" name = "Message" size = "10" cols = "10" class = "input"> </ textarea> <br/>
<Input type = "submit" value = "confirm order with just one click" /> <input type = "reset" value = "Clear" />
</ Form>

<? Php
} Elseif (! Ereg ( "^ [_ a-z0-9 -] + (\. [_ A-z0-9 -] +) * @ [a-z0-9 -] + (\. [A-z0-9 -] +) * (\. [az] {2,3}) $ ", $ contact_email)) {
echo "<p> Error: Please enter a valid e-mail. </ p>";
} Else {
mail ($ to, $ subject, $ message, $ headers);
echo "<h3> Your order is accepted! </ h3> <p> $ contact_name, <br /> as possible - will soon contact you $ contact_email.";
}
?>
10 May 2016, 1:13 AM
#19
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Php 7

Does that work on php anything? There appear to be a number of coding errors throughout. Not to mention that with the use of the form tag, it is not ZC compliant and will cause an issue if attempting to submit it because it doesn't have the applicable session information saved with it.

10 May 2016, 3:02 PM
#20
swguy avatar

swguy

Administrator

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

Re: Php 7

@Mustang80 have you looked at the Ask A Question contribution in the plugins area? It might do what you want, and it already works with PHP7.