-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fix GridView generating unused label values (issue #19899). #19900
Conversation
PowerGamer1
commented
Jul 18, 2023
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues | #19899 |
PR Summary
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #19900 +/- ##
===========================================
- Coverage 48.39% 18.19% -30.21%
===========================================
Files 445 445
Lines 42302 42561 +259
===========================================
- Hits 20474 7744 -12730
- Misses 21828 34817 +12989
☔ View full report in Codecov by Sentry. |
Are we sure this is not used? |
Its fine. From your link:
Which will happen at the moment when the label is actually needed here: https://github.com/yiisoft/yii2/blob/master/framework/data/Sort.php#L364-L366. That is if the |
Using |
That's not a problem of my fix but a bad engine design to begin with. For example, that exact "not correct behavior" you are referring to happens without my fix if you use |
That is a regression created by your PR. So yes, it is a problem with your PR. You can question the design, by you can't ignore its limitations and break existing behavior because it does not match your particular use case. Generating labels when they're not needed is not perfect, but ignoring labels form
In that case we should improve |
I wouldn't be so sure. Calling "regression" a change in UNDOCUMENTED behaviour is stretching it - nothing in the doc for
And this is where I strongly disagree. The problem you referring to "ignoring labels form
What this PR fixes:
And unlike your problem my (multiple) problems happen when using the
We fix multiple issues and remove some poorly implemented undocumented behaviour. After that, sure, implement label pulling from |
This is not some random typo that created bug/feature, this is an intentional code to keep this behavior on pair with grid view or detail view (they use attribute labels from model too). Dismissing consistent and sensible behavior as undocumented - that is stretching.
Workaround is pretty simple: define all used labels in model. I believe the is preferred solution anyway - in most cases it is much easier to maintain labels in model than duplicating them everywhere separate for grid, sorting or detail view. |
Yes this behavior is intentional but it is still poorly implemented and undocumented.
It's not. Because in practice a single model attribute has different labels depending on the context the label is used in (one label for forms, different for different grids, etc). |
Nonetheless, defining generic label in model is simple and solves your problem from #19899, without the need of altering framework and removing an useful feature from it. |
So having a choice of:
you choose p.2. In that case suit yourself. Might as well freeze the framework in its current state and let it die already. |
Fetching attribute labels from model is consistent with grid and detail views - removing it would create inconsistency in framework behavior. |
That's a two-edged sword. Since the behaviour is undocumented I can say that it is inconsistent with
No, removing it because it comes with objective cons.
So what? In the past there were many breaking changes including those that broke my projects too. And among them a lot were unwarranted - with cons outweighing the pros. I don't recall the team so vigorously arguing against those back then. But, as I already said in previous posts, in this case the pros outweigh the cons so the change is actually warranted here. Actually, there will be no cons here - as soon as the currently broken behaviour is properly reimplemented. Anyway, we are going in circles now. Fun fact: in the time you spend arguing with me you could have reimplemented that "oh so important" broken feature of yours properly. Can't do it? Ok, I'll do it for you as part of my fix. And as for you (and everyone else on the maintaining team) at least have a decency to TAKE A LOOK at INFINITELY MORE IMPORTANT problem in the engine here: #19788 and do something about it (like finding courage to revert BC breaking changes from the past responsible for it). |
But to weigh those cons more heavy than breaking backwards compatibility very much is.
Because it happened in the past by accident, you now want to use that as an argument to do it consciously? Other developers, including myself, have had pull requests rejected because it turned out that it would break BC, even if it would be more correct according to the documentation. But in general, the code is leading; Not the docs. Based on your last comment you seem to agree that it's a BC breaking change? If so, please update the "Breaks BC?" row in the opening post. Personal blaming won't resolve anything, so let's have a constructive dialogue on how to resolve the inconsistency. Perhaps it's something that can be fixed in Yii2.2? |
Yeah, right, "by accident". Every BC break I was speaking about (or the change that led to BC break) was INTENTIONAL and never reverted. Here is one for you: #19788.
Says the maintainer of an engine for which the main selling point was ... the docs. What a sad state of affairs.
As I said in my last comment, I already spend all those 5 mins to fix that badly implemented "feature" you so fond of (for which you prefer waste time to argue and defend instead of actually fixing) so now there are no longer any BC breaks (in undocumented behaviour or otherwise) in my PR.
There better be a version of Yii soon that starts breaking BC left and right and won't stop doing it, or otherwise Yii is really dead. You may start with #19788. |
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.
It would be great to have tests covering usage of Sort::$modelClass
, but overall solution looks good.
@PowerGamer1 have courage for @rob006 suggestion? |
How about @rob006 finds courage to write tests for that EXISTING undocumented and untested behaviour (the one I had to fix for him) first? They will cover nicely code path in this PR using @samdark |
Aha. I've re-checked the tests and these are enough. |
Thanks! |