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
It would be interesting to know how you can create a new node without a new revision being created.
Proposed resolution
Don't show the checkbox, it doesn't do anything.
Comments
Comment #2
yoroy CreditAttribution: yoroy at Roy Scholten commentedI *suspect* this should be relatively easy to jump into and write a patch for.
So the task is: don't show the "Create new revision" checkbox on the content creation form
Comment #3
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedOn first time checking the node revision checkbox and saving the node, shows a new tab "Revisions". If we again edit the same node and do not check the revision checkbox then this node update entry would not be saved in the node_revision table and hence will not be shown under "Revisions" tab.
Comment #4
lucur CreditAttribution: lucur commentedComment #5
katzillaComment #6
biancajs CreditAttribution: biancajs commentedComment #7
biancajs CreditAttribution: biancajs at Reinblau commentedHide revision checkbox on node add form by checking if node is new.
Comment #8
Gábor Hojtsy@kamalrajsahu21: right, but what about the first revision, how could you skip that? :)
Comment #9
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commented@Gábor Hojtsy: We can't skip that as this will be needed for first time just for backup of node.
Comment #10
Gábor Hojtsy"We can't skip that as this will be needed for first time just for backup of node." Can you explain what would be different step by step for the two cases, I am afraid I am not getting it.
Comment #11
yoroy CreditAttribution: yoroy at Roy Scholten commentedNot showing the UI bits for revisions on *initial* node creation does not mean the node can't be saved. We just don't show a part of the UI that is not relevant at that time.
Comment #12
catchUnnecessary whitespace addition.
For form alters etc. it's more predictable to do
$form['revision']['#access'] = !$node->isNew()
than to conditionally add the declaration.Comment #13
katzillaChanged the code according to #12 - thanks for the hint.
Comment #14
katzillaComment #15
romainj CreditAttribution: romainj as a volunteer commentedShould we hide the Revision log message too? It has no more purpose on node creation.
Comment #16
lucur CreditAttribution: lucur at Reinblau commented@romainj Since there is created a revision automatically on node creation the log message could be still useful.
Comment #17
romainj CreditAttribution: romainj as a volunteer commented@lucur agree even if I never use the message on new node.
Comment #18
katzillaRe-uploading patch because test wasn't triggered.
Comment #19
Gábor HojtsyLooks good. Needs tests AFAIS.
Comment #21
katzillaok, working on a test now.
Comment #22
dietmarg CreditAttribution: dietmarg at Reinblau commentedworking on it with katzilla
Comment #23
dernetzjaeger CreditAttribution: dernetzjaeger as a volunteer commentedComment #24
dernetzjaeger CreditAttribution: dernetzjaeger as a volunteer commentedWorked on that with @katzilla and @dietmarg at DrupalCon Dublin mentored by @chipway. :)
We added the simpletest in
NodeCreationTest.php
to the patch as @gábor-hojtsy suggested.Comment #25
chipway CreditAttribution: chipway at Chipway commentedThank you for the past couple of patches.
Could you provide an interdiff between the patches from #13 to #24? An interdiff helps reviewers look at the changes between patches and makes it easier to check the intended changes from what you worked on.
Comment #26
dernetzjaeger CreditAttribution: dernetzjaeger as a volunteer commentedSure @chipway :)
Comment #27
chipway CreditAttribution: chipway at Chipway commentedThank you @katzilla, @dernetzjaeger and @dietmarg for you work.
I tested node_add_form_shows-2744877-24.patch following https://www.drupal.org/patch/review. Here are my findings and suggestions:
Patch addresses the issue (see screenshots) and stays within scope of the issue, and added simpletest seems accurate.
Could you delete the 6 last lines which are out of scope?
diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml
old mode 100644
new mode 100755
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
old mode 100644
new mode 100755
To make this patch more comprehensive, I would suggest to remove the "Revision log message" field. See Create_Article_Drupal_-_2016-10-04_21.40.27_without-patch-2744877-24_suggestion.png
Comment #28
dernetzjaeger CreditAttribution: dernetzjaeger as a volunteer commentedRemoved the last lines. Don't know why that got into the patch. As I usually set
git config core.fileMode false
.I added patch + interdiff again. :)
Thanks for the suggestion to also remove the log message input in that patch. But in my eyes it shouldn't. As in #15 and #16, I would prefer a further discussion on that in a new issue and set that one as related.
Comment #29
Gábor HojtsyWording issue with the assertion:
is not present :)
Is there a positive test that it is present later on? (I would assume there is a UI test for that, but not sure).
Comment #30
Gábor HojtsyComment #31
chipway CreditAttribution: chipway at Chipway commentedThanks @Gábor Hojtsy for your help,
What is your advice about hiding "Revision log message" field in this issue or discussing this point in a new related issue?
Comment #32
Gábor HojtsyI think a different issue would be good for that. You may still want to provide a log message for your first revision, I think that makes sense in some situations, so better discussed in a separate issue. On the other hand the first revision is a new revision anyway, so the checkbox is truly pointless :)
Comment #33
chipway CreditAttribution: chipway at Chipway commentedThanks @Gábor,
I added issue https://www.drupal.org/node/2811549 to discuss the opportunity to hide "Revision log message" field when we create a new node.
So we can go ahead with the current issue.
Comment #34
dernetzjaeger CreditAttribution: dernetzjaeger as a volunteer commentedThanks @gábor-hojtsy, changed wording.
Comment #35
Gábor HojtsyOk, what about my other note in #29?
Comment #36
katzillaWe checked, but there was no test. Added test in NodeEditFormTest.php now.
Comment #37
chipway CreditAttribution: chipway at Chipway commentedI tested node_add_form_shows-2744877-36.patch following https://www.drupal.org/patch/review.
Patch applies on 8.3.X, addresses the issue (see screenshots still valid) and stays within scope of the issue. Added test in NodeEditFormTest.php seems to address comment #35.
I read the patch and looks clean.
Comment #38
chipway CreditAttribution: chipway at Chipway commentedTo be comprehensive and fussy, PHP CodeSniffer gives few Errors in your patch:
FILE: .../core/modules/node/src/Tests/NodeEditFormTest.php
116 | ERROR | [x] Concat operator must be surrounded by a single space
117 | ERROR | [x] Space found before comma in function call
Would suggest changing them to:
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldById('edit-revision', NULL, 'The revision field is present.');
Comment #39
katzillaadded a new patch - thanks for the hint :)
Comment #40
Gábor HojtsyLooks good to me, has all the tests needed, nice little usability improvement :)
Comment #41
katzillayay - that was quick in the end! Thank you :)
Comment #42
webchickLooks like a nice little usability improvement, thank you!!
Reviewed on weekly UX meeting, and committed and pushed to 8.3.x. Thanks!
Comment #44
Gábor HojtsyYay, congrats all!