| Q | A
|------------ | ------
| BC Break | no :)
| Version | 2.6.2
Just started to test our software against php7.3. We're using symfony, when it clears the cache we get a RuntimeException as follows. The issue being this line of code
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
In UnitOfWork.php line 2718:
Warning: "continue" targeting switch is equivalent to "break". Did you mean
to use "continue 2"?
I started a docker container that has php 7.3 RC1. docker run -it gnat42/centos7-php73:latest and pulled in our symfony project. composer install -o. It failed on the cache clear step.
No errors.
This is already fixed by #7325 in 2.6 and will be released in 2.6.3.
Ad:
BC Break | yesish :)
Incompatibility with new PHP version is not a BC break, it's rather a BC break in PHP 7.3. :)
Changed it to "no" :-)
Awesome. I tried searching for a pre-existing bug but didn't find one. Glad it's fixed. Thanks for all your hard work everyone
EDIT: This issue has been fixed, ran composer update and the changes I was suggesting were already implemented. My bad :)
Just as a side note, checking the file where the warning comes from, UnitOfWork.php, we find the following structure:
foreach ($class->associationMappings as $field => $assoc) {
//some logic
switch (true) {
case($assoc['type'] & ClassMetadata::TO_ONE):
//some more logic
if(isset($data[$field]) && is_object($data[$field]) && isset($this->entityStates[spl_object_hash($data[$field])])) {
//do stuff
continue; // <---- Statement that gives the error
}
//some more code
} //end of switch
} //end of foreach
Since the switch statement is the last statement on the foreach loop, then using break, continue and continue 2 will all have the same behavior.
Therefore, you are safe to edit the file and replace continue with either break or continue 2 to prevent the warning message. I did so and found no issues.
@VascoRatoGFI Please upgrade, this has been already fixed.
Would I be right in guessing that the 2.5.x branch won't be getting this fix?
Our projects have to be able to run on anything from PHP 7.0 to 7.2, so we can't update to ORM 2.6.x yet. We did try out PHP 7.3 and had this issue, but we can stay away from that until 7.0 drops out of mainstream.
Yes, you're right. 2.5 is unmaintained and there is no plan to back-port that fix.
I have a project with Doctrine ORM 2.5.14 installed. This is the latest 2.5 version, but this one still has this "bug" (and it won't be fixed, since 2.5 is unmaintained). I can't update to 2.6 or 2.7 because the project is still running on Symfony 2.8 and Doctrine ORM 2.6 needs symfony/console 3.0 or higher. So Composer update won't work in this case, because Composer can't update Doctrine ORM to any higher version than 2.5.14...
So now I'm considering a few options and so could others who end up here as well:
@7ochem your reasoning is a bit flawed to me, you seem to be concerned about running php 7.2 after maintenance, but you are already running with unmaintained versions of Symfony and Doctrine for a long time, which should concern you even more imho.
Upgrading S2 to S3 can certainly be a major task, but if you must run on PHP 7.2 that isn't really a bad option.
There are people/providers out there that will still support it. WHM/cPanel still let you run old PHP versions though don't patch the EOL ones. However if you add CloudLinux you will get security patches, way back to PHP 4.4 or something insane like that. You could also use the Sury repository if you're running on Debian (or derivatives), this chap seems to port in patches quite regularly. -- Certainly a viable option if you really don't need anything PHP 7.3+ that can't be provided with a polyfill.
Most helpful comment
Changed it to "no" :-)