The following code in freelinking.module does not query db when $noderestrict== 'none'(which is No restrictions).To solve the problem we need to move the code "$result = db_query($query, $title);" out of the if statement.

function _freelinking_exists($thetitle) { // helper function for freelinking_page
  // looks through the db for nodes matching $title. Returns the nid if such a node exists, otherwise, returns 0
  $title = urldecode($thetitle);
  $query = "SELECT nid FROM {node} WHERE title = '%s'";
  $noderestrict = variable_get('freelinking_restriction', 'none');
  if ($noderestrict != 'none') { // need to add the where clause
    foreach ($noderestrict as $restrictedtype)  {
      $clauseparts[] = 'type = "' . $restrictedtype . '"';
    }
    $restrictions = implode(' OR ', $clauseparts);
    $query .= " AND (" . $restrictions . ')';
    $result = db_query($query, $title);
  }
// FIXME ***
  while ($node = db_fetch_object($result)) { // only one, I hope... what if there's more than one?
    $nid = $node->nid;
  }
  return (empty($nid) ? 0 : $nid);
}

Comments

eafarris’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.