Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
views.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Jan 2017 at 04:49 UTC
Updated:
3 Dec 2018 at 11:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
shadcn commentedLooks like this is missing for the
Someplugin only.Comment #3
chi commentedSince negative values make no sense for these fields I propose we set #min value for them to zero.
Comment #4
shadcn commentedComment #5
chi commentedAs you changed settings in the SqlBase class the scope of the issue is slightly extended. Actually I think it would be better. So let's fix all Views pager plugins at once.
Here are the elements that needs to be fixed after applying patch #4.
Comment #6
chi commentedWell, I would like someone to confirm this statement.
Comment #7
jaykandariComment #8
jaykandariExtended #4 to include changes mentioned in #5.
Comment #9
shadcn commentedThanks @JayKandari. Can you please include an interdiff?
Comment #10
jaykandariSure !
Resubmitted #8 & an interdiff from #4.
Thanks !
Comment #11
chi commentedThis looks fine for me. Thanks.
Comment #12
cilefen commentedI like this issue! +1
The scope of the issue was expanded in #5—rightly, those are bugs—but the issue summary and title have not changed. Please update it. Test are a core gate. We need some here in order to prevent this happening again.
Manually testing this patch made me notice that Views doesn't validate this input at all. It turns out, courtesy of xjm, there is already an issue open for that: #2392823: [meta] Much Views UI input is not validated. I opened #2853054: Add validation constraints for views pager config to address pagers specifically.
Thank you!
Comment #13
chi commented@cilefen, what kind of tests are expected here? Shall we load the form objects and check #type property of these elements? Could you please point out existing tests that check type of form elements?
Comment #14
cilefen commentedDrupal\views\Tests\Plugin\PagerTest and you can probably do an xpath search to verify the element type.
Comment #15
chi commentedThis approach sounds too formal. The PagerTest will be inconsistent. If we test
'#type' = 'number'we should test all other types and perhaps not just types but any kind of form properties as well (#title, #options, etc).Comment #16
cilefen commentedWhat do you suggest?
Comment #17
chi commentedI would just give this up at least in this patch. We could create a followup to improve the PagerTest but it does not much differ from tons of other core tests which deal with forms. As far as I have learned we generally don't care about testing form elements in details.
Comment #18
cilefen commentedThe real problem, in this case, is #2853054: Add validation constraints for views pager config. It's up to you if you want to re-RTBC this and see if the other committers agree with you. It's a simple enough change. But I can't apply my own discretion in a provisional role.
Comment #19
chi commentedOk. Let's check what other committers will say about this.
Comment #20
xjmI agree that we need automated test coverage: https://www.drupal.org/core/gates#testing We are adding a minimum value here, so we should both ensure that our automated tests test that expected UI input leads to expected results (and simply document/demonstrate if so) and also add test coverage that now values lower than the minimum aren't accepted. It can be a fairly simple addition to the existing test, probably just an assertion or two. The goal is not to test the Form API, just the pager UI basic functionality.
Simple manual testing and a screenshot showing the UI change would also be nice here, so tagging for that too.
I agree also with scoping the validation issue to a followup. That's definitely something that needs to be addressed in Views, but not in scope for this small UX improvement.
Thanks @cilefen and @Chi!
Comment #21
chi commentedAdded a test.
So far we have 12 number elements in pager settings forms. I've added assertions for each one.
Here is a quick inventory:
Comment #25
joachim commentedLGTM.
Comment #26
krzysztof domańskiCorrecting a patch #21 that is out of date for 8.7.x-dev.
Comment #27
msankhala commentedLGTM
Comment #29
Anonymous (not verified) commentedUnrelated error #28. Test pass. Mark again as RTBC.
Comment #30
alexpottCommitted bcfce36 and pushed to 8.7.x. Thanks!