PHP7 will deprecate PHP4 Style constructors https://wiki.php.net/rfc/remove_php4_constructors. We need to convert them.

@blank reported: in php7, following warning is occured

 Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor 在 require_once() (行 127 在 /usr/share/drupal7/sites/all/modules/ctools/ctools.module).

    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor 在 require_once() (行 127 在 /usr/share/drupal7/sites/all/modules/ctools/ctools.module).

    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor 在 require_once() (行 127 在 /usr/share/drupal7/sites/all/modules/ctools/ctools.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

estudionet’s picture

With PHP7 I have the following messages:


    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; views_many_to_one_helper has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; views_display has a deprecated constructor in require_once() (line 3186 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\includes\bootstrap.inc).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).
    Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; views_many_to_one_helper has a deprecated constructor in require_once() (line 127 of C:\Bitnami\wampstack-7.0.0RC2-0\apache2\htdocs\drupal\sites\all\modules\ctools\ctools.module).

skyredwang’s picture

Title: php7 error for ctools » Deprecating PHP4 style constructors
Version: 7.x-1.7 » 7.x-1.x-dev
Assigned: RamboLau » skyredwang
Category: Support request » Task
Priority: Normal » Major
Issue summary: View changes

I am fixing this, based on the warning I have received and the warnings listed in the issue.

skyredwang’s picture

Assigned: skyredwang » Unassigned
Status: Active » Needs review
FileSize
1.67 KB

Status: Needs review » Needs work

The last submitted patch, 3: Deprecating-PHP4-Style-Constructors-2528736-3.patch, failed testing.

skyredwang’s picture

Assigned: Unassigned » skyredwang

We need to also update how Ctools call super/parent constructor.

skyredwang’s picture

Assigned: skyredwang » Unassigned
Status: Needs work » Needs review
FileSize
1.7 KB

Status: Needs review » Needs work

The last submitted patch, 6: Deprecating-PHP4-Style-Constructors-2528736-5.patch, failed testing.

skyredwang’s picture

Status: Needs work » Needs review
FileSize
1.71 KB

ctools_context_optional passes NULL to its parent constructor, as the parent has everything that can be passed by the child already.

Neo13’s picture

Works OK.

japerry’s picture

Status: Needs review » Fixed

Thanks skyredwang for the patch. Fixed!

  • japerry committed 96e56f5 on 7.x-1.x authored by skyredwang
    Issue #2528736 by skyredwang: Deprecating PHP4 style constructors
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jhedstrom’s picture

Would be awesome to roll a new release that includes this fix :)

sylus’s picture

Thanks so much for catching just updating tests on Travis CI and saw this deprecation.

Fabianx’s picture

Yes, a new release would be great!

Terry.Weymouth’s picture

I am also seeing this, now - 7.x-1.9

--

Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of /Users/weymouth/working/software/Drupal/docroot-from-lib/sites/all/modules/ctools/ctools.module).
Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of /Users/weymouth/working/software/Drupal/docroot-from-lib/sites/all/modules/ctools/ctools.module).
Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of /Users/weymouth/working/software/Drupal/docroot-from-lib/sites/all/modules/ctools/ctools.module).

popomyint’s picture

Please!

I am a new learner. I also face this error. How can I solve this.

Thanks

dddave’s picture

@popomyint use the dev version

paranojik’s picture

Status: Closed (fixed) » Needs review
FileSize
764 bytes

This patch crippled optional contexts. I don't think overriding the ctools_context_optional constructor is neccessary.

heddn’s picture

Status: Needs review » Closed (fixed)

re #19: please open a new issue. It is not considered good form (for several reasons) to re-open an already closed issue. Feel free to mention this issue when you open the new one and even cross-post the issue number in here.

sylus’s picture

Additionally a reproduction step oh how this cripples optional contexts as I can't seem to reproduce. Thx!

paranojik’s picture

There you go: https://www.drupal.org/node/2657834.

@stylus: reproduction steps provided...

sylus’s picture

Just attaching a patch with fix for drush make purposes.

rexy00’s picture

Hey!
I've done the patch, but I still get the same error. Any idea?
Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor require_once() (C:\xampp\htdocs\drupal\sites\all\modules\ctools\ctools.module in line 127).
Thanks, have nice day!

MustangGB’s picture

fikifir’s picture

Version: 7.x-1.x-dev » 7.x-1.9

Just works like a charm.

MustangGB’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
TrevorBradley’s picture

I've started porting my sites from Ubuntu 12.04LTS servers to Ubuntu 16.04 LTS servers. I'm also getting this error, even after upgrading to the dev version (server reports the version as 7.x-1.9+4-dev). Is it still broken? Which patch works?

EDIT: Hold on, I'm not paying enough attention. It's an error on the same line, but it's complaining about panels now...

EDIT2: Yup - I needed to upgrade to panels-7.x-3.x-dev in addition to ctools-7.x-1.x-dev. I'm all good now!

xiantaott’s picture

Patches are useless to me why?
finally use the dev version.

Martin.Schwenke’s picture

The 7.x version of this module is in use on over 850,000 sites. Many of those would be production sites. 8.x is alpha with a statement on the project page that it is not usable yet. Drupal 7 requires PHP 5.2.4 and higher, with no upper limit specified.

So, right now there is no *release* of ctools that works with modern Drupal on PHP 7. How is this issue "fixed"?

It doesn't seem right to tell site admins to run the development version on their production sites. That introduces problems in the available updates report where they are constantly told they are running a non-recommended version and an upgrade is available.

Can you please consider doing a release?

MustangGB’s picture

This issue is fixed, if you want to track progress of a new release try #2554339: Plan for CTools 7.x-1.10 release or #2554511: Plan for CTools 7.x-1.10 release.