function node_access_entity_test_page
Page callback for node access entity test page.
Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with the number filled in) if there were nodes the user could access. Also, the database query is shown, and a list of the node IDs, for debugging purposes. And if there is a query exception, the page says "Exception" and gives the error.
See also
2 string references to 'node_access_entity_test_page'
- NodeEntityFieldQueryAlter::testNodeQueryAlterWithUI in modules/
node/ node.test - Tests that node access permissions are followed.
- node_access_test_menu in modules/
node/ tests/ node_access_test.module - Implements hook_menu().
File
-
modules/
node/ tests/ node_access_test.module, line 148
Code
function node_access_entity_test_page() {
$output = '';
try {
$query = new EntityFieldQuery();
$result = $query->fieldCondition('body', 'value', 'A', 'STARTS_WITH')
->execute();
if (!empty($result['node'])) {
$output .= '<p>Yes, ' . count($result['node']) . ' nodes</p>';
$output .= '<ul>';
foreach ($result['node'] as $nid => $v) {
$output .= '<li>' . $nid . '</li>';
}
$output .= '</ul>';
}
else {
$output .= '<p>No nodes</p>';
}
} catch (Exception $e) {
$output = '<p>Exception</p>';
$output .= '<p>' . $e->getMessage() . '</p>';
}
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.