symfony1
symfony1 copied to clipboard
fix for i18n bug on php7.1 returns false on isset evaluation...
…making translation return always default culture translation. It should be true.
I will try to when I have some time. For now the fix solved the problem for our client. Thanks.
It is not a PHP-7 bug but just a modification of the deep isset behaviour.
Deep isset() on class that implement ArrayAccess
<?php
isset($arrayAccess['foo']['bar']);
Before PHP-7.0
<?php
$arrayAccess->offsetGet('foo')->offsetExists('bar');
PHP-7.0 and after
<?php
if ($arrayAccess->offsetExists('foo')) {
$arrayAccess->offsetGet('foo')->offsetExists('bar');
}
Solution
Just need to do the following modification.
<?php
// The relationship must be fetched in order to check the culture existance.
// Related to PHP-7.0 compatibility so an explicit call to method get is required.
$translation = $record['Translation'];
// process the translation.
PS: There is the same behaviour for deep isset() on class that define __isset() and __get().