symfony1 icon indicating copy to clipboard operation
symfony1 copied to clipboard

fix for i18n bug on php7.1 returns false on isset evaluation...

Open jomiojeda opened this issue 7 years ago • 2 comments

…making translation return always default culture translation. It should be true.

jomiojeda avatar Feb 27 '18 17:02 jomiojeda

I will try to when I have some time. For now the fix solved the problem for our client. Thanks.

jomiojeda avatar Mar 02 '18 15:03 jomiojeda

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().

alquerci avatar Jul 21 '18 19:07 alquerci