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.
node_revision delete was not returning any value. The documentation says that it should return bool
/**
* Deletes a node revision.
*
* @param $revision_id
* The revision ID to delete.
*
* @return bool
* TRUE if the revision deletion was successful; otherwise, FALSE.
*/
function node_revision_delete($revision_id) {
entity_revision_delete('node', $revision_id);
}
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff-2737743-6-11.txt | 421 bytes | anoopjohn |
#11 | drupal-node_revision_delete-does-not-return-bool-2737743-11.patch | 650 bytes | anoopjohn |
#6 | drupal-node_revision_delete-does-not-return-bool-2737743-6.patch | 646 bytes | anoopjohn |
Comments
Comment #2
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedHere is a patch that returns the return from entity_revision_delete . However I see that entity_revision_delete also does not return anything. Not sure what is the right fix for this.
entity_revision_delete calls
Comment #3
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedComment #4
Mile23node_revision_delete()
just wrapsentity_revision_delete()
.entity_revision_delete()
isn't documented as returning anything, and doesn't.Also
entity_revision_delete()
is deprecated, sonode_revision_delete()
should call\Drupal::entityManager()->getStorage('node')->deleteRevision($revision_id);
and return whatever it returns.Since
$storage->deleteRevision()
returns void, let's remove the@returns
from the docblock.I just filed this issue, as well: #2741249: Remove entity_revision* family of functions usage from the code base
Comment #5
Mile23Comment #6
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedThanks for the review Mile23. I have made changes as suggested. Please find attached the patch and the interdiff.
Comment #7
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedComment #9
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedUploaded the interdiff file with the correct extension.
Comment #10
Mile23Sorry, the entity manager service is also deprecated. We want the entity type manager here.
Comment #11
anoopjohn CreditAttribution: anoopjohn at Zyxware Technologies commentedThanks again for the review Mile23. Rerolled with the suggested changes
Comment #12
Mile23Nice, thanks.
Comment #13
Mile23Blocking #2722647: [Meta] Fix Drupal.Commenting.FunctionComment.InvalidNoReturn
Comment #14
alexpottNice find and the fix looks correct - the @return is not right.
Committed 998bdf2 and pushed to 8.1.x and 8.2.x. Thanks!