Problem/Motivation

After switching to PHP8 appeared error "Reference to undeclared constant \THEMEKEY_PAGECACHE_SUPPORTED. in crumbs.info.inc on line 195"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dmitrii_Zadorozhnyi created an issue. See original summary.

Dmitrii_Zadorozhnyi’s picture

I would suggest to apply a patch

donquixote’s picture

This 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?

donquixote’s picture

Also:
- Doesn't seem to be related to PHP 8.0 compatibility.
- Your patch has wrong indentation.

Dmitrii_Zadorozhnyi’s picture

FileSize
485 bytes

Sorry, i added patch with correct indentation.

Dmitrii_Zadorozhnyi’s picture

Undeclared 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.

donquixote’s picture

Undeclared 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.

Then 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 :)

apaderno’s picture

Issue tags: -PHP8.0, -PHP 8.1 +PHP 8.0

If 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: when hook_themekey_properties() is invoked but the themekey.module file isn't loaded. Could this happen?