Breaking change in XenForo 2.3.7 in getter syntax

AddonsLab

Well-known member
Affected version
2.3.7
Hello!

Today, have got a report about an error in one of our add-ons, not showing the admin panel page. The reason is the admin template contains a call
$config.get_entity_name() however, this now gives template compilation error as with the latest update the getters are hard-coded to be only in camelCase and snake_case does not work anymore. I understand the camel case is the typical and preferred syntax, especially in context of XenForo entities, but this was developed as a custom PHP object that provides information about the page, and as getters in snake case worked, then we considered having two different methods - get_entity_name returns the entity name in snake case (e.g. resource_item) and getEntityName returns the name in camel case (e.g. resourceItem). This is used in different contexts, like phrase names typically would be constructed based on snake case form, and camel case form would be preferred for variable names etc.

Fixing this from our side would require updating the template of every add-on using this syntax. We cannot provide a patch that would work for everyone just upgrading our core library add-on.

This is a breaking change that will affect almost all our customers using our public or custom add-ons based on our admin panel abstractions, and most importantly, they are very unlikely to know about it until they upgrade and get an error.

Please consider adding underscore to the allowlist of the next character of the getter name, e.g. instead of

Code:
if (preg_match('/^(' . implode('|', $prefixes) . ')([A-Z]|$)/', $name))
{
 return true;
}

to have


Code:
if (preg_match('/^(' . implode('|', $prefixes) . ')([A-Z_]|$)/', $name))
{
 return true;
}

If you consider the change to be essential, please push it to 2.4 release so we can warn our customers not to upgrade before applying a fix we will provide.

Thank you!
 
Back
Top Bottom