diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/node.api.php | 14 | ||||
-rw-r--r-- | modules/node/node.module | 4 | ||||
-rw-r--r-- | modules/node/node.test | 8 |
3 files changed, 16 insertions, 10 deletions
diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 5a1403a11..872fc6385 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -762,8 +762,12 @@ function hook_form($node, $form_state) { * For a detailed usage example, see node_example.module. */ function hook_insert($node) { - db_query("INSERT INTO {mytable} (nid, extra) - VALUES (%d, '%s')", $node->nid, $node->extra); + db_insert('mytable') + ->fields(array( + 'nid' => $node->nid, + 'extra' => $node->extra, + )) + ->execute(); } /** @@ -804,8 +808,10 @@ function hook_load($nodes) { * For a detailed usage example, see node_example.module. */ function hook_update($node) { - db_query("UPDATE {mytable} SET extra = '%s' WHERE nid = %d", - $node->extra, $node->nid); + db_update('mytable') + ->fields(array('extra' => $node->extra)) + ->condition('nid', $node->nid) + ->execute(); } /** diff --git a/modules/node/node.module b/modules/node/node.module index a81815682..5e13be9e0 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2699,7 +2699,7 @@ function _node_access_rebuild_batch_operation(&$context) { // Process the next 20 nodes. $limit = 20; - $nids = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit)->fetchCol(); + $nids = db_query_range("SELECT nid FROM {node} WHERE nid > :nid ORDER BY nid ASC", array(':nid' => $context['sandbox']['current_node']), 0, $limit)->fetchCol(); $nodes = node_load_multiple($nids, array(), TRUE); foreach ($nodes as $node) { // To preserve database integrity, only acquire grants if the node @@ -3148,7 +3148,7 @@ function node_requirements($phase) { // Only show rebuild button if there are either 0, or 2 or more, rows // in the {node_access} table, or if there are modules that // implement hook_node_grants(). - $grant_count = db_result(db_query('SELECT COUNT(*) FROM {node_access}')); + $grant_count = db_query('SELECT COUNT(*) FROM {node_access}')->fetchField(); if ($grant_count != 1 || count(module_implements('node_grants')) > 0) { $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count)); } else { diff --git a/modules/node/node.test b/modules/node/node.test index a742083a4..315d7c1b9 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -681,7 +681,7 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase { $this->assertTrue(node_load($node1->nid), t('Article node created.')); // Check to see if grants added by node_test_node_access_records made it in. - $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node1->nid)->fetchAll(); + $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node1->nid))->fetchAll(); $this->assertEqual(count($records), 1, t('Returned the correct number of rows.')); $this->assertEqual($records[0]->realm, 'test_article_realm', t('Grant with article_realm acquired for node without alteration.')); $this->assertEqual($records[0]->gid, 1, t('Grant with gid = 1 acquired for node without alteration.')); @@ -691,7 +691,7 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase { $this->assertTrue(node_load($node1->nid), t('Unpromoted page node created.')); // Check to see if grants added by node_test_node_access_records made it in. - $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node2->nid)->fetchAll(); + $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node2->nid))->fetchAll(); $this->assertEqual(count($records), 1, t('Returned the correct number of rows.')); $this->assertEqual($records[0]->realm, 'test_page_realm', t('Grant with page_realm acquired for node without alteration.')); $this->assertEqual($records[0]->gid, 1, t('Grant with gid = 1 acquired for node without alteration.')); @@ -712,7 +712,7 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase { // Check to see if grant added by node_test_node_access_records was altered // by node_test_node_access_records_alter. - $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node4->nid)->fetchAll(); + $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node4->nid))->fetchAll(); $this->assertEqual(count($records), 1, t('Returned the correct number of rows.')); $this->assertEqual($records[0]->realm, 'test_alter_realm', t('Altered grant with alter_realm acquired for node.')); $this->assertEqual($records[0]->gid, 2, t('Altered grant with gid = 2 acquired for node.')); @@ -759,7 +759,7 @@ class NodeSaveTestCase extends DrupalWebTestCase { */ function testImport() { // Node ID must be a number that is not in the database. - $max_nid = db_result(db_query('SELECT MAX(nid) FROM {node}')); + $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); $test_nid = $max_nid + mt_rand(1000, 1000000); $title = $this->randomName(8); $node = array( |