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.
Problem/Motivation
After switching to PHP8 appeared error "Reference to undeclared constant \THEMEKEY_PAGECACHE_SUPPORTED. in crumbs.info.inc on line 195"
Comment | File | Size | Author |
---|---|---|---|
#5 | crumbs-3269426-php-8.0-compatibility.patch | 485 bytes | Dmitrii_Zadorozhnyi |
Comments
Comment #2
Dmitrii_Zadorozhnyi CreditAttribution: Dmitrii_Zadorozhnyi at EPAM Systems commentedI would suggest to apply a patch
Comment #3
donquixote CreditAttribution: donquixote commentedThis is a bit strange, I need more info why this happens.
The function crumbs_themekey_properties() should only be called if themekey is enabled.
And THEMEKEY_PAGECACHE_SUPPORTED is defined in themekey.module.
The constant is globally defined by themekey since 7.x-1.5, commit c9e55075e3bb6 happened in 2011.
Are you using an older version of themekey?
Or is themekey not enabled, and the hook is called nevertheless?
Comment #4
donquixote CreditAttribution: donquixote commentedAlso:
- Doesn't seem to be related to PHP 8.0 compatibility.
- Your patch has wrong indentation.
Comment #5
Dmitrii_Zadorozhnyi CreditAttribution: Dmitrii_Zadorozhnyi at EPAM Systems commentedSorry, i added patch with correct indentation.
Comment #6
Dmitrii_Zadorozhnyi CreditAttribution: Dmitrii_Zadorozhnyi at EPAM Systems commentedUndeclared constant will cause fatal error in php 8.0+. So i added additional checking that this constant defined, in case if it will be deleted or renamed.
Comment #7
donquixote CreditAttribution: donquixote commentedThen we would also need to call
function_exists()
whenever we want to call a function from another module.Should we do that, or should we rely on new versions respecting backwards compatibility? I think at this point in the Drupal 7 life cycle we don't need to worry that the constant might be removed in themekey :)
Comment #8
apadernoIf
crumbs_themekey_properties()
is a hook invoked only from the ThemeKey module, which defines that constant in the themekey.module file, that error message could only happen in a case: whenhook_themekey_properties()
is invoked but the themekey.module file isn't loaded. Could this happen?