After upgrading a site from Drupal 6 to 7 I'm getting the following error messages when I attempt to visit the site:
Warning: Attempt to assign property of non-object in templates_load() (line 428 of /path to module/templates.module).
Notice: Trying to get property of non-object in templates_load()(line 429 of /path to module/templates.module).
Recoverable fatal error: Argument 2 passed to db_query() must be an array, null given, called in /path to module/templates.module on line 429 and defined in db_query() (line 2342 of /path to includes/includes/database/database.inc).
The templates module was custom written (not by me, I'm not a programmer) for the site.
Below are the offending lines of code.
From templates.module:
function templates_load($node) {
$node->module = 'templates'; // line 428
$query = db_query('SELECT * FROM {templates_fields} WHERE nid=%d ORDER BY fid', $node->nid); // line 429
$node->areas = array();
while($row = db_fetch_array($query)) {
$area = $row['area'];
$node->areas[$area][] = $row;
}
return $node;
}
From database.inc:
function db_query($query, array $args = array(), array $options = array()) { //line 2342
if (empty($options['target'])) {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->query($query, $args, $options);
}