Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Posts
    1,462
    Plugin Contributions
    10

    Default deprecated constructors

    with 1.5.6b and PHP 7.1.30, I get a few notices saying
    Code:
    PHP Deprecated:  Methods with the same name as their class will not be  constructors in a future version of PHP; ec_analytics has a deprecated  constructor
    If I change the method to
    PHP Code:
     __ec_analytics() 
    do I need to change anything else in any other files like the autoloader?

    Zen Cart and it's community are the best!!

  2. #2
    Join Date
    Jul 2012
    Posts
    14,795
    Plugin Contributions
    17

    Default Re: deprecated constructors

    The constructor for a class would become just the generic:
    __construct()

    member.

    But, need to also look through the code to see if there are/were specific calls to the member function ec_analytics other than declaring a new variable of that type.

    If so, then it may be desirable to add a __construct() function above the existing function of the class' name and then have that function call the old constructor...

    Sorry, digress a little.

    Adding two underscores in front of the existing name won't resolve the usage issue.

    Further note this format is becoming required in php 7.x but has been available since at least early php 5.x.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  3. #3
    Join Date
    Jan 2007
    Posts
    1,462
    Plugin Contributions
    10

    Default Re: deprecated constructors

    OK, thanks for the info. I searched and don't see where any of the affected modules' methods are called so I changed them to __construct() and the notices have disappeared. This was in ec analytics, keep cart, search log and back in stock notifications observer classes. Since it's just a notice it's probably not worth updating the mods at this point.

    Zen Cart and it's community are the best!!

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,849
    Plugin Contributions
    25

    Default Re: deprecated constructors

    Quote Originally Posted by lankeeyankee View Post
    Since it's just a notice it's probably not worth updating the mods at this point.
    That is where i disagree with you. This IS the time to update, because now it is only a warning. in a next php version, that warning will become a fatal error, because the constructor is not allowed to be the same as the class name any more.
    So you could see this as a friendly reminder of php to tell you it is time to change that piece of code. Don't wait until it is broken.

  5. #5
    Join Date
    Jan 2007
    Posts
    1,462
    Plugin Contributions
    10

    Default Re: deprecated constructors

    OK, I will test it a bit on my dev 1.5.6b for a bit to see if anything else needs changing then will upload the updated packages. There are a few other notices that I don't really know how to correct, it's been so long since I've done anything beyond some basic changes that I have forgotten much. I will post the specific issues in the related threads to see if others can help solve the issues.

    Zen Cart and it's community are the best!!

 

 

Similar Threads

  1. v137 Deprecated: Function ereg() is deprecated Error
    By esugrue in forum General Questions
    Replies: 6
    Last Post: 28 Mar 2012, 11:40 PM
  2. Deprecated: Function ereg() is deprecated
    By hsartcorp in forum General Questions
    Replies: 3
    Last Post: 19 Sep 2011, 08:08 PM
  3. Can't Login Any More: "Deprecated: Function ereg() is deprecated"
    By Slicer5489 in forum Basic Configuration
    Replies: 3
    Last Post: 21 May 2011, 11:16 PM
  4. Replies: 2
    Last Post: 3 Mar 2010, 12:53 PM
  5. Replies: 4
    Last Post: 16 Jan 2010, 02:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR