_swish_do_update() throws mysql duplicate entry error

vj0914 - November 4, 2008 - 20:34
Project:Swish-E Indexer
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

in swish.integration.inc line 135,

replace below

<?php
....
      if(
db_result(db_query("SELECT nid FROM {swish_fulltext} WHERE filepath = '%s' AND nid = %d", $file['filepath'], $file['nid']))) {
       
db_query("UPDATE {swish_fulltext} SET `fulltext` = '%s' WHERE `filepath` = '%s'",$text, $file['filepath']);
      } else {
       
db_query("INSERT INTO {swish_fulltext} (filepath,nid,`fulltext`) VALUES ('%s',%d,'%s')",$file['filepath'],$file['nid'],$text);
      }
...
?>

by

<?php
...
      if(
db_result(db_query("SELECT COUNT(nid) FROM {swish_fulltext} WHERE filepath = '%s' AND nid = %d", $file['filepath'], $file['nid']))) {
       
db_query("UPDATE {swish_fulltext} SET `fulltext` = '%s' WHERE `filepath` = '%s'",$text, $file['filepath']);
      } else {
       
db_query("INSERT INTO {swish_fulltext} (filepath,nid,`fulltext`) VALUES ('%s',%d,'%s')",$file['filepath'],$file['nid'],$text);
      }
...
?>

otherwise it doesn't return number of rows.

 
 

Drupal is a registered trademark of Dries Buytaert.