Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP 7


cornishpirate

Recommended Posts

Have just been playing with PHP 7 RC1 using these instructions as a guide:

 

https://phpdave.wordpress.com/2015/06/15/run-php-7-alpha-on-windows-in-3-steps/

 

Could only use the built-in webserver and php.ini needed tweeking for mysqli but, all in all, a very simple process.

 

Using my heavily modified RC2a system, I managed to load all pages very easily and VERY FAST!

 

Encouraging.

 

 

Link to comment
Share on other sites

  • Replies 93
  • Created
  • Last Reply

Lucky you :D - I've been cleaning up my custom code while trying to get 5.4/5.5 working.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

 

Are you sure that isn't PHP 5.7?

 

There isn't a PHP 5.7.

 

Details about PHP 7.0 RC1 are at http://www.php.net

 

Extract:

 

 

PHP 7.0.0 comes with new version of the Zend Engine with features such as (incomplete list):

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Consistent 64-bit support
  • Many fatal errors are now Exceptions
  • Removal of old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Combined comparison Operator (<=>)
  • Return Type Declarations
  • Scalar Type Declarations
  • Anonymous Classes

 

Link to comment
Share on other sites

  • 2 months later...

Hmm. So PHP is taking a page from Microsoft and skipping version numbers? Lovely. Just lovely.

 

@@MrPhil

 

From what I've heard, Microsoft went from Windows 8.1 to Windows 10 (skipping Windows 9) because ...

 

Way back when, when Microsoft moved from the Windows 95/98 platform to the Windows NT/2000/XP/etc platform, software developers had to put checks in their installation code to determine if they would/could install on a Win95/98 -vs- Win NT/2K/XP OS. So, there were checks for "Windows 9xxx".

 

While current applications may not make these checks, in order to avid problems with legacy code, Microsoft just skipped the Windows 9 version number.

 

Whether this is true or not, I can not say :-

 

Malcolm

Link to comment
Share on other sites

Whether this is true or not, I can not say :-

 

Yeah, I've heard that account too. Even if it is true (and it could be), it indicates some pretty sloppy coding practices by developers (including Microsoft) in the past. Hard to believe but entirely possible.

Link to comment
Share on other sites

 

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Should be OK as long as you've moved to MySQli. From memory, I just changed the code to avoid Deprecated warnings on PHP 4 style constructors (methods that have the same name as the class they are defined in). Working well on my test site with PHP7 RC6, but will be giving it a comprehensive test as soon as 7.0 is released, likely to be next week.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...
  • 1 month later...

I have also started working on PHP 7 for past 15 days and the most significant advancement which I found out in my application is that it has become quite faster. It takes very less time in loading any page.

It is really great working on PHP 7.

Link to comment
Share on other sites

  • 2 weeks later...

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Yes, you will need to modify classes to use __construct classes to prevent DEPRECATED errros, but other than that - it should work just fine when switching from code already compatible with 5.5 (ie. working stable without any deprecated errors on php 5.5, supports UTF-8 and mysqli) to php 7.

 

So, for example, code like this:

  class infoBoxHeading extends tableBox {    
    function infoBoxHeading($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }
 
Must be changed to this:
 
  class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

As you can see, the only modification was: function infoBoxHeading changed to function __construct

I highly recommend switching to php 7, if you can.

Link to comment
Share on other sites

Actually the specific modification example I gave is not so good, because this infoBoxHeading class extends tableBox class and in this case it would be correct to modify tableBox class first from:

class tableBox{
    function tableBox{
        // some code
    }
// more code
}

TO:

class tableBox{
   function __construct(){
    //leave it empty
   }
    function tableBox{
        // some code
    }
// more code
}

 and then on the extended class, do this:

class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;

parent::__construct(); //calling the parent constructor, as tableBox method is being used here in this class

if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

Note that we don't only modify the method name here from infoBoxHeading to __construct, but we are also calling the parent construct via parent::__construct();

Link to comment
Share on other sites

just for the fun of it, tonight after midnight I changed version to php7 for a short while

 

I had a (custom) badly coded break statement in application top

 

I had to change this line from single to double quotes

if (!tep_session_is_registered("SESSION_USER_AGENT")) {

 

I also use apc caching and had to change the references to apc_xxx to apcu_xxx

 

Now, with the little tests I made on home page, categories page and product info page, it only gave me the construct warnings.

 

So overall pretty happy. Fix the constructors, I'll take some performance baseline numbers and readup on what potentially can go wrong before taking the plunge.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I had to change this line from single to double quotes

if (!tep_session_is_registered("SESSION_USER_AGENT")) {

Actually, a macro name (defined constant) should never be within quotes. They are stand-alone strings.

if (!tep_session_is_registered(SESSION_USER_AGENT)) {
Link to comment
Share on other sites

  • 1 month later...

it will be released this year and the performance improvement is amazing.

 

PHP 7 has already been released @ Nov-Dec 2015, and yes, it does have an excellent performance improvement.

Link to comment
Share on other sites

  • 4 weeks later...

After exhaustive testing on our preview site, I took a deep breath and invoked PHP 7.05 on the live site yesterday.

 

Pleased to report that all went extremely well and the performance improvement is considerable. No horrible suprises in the error logs either.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...