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.
Problem/Motivation
If no content types are available, the list displays the possibly wrong text: There is no Content type yet., while it should be at least No content types available.
Proposed resolution
Looks like there's a correct logic in NodeTypeListBuilder class, but it doesn't get picked up (see the render() function).
public function render() {
$build = parent::render();
$build['#empty'] = t('No content types available. <a href="@link">Add content type</a>.', array(
'@link' => $this->urlGenerator->generateFromPath('admin/structure/types/add'),
));
return $build;
}
Comment | File | Size | Author |
---|---|---|---|
#33 | interdiff-33.txt | 1020 bytes | joshi.rohit100 |
#33 | wrong_text_if_no-2473215-33.patch | 3.99 KB | joshi.rohit100 |
#31 | wrong_text_if_no-2473215-31.patch | 4.41 KB | smccabe |
#28 | 2473215_test.png | 87.65 KB | jmolivas |
#28 | 2473215_admin-structure-types.png | 114.74 KB | jmolivas |
Comments
Comment #1
meramo CreditAttribution: meramo commentedComment #2
drubbIt was just the wrong render element used in the build function. Here's the patch!
Comment #3
drubbComment #4
larowlanThis is a duplicate
Comment #5
drubbDuplicate of which issue? It's similar to https://www.drupal.org/node/2454309, but that deals with content, not content types.
Comment #6
darol100 CreditAttribution: darol100 commented@larowlan, if you believe this is a duplicated please provide the link for the duplicated issue.
@drubb, great work it seem to be working fine.
I have tested this patch and seem to be working fine. I have attached an image of the results of this patch.
Comment #7
alexpottLet's add an assertion to a test for this.
Comment #8
darol100 CreditAttribution: darol100 commented@alexpott,
Its unclear to me what is the next step. If you can provide me a link for what type of testing it needs I might be able to help testing this patch.
Comment #9
m4oliveiHow about something like this for a test? I created a new test class for node module, b/c I didn't want to inherit the setup from NodeTestBase. If I did I would have had to delete the Page and Article types which are defined there. Let me know if I'm off base. Otherwise, this seems like a good enough test.
Comment #10
adriancotter CreditAttribution: adriancotter commentedepophoto and I tested this at DrupalConLA.
Comment #11
image415 CreditAttribution: image415 as a volunteer commentedI tested this at DrupalConLA
Comment #12
willzyx CreditAttribution: willzyx commentedAdd related issue
Comment #13
webchickThis is exactly the kind of thing that we're looking for, except that by making it its own test extending from WebTestBase it's going to incur a Drupal installation/teardown, which is quite expensive. Is it possible to look for an existing test that's already hitting the admin/structure/types page where we could simply add the assertion there?
Comment #14
smccabe CreditAttribution: smccabe at Acro Commerce commentedSlim picking for tests to piggyback off of, nearly all of them create content types as part of setup.
Few not-so-great candidates I found
NodeBodyFieldStorageTest
NodeCacheTagsTest
NodeFieldAccessTest
NodeFieldOverrridesTest
NodeListBuilderTest
None of these really have anything to do with content types though and none of them seem suitable generic.
Comment #15
willzyx CreditAttribution: willzyx commented@all as suggested by @tim.plunkett can we please combine this issue with #2490290: Subclasses of EntityListBuilder incorrectly override the #empty message and fix all of the subclasses of EntityListBuilder at once?
@smccabe could NodeTypeTest or NodeAdminTest be candidate? we simply need to delete the Page and Article node types before test the empty message
Comment #16
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commented@willzyx I agree one of those makes a lot more sense logically, I just wasn't sure about undoing the setup, possibly screwing up additional tests that get added. What would be the best option, to remove the content types, run the test and then re-add them so additional tests still have the correct setup?
Comment #17
sumitmadan CreditAttribution: sumitmadan commentedChanged #9 patch according to @webchick said. I have added the test in NodeTypeTest and also changed NodeTypeListBuilder as per #2490290: Subclasses of EntityListBuilder incorrectly override the #empty message.
Comment #18
sumitmadan CreditAttribution: sumitmadan at QED42 commentedOops!!! Forgot to upload the patch.
Comment #19
joshi.rohit100Should be short array syntax here.
same here (short array syntax)
Comment #21
joshi.rohit100As NodeTypeTest class extends the NodeTestBase, and you can see that in setup, Article and Page content types are created. So in your test case, You should first delete those two bundles.
Also I think that the new test case method name be testNoNodeContentType (just thought).
Comment #22
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedupdated test to remove the content types and then re-add after the tests are done.
Comment #23
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commented@joshi.rohit100 im not sure why you suggest short array syntax for those sections, when I looked at any other tests they don't use short array syntax either. Is this something new that is being changed for D8?
Comment #24
cilefen CreditAttribution: cilefen commented@smccabe
I think the working policy is to use short array syntax if the array in question is in the issue scope.
Comment #25
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedAh I see, try to update if you're doing new stuff but not doing the mass convert of everything. I will update the patch when I get a chance.
https://www.drupal.org/node/2135291
Comment #26
googletorp CreditAttribution: googletorp at Reveal IT commentedComment #27
googletorp CreditAttribution: googletorp at Reveal IT commentedFixed the short array syntax.
Comment #28
jmolivas CreditAttribution: jmolivas at Blink Reaction (now part of FFW) commentedI have tested this patch and seem to be working fine, I have attached an image of the results of this patch:
And the result of running phpunit:
Comment #29
jmolivas CreditAttribution: jmolivas at Blink Reaction (now part of FFW) commentedRemove embedding images and status update
Comment #30
joshi.rohit100I am just curious why we re-added the node module in NodeTypeTest class as it is already added in parent class ?
@smccabe : I just suggested the short array syntax as it is new patch policy.
Comment #31
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedremoved unneeded node module included
Comment #32
alexpottNot needed.
@jmolivas running PHPUnit doesn't run the test added by this patch - unfortunately. It's a web test.
Comment #33
joshi.rohit100Comment #34
googletorp CreditAttribution: googletorp at Reveal IT commentedThanks @joshi.rohit100 RTBC when turns green.
Comment #35
googletorp CreditAttribution: googletorp at Reveal IT commentedComment #36
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 34d3c8c and pushed to 8.0.x. Thanks!