Part of #2068325: [META] Convert entity SQL queries to the Entity Query API. See the parent issue for details.

Comments in #59.

CommentFileSizeAuthor
#76 interdiff-2068333-73-76.txt1.28 KBroderik
#76 node-entity-queries-2068333-76.patch23.25 KBroderik
#73 node-entity-queries-2068333-73.patch23.36 KBplach
#73 node-entity-queries-2068333-73.interdiff.txt605 bytesplach
#72 node-entity-queries-2068333-72.patch23.36 KBroderik
#72 interdiff-2068333-68-72.txt1.2 KBroderik
#70 interdiff-2068333-66-68.txt2.28 KBroderik
#70 node-entity-queries-2068333-68.patch23.35 KBroderik
#68 interdiff-2068333-66-68.patch2.28 KBroderik
#68 node-entity-queries-2068333-68.patch23.35 KBroderik
#66 interdiff-2068333-62-66.txt4.22 KBroderik
#66 node-entity-queries-2068333-66.patch23.42 KBroderik
#62 interdiff-2068333-56-62.txt4.38 KBroderik
#62 node-entity-queries-2068333-62.patch23.4 KBroderik
#59 interdiff.txt3.99 KBroderik
#59 2068333-59.patch23.18 KBroderik
#4 2068333-node-sql-to-entity-query-4.patch2.38 KBDésiré
#9 node-entity-move.patch14.25 KBmarcingy
#10 node-entity-move-10.patch9.93 KBpeximo
#20 node_entity-nove-2068333-20.patch14.73 KBskipyT
#23 interdiff.txt2.48 KBskipyT
#23 node-entity-queries-2068333-23.patch14.6 KBskipyT
#28 interdiff-2068333-23-28.txt6.44 KBskipyT
#28 node-entity-queries-2068333-28.patch16.47 KBskipyT
#32 node-entity-queries-2068333-32.patch16.4 KBpcambra
#34 node-entity-queries-2068333-34.patch16.51 KBpcambra
#34 interdiff.txt987 bytespcambra
#38 node-entity-queries-2068333-38.patch16.08 KBpcambra
#38 interdiff.txt3.35 KBpcambra
#41 interdiff.txt3.22 KBroderik
#41 node-entity-queries-2068333-41.patch16.15 KBroderik
#45 node-entity-queries-2068333-45.patch17.13 KBroderik
#45 interdiff.txt10.04 KBroderik
#47 node-entity-queries-2068333-49.patch16.93 KBroderik
#47 interdiff_2068333_41-49.txt12.58 KBroderik
#50 node-entity-queries-2068333-50.patch16.97 KBroderik
#50 interdiff_2068333_41-50.txt12.67 KBroderik
#52 node-entity-queries-2068333-52.patch23.12 KBroderik
#52 interdiff.txt12.23 KBroderik
#55 node-entity-queries-2068333-55.patch23.17 KBplach
#56 node-entity-queries-2068333-56.patch23.17 KBplach
#56 node-entity-queries-2068333-56.interdiff.txt619 bytesplach
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Désiré’s picture

Status: Active » Needs review

I don't see any sql queries in the menu_link module (except the \Drupal\menu_link\MenuLinkStorageController of course).

So I think this issue should be closed.

Désiré’s picture

Assigned: Unassigned » Désiré
Status: Needs review » Needs work

Sorry, previous comment landed on the wrong issue...

plach’s picture

Status: Needs work » Active
Désiré’s picture

Status: Active » Needs review
FileSize
2.38 KB

Here is a partial solution, changes only in the node.module file. It also contains some todos where are queries to change in this issue.

I'm also created a new function (node_mass_update_user_nodes()) to eliminate some code duplication.

Désiré’s picture

Status: Needs review » Needs work
plach’s picture

Are you still working on this? Otherwise tomorrow we should be able to bring it forward at the Prague extended sprint.

Désiré’s picture

Assigned: Désiré » Unassigned
plach’s picture

marcingy’s picture

Status: Needs work » Needs review
FileSize
14.25 KB

New patch its doesn't touch tracker or statistics yet but I am also thinking they likely don't need to be ported initially as after all if I was using mongo for storage I most definently would not be using either of those modules!

peximo’s picture

