Fixed Inconsistent extracting phrase group from phrase title

Xon

Well-known member
Affected version
2.2.12
\XF\Entity\Phrase
PHP:
	public function getPhraseGroup($new = true)
	{
		$title = $new ? $this->getValue('title') : $this->getExistingValue('title');
		if (!$title || !preg_match('/^([a-z0-9_]+)\./i', $title, $match))
		{
			return null;
		}
...

XF\Service\Phrase\Rebuild
PHP:
	protected function _rebuildPhraseMap($id, array $map, array $phraseList)
	{
...
			$parts = explode('.', $title);

\XF\Language
PHP:
	public function getPhraseText($name)
	{
...
		$parts = explode('.', $name, 2);

The first two likely should match the 3rd. ie explode with a limit of 2.

getPhraseGroup also has the issue with dealing with a falsy title. The phrase title 0.foo will be regarded as non-grouped when the entity is about to save the phrase but will be considered grouped when trying to use it.
 
We now have a null check on variables set by getPhraseGroup to workaround the falsy issue.

But in terms of the specific implementations of how the title is split, I don't particularly see an issue. In each case, the subsequent code is used appropriately and produces the expected results.

Unless there's a specific bug not mentioned that I'm overlooking?
 
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.13).

Change log:
Add null checks when we're inspecting the result of the getPhraseGroup method of the Phrase entity.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom