Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
On a view with a result summary, the result summary is not displayed when there is no result. Even if the checkbox "Display even if view has no result" is checked.
Steps to reproduce :
- Make a view with a result summary in the view header.
- Check "Display even if view has no result" on the result summary.
- Add an exposed filter to get no result in your view.
- When there is no result, the summary is not displayed.
I will attach a patch.
Comment | File | Size | Author |
---|---|---|---|
#35 | interdiff-2782221-22-35.txt | 1.31 KB | Grimreaper |
#35 | drupal-result_summary_not_displayed-2782221-35.patch | 7.55 KB | Grimreaper |
#30 | 2782221-after_patch-without_result.png | 20.46 KB | Grimreaper |
#30 | 2782221-after_patch-with_result.png | 36.25 KB | Grimreaper |
#30 | 2782221-before_patch-without_result.png | 6.28 KB | Grimreaper |
Comments
Comment #2
GrimreaperHere is the patch.
Thanks for the review.
Comment #3
dawehnerThank you for working on this issue! The fix itself looks totally fine.
Do you mind writing a test for this bug as well?
Ideally this comment should answer "why" we need this. The code itself already kinda explains that :)
Comment #4
GrimreaperHello,
Thanks for the review.
Ok, I will make a patch rewording the comment.
About the test, no problem, it is an opportunity for me to learn. But I never wrote test for the core so I don't know exactly how to do it.
Do you want an unit, kernel or functional test? (no more simpletest?)
I also have a problem with automated tests. I tried to follow the documentation https://www.drupal.org/node/2116263, https://www.drupal.org/node/2288559 and an article from commerceguys https://drupalcommerce.org/blog/45322/commerce-2x-unit-kernel-and-functi...
But I can't figure out the step I missed because in PhpStorm when I try to execute the core tests, I have the following error: "PHP Fatal error: Class 'Drupal\Tests\TestSuites\TestSuiteBase' not found in core/tests/Drupal/Tests/TestSuites/TestSuiteBaseTest.php on line 101" but when executing tests in command line, I have no problem.
Thanks for any help.
Comment #5
GrimreaperHello,
I find out a way to add an automated test. I based myself on the AreaMessageTest.
Here are two patches. One adds the test and should fail. The other one adds the tezst and the fix.
Thanks for the review.
Comment #7
GrimreaperAs expected the patch that only adds the test has failed.
Comment #8
dawehnerThe tests are looking great. Here is a quick comment about the comment.
Is there a reason why this comment doesn't match to the code? Note: it would be even better, if the comment would describe why we need to use a different start.
its good to fix that!
Nice!
Comment #9
GrimreaperHello,
Thanks for the review.
About the $start = 0 if the view is empty, I have changed the code a little bit. I don't know if it is more explicit.
I also found that when using a mini pager, if it is not the last page that is displayed, the total count is broken, instead of 54 for example for my manual tests, it displays 4.6116860184274E+18.
I will open another issue for that and try to find from where it is from.
Comment #10
dawehnerWell mini pagers are special :)
Comment #11
alexpottI think we need to add to the
testResultEmpty
test case. We need to test when the view has theempty
option set to FALSE - to check nothing displays.Comment #12
GrimreaperHello,
Thanks for the review. Here is a new patch that also add this test.
Comment #13
dawehner@Grimreaper do you mind posting an interdiff for it?
Comment #14
GrimreaperSorry, I don't have the habit of making interdiff.
Here it is.
Comment #15
GrimreaperRemoving the "Needs tests" tag as there is a patch with the automated test.
Comment #17
GrimreaperHello,
I will be at the Drupal Developer Days 2017 in Seville.
Any chance to meet a core commiter there and get it reviewed and merged (after rerolling the patch)?
Comment #18
dawehner@Grimreaper
The problem is not a missing core committer, its about a missing reviewer
It would be nice to explain why this line is needed. The current documentation is about what is done.
Comment #19
LendudeNeeds a reroll for #2776975: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
some other things:
This can just be an {@inheritdoc}
Copy/paste leftover, needs to be updated to the current use case.
Copy/paste leftover, needs an update.
'Add a filter that will make the result set empty.' Something like that?
Since the page_1 display doesn't have overridden filters, adding this again shouldn't be necessary right? It should already have this filter from adding it to the default display?
Comment #20
GrimreaperHello,
@dawehner and @Lendude, thanks for the review and reply.
I will update my patch next week.
Comment #21
GrimreaperHello,
I have rerolled the patch and applied your comment review.
Sorry, I haven't made the interdiff, the previous patch did not apply anymore. I changed the comment that @davehner pointed at and the points 1, 2, 3, 4 pointed by @Lendude.
@Lendude, about point 5, the default display and the page_1 display have a small difference.
On the default display, the result header is always displayed "empty: true" whereas on the page_1 display is it displayed only if there is a result "empty: false".
Thanks for the review.
Comment #22
GrimreaperThanks @Lendude for the live review.
Here is an update patch that remove the filter override as you suggested and I also remembered to convert array in short array syntax.
Comment #23
HazaI can't reproduce the issue on the 8.4.x branch. Does this have been fixed in any way with 8.4 ?
Comment #24
LendudeGood catch! This looks good now.
Manually tested this in 8.4.x again and still fails to show the summary for me without the patch applied. Don't know what's different for @Haza
Comment #25
HazaOk, got it. I added the wrong "field" type for the header (I added "Global : Text area")
Well, at least it made clear that the issue is very specific to the "issue summary" field.
Manually tested the patch with 8.x and using the correct field (this time), I can confirm it solves the issue.
Comment #26
GrimreaperComment #27
LendudeOverlaps with #2569381: Drupal\views\Plugin\views\area\Result does an unnecessary XSS::adminFilter() , if that lands first we need to combine the tests from that with the tests added here.
Comment #28
iMiksuCan we have some screenshots about this fix for making it easier for core committer to review?
Comment #29
GrimreaperI am making the screenshots.
Comment #30
GrimreaperThe important screenshot is:
Now the result area, that is configured to be displayed even if there is no result, is actually displayed and with the right values for the replacement.
Comment #31
GrimreaperComment #32
mavillalba CreditAttribution: mavillalba at La Drupalera by Emergya commentedComment #33
mavillalba CreditAttribution: mavillalba at La Drupalera by Emergya commentedComment #34
alexpottNice, fix, tests and screenshots everyone. Just one minor point around BC...
Whilst adding
|| !empty($this->options['empty']
is required for the fix. I'm not sure that we should change the return for empty result from['#markup' => '']
to[]
. As far as I can see it's not necessary for the fix and potentially could introduce PHP notices/errors in custom code where people are relying on#markup
being set even when there is nothing to render.Comment #35
GrimreaperHello,
Here is reworked patch to take @alexpott suggestions into account.
Thanks for the review.
Comment #36
Lendude@alexpotts feedback has been addressed, still looks good, tests are still green.
Comment #37
alexpottCommitted 2be2910 and pushed to 8.4.x. Thanks!
As we're in the run up to 8.3.0 setting to patch to be ported for commit to 8.3.1 as I think this is BC safe.
Comment #39
alexpottCommitted b32e30b and pushed to 8.3.x. Thanks!
Comment #41
GrimreaperThanks :)