I've seen this in a couple of other threads, I think... you have freelinking set up with prepopulate, and are using the nodetitle plugin, so that when your [[bracketed title]] turns into a 'create this node' link when it doesn't already exist.

But after it's created, the link doesn't change into a straight link to that target... it just keeps putting in a 'create' link.

Sorry this isn't conventional patch code, but this is how I fixed it:

in freelinking.nodetitle.inc, in the function freelinking_nodetitle_nid_from_title, I changed this

  $sql = "SELECT title, nid, language FROM {node} WHERE title='%s'";
  if ($type != 'none') {
    $sql .= " AND type='%s'";    
    $result = db_query($sql, $title, $type);
  }
  $result = db_query($sql, $title);

to this:

  $sql = "SELECT title, nid, language FROM {node} WHERE title='%s'";
  if ($type != 'none') {
    $sql .= " AND type='%s'";    
    $result = db_query($sql, $title, $type);
  } else {
    $result = db_query($sql, $title);
  }

In the original, the second db_query is executed no matter what.

Comments

pauldawg’s picture

I have also experienced this, but I noticed the next day that the links that were not working at first were now working, with no other changes. So out of curiosity I did it again, created a link using the [[bracketed title]] method, then clicked to create and save the new content, and went back to verify the term was not linking to the newly created content. Then I ran Cron manually and tried it again and this time it worked. So it seems that whatever condition that makes the code break is not present if cron runs soon. This may have hidden the bug from first appearing if the links weren't tested right away. Anyway, I am not necessarily saying that the fix in this post is not the correct fix, but just providing more information in case it is helpful to other users or to the module maintainer.

pauldawg’s picture

Hmm... the new code in this file is different from what you quoted, so it seems the fix suggested here is not relevant to the latest code. However, there is still a bug here, as mentioned in my previous post.

The new code addresses the logic issue by using the $params array and including the type param if it is there, otherwise querying without it. So it does seem that the original fix was probably off-base. i.e. the nodetitle query would have come back the same whether type was provided, so if it doesn't come back after creating the node, then this I believe is a separate issue.

So question: why isn't the query result returning the newly created node right after the node is corrected, and what can we do to fix that?

$sql = "SELECT title, nid, language FROM {node} WHERE title = :title";
  $params = array(':title' = $title);
  if ($type != 'none') {
    $sql .= " AND type = :type";
    $params[':type'] = $type;
  }
  $result = db_query($sql, $params);  
realEuph’s picture

Thank you cath0de. The fix you posted first appears to completely fix my problem.

gisle’s picture

Version: 6.x-3.2 » 6.x-3.4
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

I am unable to reproduce this with the latest version (6.x-3.4).

Can anyone confirm that this is still a problem with the latest version.

gisle’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I am unable to reproduce this with the latest version.
Feel free to reopen if you still think this is an issue.