yii2: #14456 breaks backward compatibility

Regarding https://github.com/yiisoft/yii2/pull/14456#issuecomment-327409143 I think the PR #14456 breaks backward compatibility.

You can totally have some classes extending BaseActiveRecord (which implements ActiveRecordInterface which extends StaticInstanceInterface) and having an instance() method.

See for instance Humhub: https://github.com/humhub/humhub/blob/master/protected/humhub/modules/user/models/GroupPermission.php#L26

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 22 (21 by maintainers)

Commits related to this issue

Most upvoted comments

how about renaming the method to modelInstance() to make it less likely to conflict?

And what about following comment then: https://github.com/yiisoft/yii2/pull/14456#issuecomment-323966799 ?

We have already decided the naming, besides who can tell someone have not declared modelInstance() method inside his ActiveRecord.

We have already placed the note to UPGRAGE.md, I can not see why there should be anything else to be done.

There is a versioning policy, which explains what changes may appear at particualr release. For the 2.0.x there is an explanation: https://github.com/yiisoft/yii2/blob/master/docs/internals/versions.md#2xy-minor-releases

It is not some secret: you have been warned about it.

Yes, it is a sad thing that we are unable to follow strict versioning rules, but we simply do not have enough resources for that. If we use more strict rules for the releases this framework will not move anywhere as it happens for 2.1 version at the present state.

how about renaming the method to modelInstance() to make it less likely to conflict?

Each update we create tons of new method and we can not predict cases like this. There’s always a possibility that new public or protected method will break users’ code just because of incompatible declaration. I think we have nothing to do it.

isn’t every public API expansion possibly backward-incompatible? There could always be a project who is already using the new method in an extended class - or does this relate to interfaces specifically?

It’s general. Doesn’t matter if it’s a class or interface. In both SemVer and YiiVer it’s allowed to be released in minor version which 2.0.13 is.

while the change from Object to BaseObject has a detailed description what a developer needs to do if he wants to upgrade (also to PHP 7.2) - there’s no advice about instance(). Would a developer needs to rename every method call in his project for example or could he work around it?

No workaround is possible. It’s common for minor versions and I’ve never seen any library is describing every introduced non-private method or property in this manner.

I would rather move these changes to 2.1 milestone than introduce some weird names like modelInstance().

The main issue here is lack of LTS line which contains only BC bugfixes. Right now big projects based on Yii (or extensions) doesn’t have any way to safely use Yii without locking framework version to specific release. Just look at https://github.com/yiisoft/yii2/blob/master/framework/UPGRADE.md - changing method signature or introducing new methods in interfaces are regular BC breakers in last releases. Yii simply does not have BC line - new versions always always bring a risk of serious BC break.

That is why it is mentioned in UPGRADE.