Fixed Error with activity summary sections having a title containing a "." character

AddonsLab

Well-known member
Affected version
2.2.6 Patch 1
If an activity summary section has a custom title with a "dot" in it, e.g. "Second thread with very long title. Another title here" sending a test email generates the following PHP error:

InvalidArgumentException: Phrase rendering error: Phrase group Second thread with very long title is not a valid format src/XF/Language.php:278
#0 src/XF/Language.php(247): XF\Language->loadPhraseGroup('Second thread w...')#1 src/XF/Language.php(130): XF\Language->getPhraseText('Second thread w...')
#2 src/XF/Phrase.php(52): XF\Language->renderPhrase('Second thread w...', Array, 'html', Array)
#3 src/XF/Phrase.php(59): XF\Phrase->render()
#4 src/XF.php(1169): XF\Phrase->__toString()
#5 src/XF/Template/Templater.php(1194): XF::escapeString(Object(XF\Phrase), 'html')
#6 internal_data/code_cache/templates/l1/s1/email/activity_summary.php(28): XF\Template\Templater->escape(Object(XF\Phrase))
#7 src/XF/Template/Templater.php(1644): XF\Template\Templater->{closure}(Object(XF\Mail\Templater), Array, NULL)
#8 src/XF/Mail/Mailer.php(216): XF\Template\Templater->renderTemplate('activity_summar...', Array)
#9 src/XF/Mail/Mailer.php(150): XF\Mail\Mailer->renderPartialMailTemplate('activity_summar...', Array, Object(XF\Language), Object(CG\UserReward\XF\Entity\User))
#10 src/XF/Mail/Mail.php(335): XF\Mail\Mailer->renderMailTemplate('activity_summar...', Array, Object(XF\Language), Object(CG\UserReward\XF\Entity\User))
#11 src/XF/Mail/Mail.php(403): XF\Mail\Mail->renderTemplate()
#12 src/XF/Mail/Mail.php(417): XF\Mail\Mail->getSendableMessage()
#13 src/addons/AL/TestFramework/XF/Mail/Mail.php(24): XF\Mail\Mail->send(NULL, true)
#14 src/XF/Job/ActivitySummaryEmail.php(121): AL\TestFramework\XF\Mail\Mail->send()
#15 src/XF/Job/ActivitySummaryEmail.php(67): XF\Job\ActivitySummaryEmail->generateAndSendEmail(Object(CG\UserReward\XF\Entity\User))
#16 src/XF/Job/Manager.php(258): XF\Job\ActivitySummaryEmail->run(7.99999)
#17 src/XF/Job/Manager.php(200): XF\Job\Manager->runJobInternal(Array, 7.99999)
#18 src/XF/Job/Manager.php(116): XF\Job\Manager->runJobEntry(Array, 7.99999)
#19 src/XF/Admin/Controller/Tools.php(120): XF\Job\Manager->runByIds(Array, 8)
#20 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#21 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(CG\AttachmentEssentials\XF\Admin\Controller\Tools), NULL)
#22 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(CG\AttachmentEssentials\XF\Admin\Controller\Tools), NULL)
#23 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#24 src/XF/App.php(2344): XF\Mvc\Dispatcher->run()
#25 src/XF.php(512): XF\App->run()
#26 admin.php(13): XF::runApp('XF\\Admin\\App')
#27 {main}
It seems the reason is that in the file src/XF/ActivitySummary/Instance.php the text is used as a phrase:
Code:
public function addDisplayValue($label, $value)
{
   if (!($label instanceof \XF\Phrase))
   {
      $label = \XF::phrase($label);
   }

   $this->displayValues[] = [
      'label' => $label,
      'value' => $value
   ];
}
 
It seems the reason is that in the file src/XF/ActivitySummary/Instance.php the text is used as a phrase:
That certainly wouldn't be the case by default. That code is responsible for rendering the labels and values for this section of the email:

1626817619584.webp

There's nothing here by default that would try to use a thread title for the label.

I just generated a test email and wasn't able to reproduce this.

I'm thinking that there may be some sort of custom code involved here. Potentially a custom activity summary definition or a modified template.
 
Sorry, I have used a misleading title for the section. Please create any section with a "." in its title e.g. "Latest posts. With custom title" and here is the stack of the error logged in that case:
InvalidArgumentException: Phrase rendering error: Phrase group Latest posts is not a valid format src/XF/Language.php:278
Generated by: admin Jul 21, 2021 at 7:45 AM
Stack trace
#0 src/XF/Language.php(247): XF\Language->loadPhraseGroup('Latest posts')
#1 src/XF/Language.php(130): XF\Language->getPhraseText('Latest posts. W...')
#2 src/XF/Phrase.php(52): XF\Language->renderPhrase('Latest posts. W...', Array, 'html', Array)
#3 src/XF/Phrase.php(59): XF\Phrase->render()
#4 src/XF.php(1169): XF\Phrase->__toString()
#5 src/XF/Template/Templater.php(1194): XF::escapeString(Object(XF\Phrase), 'html')
#6 internal_data/code_cache/templates/l1/s1/email/activity_summary.php(28): XF\Template\Templater->escape(Object(XF\Phrase))
#7 src/XF/Template/Templater.php(1644): XF\Template\Templater->{closure}(Object(XF\Mail\Templater), Array, NULL)
#8 src/XF/Mail/Mailer.php(216): XF\Template\Templater->renderTemplate('activity_summar...', Array)
#9 src/XF/Mail/Mailer.php(150): XF\Mail\Mailer->renderPartialMailTemplate('activity_summar...', Array, Object(XF\Language), Object(CG\UserReward\XF\Entity\User))
#10 src/XF/Mail/Mail.php(335): XF\Mail\Mailer->renderMailTemplate('activity_summar...', Array, Object(XF\Language), Object(CG\UserReward\XF\Entity\User))
#11 src/XF/Mail/Mail.php(403): XF\Mail\Mail->renderTemplate()
#12 src/XF/Mail/Mail.php(417): XF\Mail\Mail->getSendableMessage()
 
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.2.7).

Change log:
Avoid throwing an error when sending an activity summary that has a section title containing a dot.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom