Fixed getRelationOrDefault fails when condition is set to empty string

TickTackk

Well-known member
Affected version
2.1.10 P2+
Code:
ErrorException: [E_NOTICE] Uninitialized string offset: 0 src/XF/Mvc/Entity/Manager.php:667
...
#0 src/XF/Mvc/Entity/Manager.php(667): XF::handlePhpError()
#1 src/XF/Mvc/Entity/Entity.php(407): XF\Mvc\Entity\Manager->hydrateDefaultFromRelation()
#2 src/addons/<add-on id>/Repository/<repo name>.php(35): XF\Mvc\Entity\Entity->getRelationOrDefault()
#3 src/addons/<add-on id>/Setup.php(79): <add-on id>\Repository\<repo name>-><method name>()
#4 src/XF/AddOn/AddOn.php(523): <add-on id>\Setup->postInstall()
#5 src/XF/Cli/Command/AddOnSubAction.php(75): XF\AddOn\AddOn->postInstall()
#6 src/vendor/symfony/console/Command/Command.php(255): XF\Cli\Command\AddOnSubAction->execute()
#7 src/vendor/symfony/console/Application.php(987): Symfony\Component\Console\Command\Command->run()
#8 src/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand()
#9 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun()
#10 src/XF/Cli/Runner.php(63): Symfony\Component\Console\Application->run()
#11 cmd.php(15): XF\Cli\Runner->run()
#12 {main}
Relation in entity structure:
PHP:
            'MasterTitle' => [
                'entity' => 'XF:Phrase',
                'type' => static::TO_ONE,
                'conditions' => [
                    ['language_id', '=', 0],
                    ['title', '=', static::TITLE_PHRASE_GROUP, '$uint_primary_key'],
                    ['addon_id', '=', '']
                ]
            ],
 
Last edited:
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.0 Beta 4).

Change log:
Ensure relation condition string is non-empty before checking its value
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom