Jump to content



Photo
- - - - -

PHP 7


  • Please log in to reply
63 replies to this topic

#21   MrPhil

MrPhil
  • Members
  • 6,978 posts
  • Real Name:Phil
  • Gender:Male

Posted 09 February 2016 - 01:00

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)) {


#22   burt

burt

    I drink and I know things

  • Community Team
  • 12,463 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 February 2016 - 12:22

@MrPhil @bruyndoncx

 

That is mostly true.  I was caught out doing something recently;

if (defined(SOME_TEXT)) echo SOME_TEXT;

needs to be

if (defined('SOME_TEXT')) echo SOME_TEXT;

The lack of apostrophes stumped me for an afternoon lol


This is a signature that appears on all my posts.  It is not specifically aimed at you.

 

IF YOU MAKE A POST REQUESTING HELP...please state the exact version of osCommerce that you are using. THANKS
 
If you are still on the old style osCommerce, it is time to move to Responsive.

 


#23   dr_lucas

dr_lucas
  • Members
  • 331 posts
  • Real Name:Michaela
  • Gender:Female

Posted 06 April 2016 - 00:22

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.



#24 ONLINE   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 29 April 2016 - 10:31

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.



#25   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 29 April 2016 - 15:13

@cornishpirate

 

Alan, what version of osC are you running it with?

 

Dan



#26 ONLINE   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 29 April 2016 - 16:16

Dan, well it started as RC2a !

 

It's very heavily modified, both in terms of keeping it updated, secure, improving efficiency, making it responsive and extending facilities.

 

However, it didn't take too much to make it run under PHP 7. I just made a point of ensuring all notices, warnings and errors from the log were dealt with.

 

Alan

 

PS Having a lifetime in software developement helped!



#27   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 30 April 2016 - 11:27

@cornishpirate  A frankinstore eh?  Well done.

 

Dan



#28   xinn2005

xinn2005
  • Members
  • 7 posts
  • Real Name:Cindy Na
  • Gender:Female
  • Location:United States

Posted 13 January 2017 - 18:37

I just upgraded the PHP version to 7.0 for my website. While most warnings were fixed by replacing the old class constructors with __construct(), there are some pretty serious issues with the child class calling parent class constructors in the original code. For example, includes/classes/message_stack.php extends tableBox and has some code that created the "Call to undefined method" error:

 

class tableBox {

   // class constructor

    function __construct($contents, $direct_output = false) { ... }

}

 

class messageStack extends tableBox {

    function __construct() { ... }

 

   function output($class) {

       ..............    

     // the line below throws Call to undefined method error

     return $this->tableBox($output);

 }

 

Replacing the line above with parent::__construct() didn't work. I would appreciate it if you could share your thoughts on this. 


Edited by xinn2005, 13 January 2017 - 18:42.


#29   bruyndoncx

bruyndoncx

    osCommerce Teenager

  • Members
  • 3,773 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 13 January 2017 - 19:22

I just upgraded the PHP version to 7.0 for my website. While most warnings were fixed by replacing the old class constructors with __construct(), there are some pretty serious issues with the child class calling parent class constructors in the original code. For example, includes/classes/message_stack.php extends tableBox and has some code that created the "Call to undefined method" error:
 
class tableBox {
   // class constructor
    function __construct($contents, $direct_output = false) { ... }
}
 
class messageStack extends tableBox {
    function __construct() { ... }
 
   function output($class) {
       ..............    
     // the line below throws Call to undefined method error
     return $this->tableBox($output);
 }
 
Replacing the line above with parent::__construct() didn't work. I would appreciate it if you could share your thoughts on this.

to be fair, you should use these boxes any more.
shouldn t be too hard to find examples of how to rewrite these in modern div based code
KEEP CALM AND CARRY ON
FYI Just upgraded from PHP 5.3 to PHP 5.5  and saw big performance improvement.
But be aware php 5.5 is more strict about things.
UTF8-without BOM, no extra spaces allowed at the beginning or end of your php file, or your redirects wont work.
No double declarations of functions allowed - used to slip through the cracks ...

#30   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 13 January 2017 - 19:24

@xinn2005 Cindy out of curiosity what version of osC are you using?

 

Dan



#31   xinn2005

xinn2005
  • Members
  • 7 posts
  • Real Name:Cindy Na
  • Gender:Female
  • Location:United States

Posted 13 January 2017 - 19:41

I am using v2.3.4.

 

I guess I could replace the "boxes" with div based code but it would not change the hierarchy of the classes that caused the error. 



#32   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 13 January 2017 - 19:51

@xinn2005  Cindy you might want to have a look and see what was done to fix it, if anything, on the EDGE version.  I think it is PHP 7 ready.

 

Dan



#33   dr_lucas

dr_lucas
  • Members
  • 331 posts
  • Real Name:Michaela
  • Gender:Female

Posted 13 January 2017 - 19:59

You can easily fix it.

Read this:

http://stackoverflow...-extended-class



#34   xinn2005

xinn2005
  • Members
  • 7 posts
  • Real Name:Cindy Na
  • Gender:Female
  • Location:United States

Posted 13 January 2017 - 19:59

@Dan Cole Thanks for the info Dan! I was actually looking for the PHP7 compatible version. Another way to deal with it is to bypass calls to messageStack within create_account. Will see how these approaches work out. Appreciate your help!



#35   xinn2005

xinn2005
  • Members
  • 7 posts
  • Real Name:Cindy Na
  • Gender:Female
  • Location:United States

Posted 13 January 2017 - 20:02

@dr_lucas Exactly the topic I've been searching for! I did some similar work but it didn't go through. Will take a closer look. Thanks a bunch!



#36   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 13 January 2017 - 21:23

@xinn2005  And you'll find EDGE here if you want to have a look at it or contribute to it.

 

Dan



#37   Lioelx

Lioelx
  • Members
  • 157 posts
  • Real Name:Lionel
  • Gender:Male
  • Location:Spain

Posted 14 January 2017 - 12:06

Hi all

This is correct?

Original code

  class cm_navbar {
    var $code;
    var $group;
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function cm_navbar() {
      $this->code = get_class($this);
      $this->group = basename(dirname(__FILE__));

      $this->title = MODULE_CONTENT_NAVBAR_TITLE;
      $this->description = MODULE_CONTENT_NAVBAR_DESCRIPTION;

      if ( defined('MODULE_CONTENT_NAVBAR_STATUS') ) {
        $this->sort_order = MODULE_CONTENT_NAVBAR_SORT_ORDER;
        $this->enabled = (MODULE_CONTENT_NAVBAR_STATUS == 'True');
      }
    }

Changed code for php7.1

  class cm_navbar {
    var $code;
    var $group;
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function __construct() {
      $this->code = get_class($this);
      $this->group = basename(dirname(__FILE__));

      $this->title = MODULE_CONTENT_NAVBAR_TITLE;
      $this->description = MODULE_CONTENT_NAVBAR_DESCRIPTION;

      if ( defined('MODULE_CONTENT_NAVBAR_STATUS') ) {
        $this->sort_order = MODULE_CONTENT_NAVBAR_SORT_ORDER;
        $this->enabled = (MODULE_CONTENT_NAVBAR_STATUS == 'True');
      }
    }

The cange is line 21

Regards


No external links here, thank you


#38   xinn2005

xinn2005
  • Members
  • 7 posts
  • Real Name:Cindy Na
  • Gender:Female
  • Location:United States

Posted 14 January 2017 - 13:51

@Lioelx Yes that was the correct fix. 



#39   Lioelx

Lioelx
  • Members
  • 157 posts
  • Real Name:Lionel
  • Gender:Male
  • Location:Spain

Posted 14 January 2017 - 16:43

Tanks @xinn2005.

Well put the 2.3.4 gold for php7 has a lot of work ...


No external links here, thank you


#40   Dan Cole

Dan Cole
  • Community Sponsor
  • 1,647 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 14 January 2017 - 17:08

This might be of help....

 

https://github.com/B...i/PHP-7-changes

 

Dan