Problem
#1946434: Convert all of confirm_form() in node.admin.inc and node.pages.inc to the new form interface introduced a direct database query to the {node} table in \Drupal\node\Access\NodeRevisionAccessCheck. This breaks the ability to use a different storage controller for nodes, or in other words, everyone implementing a different storage controller for nodes, needs to swap out this access check. This breaks encapsulation.
Details
The query in question is:
$this->connection->query('SELECT COUNT(*) FROM {node_field_revision} WHERE nid = :nid AND default_langcode = 1', array(':nid' => $node->id()))->fetchField()
Proposed resolution
I (tstoeckler) am not entirely sure. See #13 and #14 of the above mentioned issue. @Crell said it should be on NodeInterface but I think in order for the storage controller to be truely swappable it would need to live on NodeStorageControllerInterface. Node doing direct DB queries breaks encapsulation just as much, in my opinion.
Comment | File | Size | Author |
---|---|---|---|
#6 | issue-2040545-6.patch | 2 KB | marcingy |
#2 | issue-2040545-3.patch | 1.99 KB | marcingy |
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedCan't this be done as an EFQ using FIELD_LOAD_REVISION, that way the query can remain in place but will be database storage agnostic. Actually after some testing this idea won't work.
Comment #2
marcingy CreditAttribution: marcingy commentedHow about....
Comment #3
tim.plunkettWell then you need to inject the DB connection into the storage controller (you can do that).
Comment #4
marcingy CreditAttribution: marcingy commentedI was thinking that as well but
Seems to indicate that direct db queries are acceptable.
Comment #5
tim.plunkettNo, that just hasn't been converted yet.
Comment #6
marcingy CreditAttribution: marcingy commentedThis what you had in mind?
Comment #7
tstoecklerLooks good to me.
Comment #8
Crell CreditAttribution: Crell commentedThe function wrappers are never OK inside a class. We just haven't killed them all yet. :-)
Comment #9
alexpottSo we no longer need to inject the database connection...
Comment #9.0
alexpottFixed messed up <?php syntax
Comment #10
xjm(Merging "node system" and "node.module" components for 8.x; disregard.)
Comment #22
quietone CreditAttribution: quietone at PreviousNext commentedNodeRevisionAccessCheck has been deprecated and removed. #3261251: Remove deprecated node module functions. And grepping didn't turn up that query. There I am closing this as outdated.