-
-
Notifications
You must be signed in to change notification settings - Fork 181
fix for i18n bug on php7.1 returns false on isset evaluation... #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ng translation returning always default culture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance to add a test to generate the error?
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');
} SolutionJust 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works!
What is missing now to get it into master?
P.S.: here some more info on the isset & ArrayAccess php bug: https://bugs.php.net/bug.php?id=69659
{ | ||
$culture = sfDoctrineRecord::getDefaultCulture(); | ||
if (isset($record['Translation'][$culture]) && '' != $record['Translation'][$culture][$name]) | ||
if (is_subclass_of($record['Translation'][$culture], 'Doctrine_Record') && '' != $record['Translation'][$culture][$name]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point of view.
We need to take gloves, as the test suite does not cover this part of the code.
Using is_subclass_of()
is too much.
Indeed, it works.
This change forces the call on $record->get('Translation')
.
Which was not done on PHP 7+ but done on PHP 5, with the isset()
.
To dig deeper, read #184 (comment)
Also, the same bug has been fixed on doctine1 where there is a proof that works as it should.
…making translation return always default culture translation. It should be true.