Fixed Template compile error when entity is missing Master Phrase relation

pegasus

Well-known member
Affected version
2.3.0 Beta 1
In 2.3.0, the Templater has added the new processEntityAttributes method, which fills an attribute value automatically based on an entity's phrase value. This works great, until we run into an entity that is missing its Master Phrase for some reason, maybe accidental deletion of the phrase.

I ran into this issue when using the AdminCP to attempt to edit a BB-Code that was missing its Master Phrase for the description, figuring I could just edit the field and thus regenerate the appropriate phrase. However, instead of the editor, I received the following error message:
Code:
Template Compilation Error
admin:bb_code_edit - Call to a member function get() on null in /[redacted]/src/XF/Template/Templater.php:6916
The issue rests in this line:
Code:
$attributes['value'] = $entity->exists() ? $entity->$masterPhraseRelation->get('phrase_text') : '';
I was able to temporarily resolve it with the following replacement:
Code:
$attributes['value'] = ($entity->exists() AND $entity->$masterPhraseRelation) ? $entity->$masterPhraseRelation->get('phrase_text') : '';

In 2.2.15, this error does not occur when editing an entity that is missing master-phrases.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0 Beta 3).

Change log:
Fix template compilation error when an entity master phrase relation is missing
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom