Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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).
Comments
Comment #1
estudionet CreditAttribution: estudionet commentedWith PHP7 I have the following messages:
Comment #2
skyredwangI am fixing this, based on the warning I have received and the warnings listed in the issue.
Comment #3
skyredwangComment #5
skyredwangWe need to also update how Ctools call super/parent constructor.
Comment #6
skyredwangComment #8
skyredwangctools_context_optional passes NULL to its parent constructor, as the parent has everything that can be passed by the child already.
Comment #9
Neo13 CreditAttribution: Neo13 commentedWorks OK.
Comment #10
japerryThanks skyredwang for the patch. Fixed!
Comment #13
jhedstromWould be awesome to roll a new release that includes this fix :)
Comment #14
sylus CreditAttribution: sylus commentedThanks so much for catching just updating tests on Travis CI and saw this deprecation.
Comment #15
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedYes, a new release would be great!
Comment #16
Terry.Weymouth CreditAttribution: Terry.Weymouth as a volunteer commentedI 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).
Comment #17
popomyint CreditAttribution: popomyint commentedPlease!
I am a new learner. I also face this error. How can I solve this.
Thanks
Comment #18
dddave CreditAttribution: dddave commented@popomyint use the dev version
Comment #19
paranojik CreditAttribution: paranojik at Cando commentedThis patch crippled optional contexts. I don't think overriding the ctools_context_optional constructor is neccessary.
Comment #20
heddnre #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.
Comment #21
sylus CreditAttribution: sylus commentedAdditionally a reproduction step oh how this cripples optional contexts as I can't seem to reproduce. Thx!
Comment #22
paranojik CreditAttribution: paranojik at Cando commentedThere you go: https://www.drupal.org/node/2657834.
@stylus: reproduction steps provided...
Comment #23
sylus CreditAttribution: sylus commentedJust attaching a patch with fix for drush make purposes.
Comment #24
rexy00 CreditAttribution: rexy00 as a volunteer commentedHey!
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!
Comment #25
MustangGB CreditAttribution: MustangGB commentedCould we get the other PHP7 issue committed?
#2640404: PHP 7 Undefined property: stdClass::$Array in page_manager_page_manager_pages_to_hook_code
Comment #26
fikifir CreditAttribution: fikifir commentedJust works like a charm.
Comment #27
MustangGB CreditAttribution: MustangGB commentedComment #28
TrevorBradley CreditAttribution: TrevorBradley commentedI'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!
Comment #29
xiantaott CreditAttribution: xiantaott commentedPatches are useless to me why?
finally use the dev version.
Comment #30
Martin.Schwenke CreditAttribution: Martin.Schwenke commentedThe 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?
Comment #31
MustangGB CreditAttribution: MustangGB commentedThis 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.