Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300665

Optimize node access query building

$
0
0

Updated: Comment #153

Problem/Motivation

Drupal's current method of determining whether a specified user has access to a node is reported to have significant performance issues on a site using node access with a large number of grants.

Proposed resolution

A patch has been prepared, however it appears to be unclear as to what functionality/performance testing might be required or how it would be undertaken.

Remaining tasks

  • (todo) commit patch #133

------------------------------------------------------------

Not sure if its faster, but I thought it might:

function node_access($op, $node = NULL) { 
  // ...

  // If the module did not override the access rights, use those set in the
  // node_access table.
  if ($op != 'create'&& $node->nid && $node->status) {
    $grants = array();
    foreach (node_access_grants($op) as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants[] = "(gid = $gid AND realm = '$realm')";
      }
    } 

  // ...
}
function node_access($op, $node = NULL) { 
  // ...

  // If the module did not override the access rights, use those set in the
  // node_access table.
  if ($op != 'create'&& $node->nid && $node->status) {
    $grants = array();
    foreach (node_access_grants($op) as $realm => $gids) {
      $grants[] = "((realm = '$realm') AND (gid = ".implode(' OR gid = ', $gids)."))";
    } 

  // ...
}

Difference is that realm is just checked once; not per gid. But it is possible that mysql/postgre server already do this, I don't know.


Viewing all articles
Browse latest Browse all 300665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>