18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9<br />

Note that the {node_access} table uses the node id (nid) as its primary key. As a<br />

result, it can only be used to check access for content that has already been created.<br />

This means that node access modules cannot assert permissions for the Create<br />

operation. To do so, your module must implement hook_node_access() and<br />

respond to the 'create' operation.<br />

Rebuilding the access permissions will also trigger node_query_node_access_<br />

alter() to begin rewriting node queries for the View, Update, and Delete actions.<br />

However, modules that only implement hook_node_access() do not write records<br />

to the {node_access} table, nor do they impose query altering logic. As a result,<br />

we might consider hook_node_access() to be an easier (and often more efficient)<br />

approach to solving the problem of node access.<br />

When using a node access module, <strong>Drupal</strong> will add a JOIN statement to<br />

every node query. This can have minor performance implications for your<br />

site if you have large amounts of content.<br />

[ 253 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!