diff --git a/channel/ad_channel.module b/channel/ad_channel.module index cc034f431dfb214ef4c8dc5dd8da0ff7d5f24d82..6d724085148ae8ceca1165b52aa1b823f5a86466 100644 --- a/channel/ad_channel.module +++ b/channel/ad_channel.module @@ -449,12 +449,11 @@ function ad_channel_nodeapi($node, $op, $arg = 0) { return _ad_channel_load_node($node); case 'insert': case 'update': - // Fully load the node object to confirm that we are working with an - // advertisement. - $ad = node_load($node->nid); - if (isset($ad->adtype)) { + if (is_object($node) && isset($node->adtype) && + isset($node->probability) && isset($node->nid)) { return _ad_channel_save_node($node); } + break; case 'delete': return _ad_channel_delete_node($node); case 'validate': diff --git a/documentation/CHANGELOG.txt b/documentation/CHANGELOG.txt index 5810aa6e6732fa4e28a13b88e7e27a3b1230009e..aec3c7d082f0f05448a700c65f6f44a13dfb6d10 100644 --- a/documentation/CHANGELOG.txt +++ b/documentation/CHANGELOG.txt @@ -1,5 +1,11 @@ $Id$ +April 22nd, 2009 + - ad_channel.module + o bug #436234: allow nodes to save properly on creation + - ad_weight_percentage.module + o bug #436234: allow nodes to save properly on creation + April 17th, 2009 - ad_cache_file.install o bug #436926: be sure the file cache is disabled when the ad file cache diff --git a/weight/probability/ad_weight_probability.module b/weight/probability/ad_weight_probability.module index 02a8ca94b57a40105f22c87f02d7ae0c1dbdbd23..9a3d763e5576a4d728337dc7667418eb780f7ca9 100644 --- a/weight/probability/ad_weight_probability.module +++ b/weight/probability/ad_weight_probability.module @@ -48,13 +48,12 @@ function ad_weight_probability_nodeapi($node, $op, $arg = 0) { case 'insert': case 'update': if (user_access('configure ad probability')) { - // Fully load the node object to confirm that we are working with an - // advertisement. - $ad = node_load($node->nid); - if (isset($ad->adtype)) { + if (is_object($node) && isset($node->adtype) && + isset($node->probability) && isset($node->nid)) { return _ad_weight_probability_node_save($node, $op); } } + break; case 'delete': return _ad_weight_probability_node_delete($node); } @@ -99,7 +98,7 @@ function _ad_weight_probability_node_load($node) { * Helper function, save the probability to the database. */ function _ad_weight_probability_node_save($node) { - if (is_object($node) && $node->nid) { + if (isset($node->nid) && $node->nid) { db_query('UPDATE {ad_weight_probability} SET probability = %d WHERE aid = %d', $node->probability, $node->nid); if (!db_affected_rows()) { db_query('INSERT INTO {ad_weight_probability} (aid, probability) VALUES(%d, %d)', $node->nid, $node->probability);