FileSize
9.93 KB
  1. +++ b/core/modules/node/lib/Drupal/node/NodeStorageControllerInterface.php
    @@ -0,0 +1,53 @@
    +  public function adminNodeList(Array $header);
    
    +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -82,4 +82,60 @@ protected function postDelete($nodes) {
    +  public function adminNodeList(array $header) {
    
    +++ b/core/modules/node/node.admin.inc
    @@ -198,33 +198,7 @@ function node_admin_nodes() {
    +  $nids = \Drupal::entityManager()->getStorageController('node')->adminNodeList($header);
    

    This function is no longer necessary since substituted with default entity list.

  2. +++ b/core/modules/node/lib/Drupal/node/NodeStorageControllerInterface.php
    @@ -0,0 +1,53 @@
    +  public function userRevisons(EntityInterface $account);
    
    +++ b/core/modules/node/node.module
    @@ -829,20 +817,35 @@ function node_user_cancel($edit, $account, $method) {
    +  $revisions = \Drupal::entityManager()->getStorageController('node')->userRevisons($account);
    
    +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -82,4 +82,60 @@ protected function postDelete($nodes) {
    +  public function userRevisons(EntityInterface $account) {
    

    Renamed the function as userRevisions.

Status: Needs review » Needs work

The last submitted patch, 10: node-entity-move-10.patch, failed testing.

peximo’s picture

Status: Needs work » Needs review

10: node-entity-move-10.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 10: node-entity-move-10.patch, failed testing.

xjm’s picture

Component: node.module » node system

(Merging "node system" and "node.module" components for 8.x; disregard.)

skipyT’s picture

hi,

I can take this issue and try to create a new patch file. I rerolled the patch file from #10, also replaced the db_selects with entity queries in the test files. But some of them can't be made with entity queries. what do you recommend? shall I let them there, I don't think that one is the good solution.

skipyT’s picture

Assigned: Unassigned » skipyT
Berdir’s picture

I don't think we need to worry about tests?

marcingy’s picture

Correct as far as I know no need to touch tests, none of the other related issues do.

skipyT’s picture

ok, then I check again my patch file and push it here.

skipyT’s picture

Status: Needs work » Needs review
FileSize
14.73 KB

I used the patch file from #10 to continue to work on this.
I added a node storage controller, I replaced the SQL queries to entity queries where I was able to and if it wasn't possible I added methods in the storage controller to keep those features.

chx’s picture

In lastChanged() you are missing an execute and fetchField() would be better also you can do

$query =$this->database->select('node_field_data')->condition('nid', $nid); // format this nicely
if (isset($langcode)) { // add the right langcode condition
return $query->execute->fetchField();
chx’s picture

Status: Needs review » Needs work

Also, please be mindful of \ No newline at end of file these git warnings and add a newline to the end of the new files. Thanks!

And thanks for working on this, really nice to see this moving forward.

skipyT’s picture

Fixed the issues found by chx and also some found by me (renamed some variables, modified documentation).

skipyT’s picture

Status: Needs work » Needs review

The last submitted patch, 20: node_entity-nove-2068333-20.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 23: node-entity-queries-2068333-23.patch, failed testing.

The last submitted patch, 23: node-entity-queries-2068333-23.patch, failed testing.

skipyT’s picture

Status: Needs work » Needs review
FileSize
6.44 KB
16.47 KB

fixed some issues, found another query to be converted, fixed that also.

Status: Needs review » Needs work

The last submitted patch, 28: node-entity-queries-2068333-28.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 28: node-entity-queries-2068333-28.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
FileSize
16.4 KB

Here's a reroll changing some signatures of the account interfaces and node interfaces used, let's see what else is missing from here.

Status: Needs review » Needs work

The last submitted patch, 32: node-entity-queries-2068333-32.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
FileSize
16.51 KB
987 bytes

There were a couple of missing includes.

skipyT’s picture

this seems ok, but personally I don't like the solution to call a procedural function from a storage controller. can't we find a solution to avoid this kind of code or do you think this kind of dependencies are ok?

pcambra’s picture

+++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
@@ -0,0 +1,122 @@
+    module_load_include('inc', 'node', 'node.admin');
+    $nids = $this->userNodes($account);
+    node_mass_update($nids, array('status' => 0), NULL, TRUE);

Just to clarify that we're discussing about this piece of the code.

I don't like it either but I guess it should be handled in a followup, maybe making it a method of the storage controller from nodes and removing it from node.admin.inc?

Maybe related: #89181: Use queue API for node and comment, user, node multiple deletes

chx’s picture

I do not see why do you need to move all the procedural code into the storage controller...? ->userNodes is already public so can't we just do:

$storage_controller = \Drupal::entityManager()->getStorageController('node');
module_load_include('inc', 'node', 'node.admin');
node_mass_update($storage_controller->userNodes($account), array('status' => 0), NULL, TRUE);

and

$storage_controller = \Drupal::entityManager()->getStorageController('node');
module_load_include('inc', 'node', 'node.admin');
node_mass_update($storage_controller->userNodes($account), array('uid' => 0), NULL, TRUE);
$storage_controller->anonymizeUserRevisions($account);

and then anonymizeUserRevisions would just be the update() in anonymizeUserNodes in the current patch. Already node_user_predelete() does something similar.

pcambra’s picture

FileSize
16.08 KB
3.35 KB

Agreed with @chx, here's a version implementing the changes proposed in #37

pcambra’s picture

skipyT’s picture

seems ok for me

roderik’s picture

FileSize
3.22 KB
16.15 KB

Trying to review issues @ DevDays, and learn. Relatively new to D8 core contribution, so please bear with some wordiness and feel free to tell me, if doing/saying too much/little.

done:
- reviewed the code
- reviewed the node module for outstanding stuff, obviously didn't find anything
- the scope of this issue does not require checking against 'core gates' or anything else I can think of. (I did find something that left me wondering, but I'll ask in the related meta issue.)

I wouldn't RTBC even if I did only space changes, so it's still Needs Review. But I think anyone who's seen the previous version can quickly set RTBC. It was already reviewed before me, anyway.

...but I did minor changes:

- space/indent changes

- changed 'join' to 'innerJoin' in revisionsList, for clarity. (Another innerJoin is already in there too.)

- inserted extra comment in node_user_cancel(); if node_mass_update() confuses me, it may confuse someone else too...

plach’s picture

Assigned: skipyT » Unassigned

Thanks for working on this! I was finally able to review the patch:

  1. +++ b/core/includes/menu.inc
    @@ -801,15 +801,14 @@ function menu_tree_collect_node_links(&$tree, &$node_links) {
    +    $nids = \Drupal::entityQuery('node')
    +      ->condition('status', 1)
    +      ->condition('nid', $nids, 'IN')
    +      ->addTag('node_access')
    +      ->execute();
         // @todo This should be actually filtering on the desired node status field
         //   language and just fall back to the default language.
    -    $select->condition('n.status', 1);
    

    This change should be ok, as here we are selecting all nodes the user has access to for at least one translation, but a single node_access() call should be able to determine per-language access when generating the actual menu link. We need to remove the following @todo, though.

  2. +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -0,0 +1,109 @@
    +  public function lastChanged($nid, $langcode) {
    

    Can we make the $langcode parameter optional since we are supporting it being NULL?

  3. +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -0,0 +1,109 @@
    +    $result = $this->database->select('node_field_data', 'n')
    +      ->fields('n', array('changed'))
    +      ->condition('nid', $nid);
    +    if (isset($langcode)) {
    +      $result->condition('langcode', $langcode);
    +    }
    +    else {
    +      $result->condition('default_langcode', 1);
    +    }
    +
    +    $result = $result->execute()->fetchField();
    +    return !empty($result) ? $result : FALSE;
    ...
    +  public function userNodes(AccountInterface $account) {
    +    return $this->database->select('node_field_data', 'n')
    +      ->fields('n', array('nid'))
    +      ->condition('uid', $account->id())
    +      ->execute()
    +      ->fetchCol();
    +  }
    +
    

    Why can't we implement these through entity query?

  4. +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -0,0 +1,109 @@
    +  public function anonymizeUserRevisions(AccountInterface $account) {
    +    $this->database->update('node_field_revision')
    +      ->fields(array('uid' => 0))
    +      ->condition('uid', $account->id())
    +      ->execute();
    +  }
    +
    
    +++ b/core/modules/node/lib/Drupal/node/NodeStorageControllerInterface.php
    @@ -0,0 +1,91 @@
    +  /**
    +   * Anonymize the node revisions of the given account.
    +   *
    +   * @param \Drupal\Core\Session\AccountInterface $account
    +   *   The user entity.
    +   */
    +  public function anonymizeUserRevisions(AccountInterface $account);
    +
    
    +++ b/core/modules/node/node.module
    @@ -812,30 +809,18 @@ function node_user_cancel($edit, $account, $method) {
    +      $storage_controller->anonymizeUserRevisions($account);
    

    Spoke with @catch about this: we shouldn't really be doing such partial updates anymore as they bypass the Entity API. He suggests to just do a proper node (revision) save within the batch update.

    The updateType() above is a valid exception because we cannot save a node with an invalid type.

  5. +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
    @@ -0,0 +1,109 @@
    +      ->fields(array('langcode' => ''))
    

    This should be Language::LANGCODE_NOT_SPECIFIED.

  6. +++ b/core/modules/node/lib/Drupal/node/NodeStorageControllerInterface.php
    @@ -0,0 +1,91 @@
    + * Contains \Drupal\node\nodeStorageControllerInterface.
    

    missing capital N

  7. +++ b/core/modules/node/node.module
    @@ -1014,31 +987,31 @@ function node_revision_list(NodeInterface $node) {
    +   }
    

    Bad indentation.

plach’s picture

Status: Needs review » Needs work
roderik’s picture

Assigned: Unassigned » roderik

Thanks for the review! I don't spot these things but can probably implement. Will do this before working further on #2068331, and take the above into account there.

roderik’s picture

Status: Needs work » Needs review
FileSize
17.13 KB
10.04 KB

Interdiff is between the rebased patch #41 and the new one; I assume that's what people do. The difference between #41 and #41-rebased is that the menu.inc patch has fallen away: #2199381: Add \Drupal\Core\Path\PathInterface moved menu_tree_check_access() to Drupal\menu_link\MenuTree::checkAccess() and rewrote it to not use a database query anymore.

---

re. #42:

point 1: obsoleted by the above - lucky me ;)

point 2-6 implemented; 7 not seen. Plus added some random comments in the new interface.

re. point 4:

  • Added an extra argument to node_mass_update(). Not ideal, but I guess there isn't an ideal way. Comments welcome.
  • Manual testing shows that in the 'user_cancel_reassign' case (where node_mass_update() now gets a list of node revisions to update to 0)... node_field_revision.uid gets set to 0 but node_revision.revision_uid keeps the id of the now-deleted user. This also happens before applying the patch; I can't see if it's an issue that should be filed, someone is working on deleting node_revision.revision_uid, or whatever else. So, assuming I shouldn't create an issue for that.

Status: Needs review » Needs work

The last submitted patch, 45: node-entity-queries-2068333-45.patch, failed testing.

roderik’s picture

FileSize
16.93 KB
12.58 KB

Tests didn't fail on my local machine, so I hope the failures go away now :/

In the meantime: rerolled after #2188613: Rename EntityStorageController to EntityStorage got committed. The comments from #45 still apply; there's just an extra renamed interface/class/file/method in the interdiff.

roderik’s picture

Status: Needs work » Needs review

*cough*

Status: Needs review » Needs work

The last submitted patch, 47: node-entity-queries-2068333-49.patch, failed testing.

roderik’s picture

Status: Needs work » Needs review
FileSize
16.97 KB
12.67 KB

(LOL. Maybe a 'use' statement helps before using Language::LANGCODE_NOT_SPECIFIED. Live and learn. Now just uploading and seeing what the testbot says.)

Again: comments from #45 still apply.

plach’s picture

Status: Needs review » Needs work

Thanks for the update! There are still some issues though:

  1. +++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
    @@ -0,0 +1,81 @@
    +  public function anonymizeUserRevisions(AccountInterface $account) {
    +    $this->database->update('node_field_revision')
    +      ->fields(array('uid' => 0))
    +      ->condition('uid', $account->id())
    +      ->execute();
    +  }
    +
    
    +++ b/core/modules/node/lib/Drupal/node/NodeStorageInterface.php
    @@ -0,0 +1,77 @@
    +  public function anonymizeUserRevisions(AccountInterface $account);
    

    It seems we can remove this now.

  2. +++ b/core/modules/node/lib/Drupal/node/NodeStorageInterface.php
    @@ -0,0 +1,77 @@
    +   * Returns a list of data for all revisions of a specific node.
    +   *
    +   * @param \Drupal\node\NodeInterface
    +   *   The node entity.
    +   *
    +   * @return mixed
    +   *   An associative array of objects containing specific properties (empty
    +   *   array if no result set), keyed by revision id. The keys of object
    +   *   properties are:
    +   *   - vid
    +   *   - current_vid (vid of the _current_ node, not this revision)
    +   *   - title
    +   *   - revision_timestamp
    +   *   - log
    +   *   - uid
    +   *   - name (user name linked to uid)
    +   */
    +  public function revisionsList(NodeInterface $node);
    +}
    

    In D8 we don't support partial entity objects. This method should return a list of revision ids that can then be used to retrieve the related revision entity objects.

roderik’s picture

FileSize
23.12 KB
12.23 KB

#1: d'oh! / #2: done.

revisionsList() has been replaced by revisionIds(). Points of note:

  • Naming? (I didn't find any other existing functions that retrieve revisions, which seems a bit strange to me...)
  • I nailed down the order in which revision IDs are returned, in the interface. Am I allowed to do that?
  • node_revision_list() has pretty specific return arguments and actually only one caller (node_revision_overview()) uses those. So, as discussed, node_revision_list() has been removed; node_revision_overview() was changed to accomodate this, and other callers are now changed to use the revisionIds() method.

Those calls are inside simpletests.
My local environments is failing tests in mysterious (possibly unrelated) ways now :/ so I'll just see if the test bot is nice to me.

roderik’s picture

Status: Needs work » Needs review

.

roderik’s picture

Issue tags: +Needs change record

Oh; draft change record at [#2228895].

plach’s picture

Assigned: roderik » catch
Status: Needs review » Reviewed & tested by the community
FileSize
23.17 KB

I am terribly sorry, I completely lost track of this. This looks fine to me now!

Here's a reroll as the patch no longer applied. Assigning to @catch since I discussed this with him.

plach’s picture

FileSize
619 bytes
23.17 KB
+++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
@@ -0,0 +1,64 @@
+ * This extends the nast storage class, adding required special handling for

lol

catch’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
    @@ -0,0 +1,64 @@
    +    return $this->database->select('node_revision', 'r')
    

    This and others don't really need to use ->select, could just be static queries no?

  2. +++ b/core/modules/node/node.module
    @@ -926,32 +908,24 @@ function node_page_title(NodeInterface $node) {
    +    ->addTag('node_access')
    

    I don't understand this change. tbh I don't understand the entire function.

    This passes in an nid, so we could just load the node. But where this gets called, we already have the node.

    Also it is loading the nodes but not checking the translated value of 'changed'.

    NodeFormController::validate is one of only two places this is used:

    node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime()))

    That results in $node->getChangedTime() > $node->getChangedTime() after all that work it looks like.

    Should just be a check on the original entity or something? We could likely remove node_last_changed() altogether.

+++ b/core/modules/node/node.pages.inc
@@ -134,45 +132,49 @@ function node_revision_overview($node) {
+    if ($revision = node_revision_load($vid)) {

Looks like a performance regression, but unavoidable really.

Berdir’s picture

Yes, the last changed function looks wrong, that very explicitly looks for it with a raw query.

We have an EntityChanged constraint now, which uses loadUnchanged() instead.

roderik’s picture

FileSize
23.18 KB
3.99 KB

#1
sure; will remember the convention.
(For consistency, I also made it explicit that userRevisions() returns a sorted list; comments still welcome.

#2
Thanks for your comments! Should have seen that this rewrite wasn't making sense / checked the actual function usage.

If I pieced all the info together correctly,

So shall I just place a @todo to delete this function later (while ignoring the fact that we ignore the $langcode argument, for now)?

roderik’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 59: 2068333-59.patch, failed testing.

roderik’s picture

Still a noob, I know. (I guess this is the correct way to do update db_queries...)

roderik’s picture

Status: Needs work » Needs review

.

roderik’s picture

Assigned: catch » roderik
Status: Needs review » Needs work
alexpott		roderik: revisionIds vs userRevisions - both return a list of vids
alexpott		roderik: deleteRevisionsLanguage is not deleting anything
alexpott’s picture

Assigned: roderik » catch
  1. +++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
    @@ -0,0 +1,64 @@
    +  public function revisionIds(NodeInterface $node) {
    +    return $this->database->query(
    +      'SELECT vid FROM {node_revision} WHERE nid=:nid ORDER BY vid',
    +      array(':nid' => $node->id())
    +    )->fetchCol();
    +  }
    ...
    +  public function userRevisions(AccountInterface $account) {
    +    return $this->database->query(
    +      'SELECT vid FROM {node_field_revision} WHERE uid = :uid ORDER BY vid',
    +      array(':uid' => $account->id())
    +    )->fetchCol();
    +  }
    ...
    +  public function deleteRevisionsLanguage($language) {
    

    The names of these functions are inconsistent - both return a list of revision IDs

  2. +++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
    @@ -0,0 +1,64 @@
    +  public function updateType($old_id, $new_id) {
    +    return $this->database->query(
    +      'UPDATE {node} SET type=:new WHERE type=:old',
    +      array(':new' => $new_id, ':old' => $old_id),
    +      array('return' => Database::RETURN_AFFECTED)
    +    );
    +  }
    

    how about old_type, new_type instead of _id

  3. +++ b/core/modules/node/lib/Drupal/node/NodeStorage.php
    @@ -0,0 +1,64 @@
    +  public function deleteRevisionsLanguage($language) {
    +    return $this->database->query(
    +      'UPDATE {node_revision} SET langcode=:ns WHERE langcode=:lc',
    +      array(':ns' => Language::LANGCODE_NOT_SPECIFIED, ':lc' => $language->id),
    +      array('return' => Database::RETURN_AFFECTED)
    +    );
    +  }
    

    This function does not delete anything

roderik’s picture

Status: Needs work » Needs review
FileSize
23.42 KB
4.22 KB

Thanks. Changed . (Between resetRevisionsLanguage, unsetRevisionsLanguage and clearRevisionsLanguage, I chose the latter.)

Not changing assignee...idk...

plach’s picture

Aside from the things below it seems this is addressing the reviews above.

+++ b/core/modules/node/lib/Drupal/node/NodeStorageInterface.php
@@ -0,0 +1,60 @@
+   * Returns a list of data for all revisions of a specific node.
...
+   * Retrieve a list of revisions for a given user.

Also the descriptions are a bit inconsistent, they both should mention they are returning identifiers :)

+++ b/core/modules/node/node.module
@@ -881,6 +881,8 @@ function node_page_title(NodeInterface $node) {
+ * @todo delete this function & its calls after #2002180 lands; it's only used
+ *       for validation, which will be done by EntityChangedConstraintValidator.

This is in the wrong place, see https://drupal.org/node/1354#order. It should alse have a blank line above.

roderik’s picture

FileSize
23.35 KB
2.28 KB

Ehm, yeah :)
Fixed, plus some more comment details.

Also reassessed the removal of node_revisions_list() (as a result of thinking about #2068331) and still concluding it should go. Draft change notice still at https://drupal.org/node/2228895.

Status: Needs review » Needs work

The last submitted patch, 68: interdiff-2068333-66-68.patch, failed testing.

roderik’s picture

Status: Needs work » Needs review
FileSize
23.35 KB
2.28 KB

Oh, meh.

plach’s picture

  1. +++ b/core/modules/node/lib/Drupal/node/NodeStorageInterface.php
    @@ -27,12 +27,12 @@
    +   * Returns a list of node revision IDs for a given user.
    

    The comment is still a bit unclear, sorry: this is returning a set of revisions for nodes authored by the user.

  2. +++ b/core/modules/node/node.module
    @@ -892,6 +890,9 @@ function node_page_title(NodeInterface $node) {
    + * @todo Remove once https://drupal.org/node/XXXX is resolved. It's only used
    

    I don't think we can commit this :)

roderik’s picture

FileSize
1.2 KB
23.36 KB

But... why not? It's the recommended notation! :p

*slaps self* Thanks. Also for the Interface comment - better to get the details right.

plach’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs change record
FileSize
605 bytes
23.36 KB

Thanks but...

+++ b/core/modules/node/lib/Drupal/node/NodeStorageInterface.php
@@ -27,7 +27,7 @@
+   * Returns a list of node revision IDs authored by a given user.

this does not make clear yet we are talking about $node->uid and not $node->revision_uid. I hope the attached patch makes it more understandable.
(sorry for being picky :)

No complaints left, let's see whether @catch is happy this time :)

marcingy’s picture

+  public function updateType($old_type, $new_type) {
+    return $this->database->query(
+      'UPDATE {node} SET type=:new WHERE type=:old',
+      array(':new' => $new_type, ':old' => $old_type),
+      array('return' => Database::RETURN_AFFECTED)
+    );
+  }

+public function clearRevisionsLanguage($language) {
+    return $this->database->query(
+      'UPDATE {node_revision} SET langcode=:ns WHERE langcode=:lc',
+      array(':ns' => Language::LANGCODE_NOT_SPECIFIED, ':lc' => $language->id),
+      array('return' => Database::RETURN_AFFECTED)
+    );

Any reason why these aren't a database->update() query. I understand all the selects being static queries but I thought updates should always use ->update to deal with the differences between db drivers.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Yes only static select queries should use $connection->query(), rest have to stay dynamic.

roderik’s picture

Status: Needs work » Needs review
FileSize
23.25 KB
1.28 KB

Ah.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit e67b313 on 8.x by catch:
    Issue #2068333 by roderik, skipyT, pcambra, plach, Désiré, marcingy,...
plach’s picture

Yay!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.