table name called without prefix

sybesis - September 6, 2008 - 19:53
Project:Comment Subscribe
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:zyxware
Status:closed
Description

change

function comment_subscribe_enable() {
//If comment_subscribe module is enabled in a live site.
  //For previous comments an entry in z_commentsubscribe is
  //generated using the below code.
$level = 1;
  $ifcondition = "if(c".$level.".pid <> 0, concat(c".$level.".pid, ','),'')";
  $table = "c".$level;
$join =null;
  //First find the level of comments
do {

   if($level != 1) {
     $prvlevel = $level - 1;
$join .= " join comments c".$level." on c".$prvlevel.".pid=c".$level.".cid";
   }
$sql = "select c1.cid, concat('0,', ".$ifcondition." ) as parents from comments c1  ".$join;
$result = db_fetch_array(db_query($sql));
   if($result != NULL ) {
$origsql = $sql;
     $origjoin = $join;
$origifcond = $ifcondition;
   }
$level++;
   $table = "c".$level;
   $ifcondition = " if(c".$level.".pid <> 0, concat(c".$level.".pid, ','),''),".$ifcondition;
  }while($result != NULL );
  $sql = str_replace('join','left join',$origsql);
$sql = str_replace('as parents','as parents,0 as subscribe,0 as subscribenode',$sql);
/*$origjoin = str_replace('join','left join',$origjoin);*/
  $sql = "insert into z_commentsubscribe (cid, parents, subscribe, subscribenode) ".$sql."
left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null";
db_query($sql);
/*  db_query("update comments c1 $origjoin join z_commentsubscribe cs on c1.cid = cs.cid set cs.parents = concat('0,', ".$origifcond." )");*/
}

to
function comment_subscribe_enable() {
//If comment_subscribe module is enabled in a live site.
  //For previous comments an entry in z_commentsubscribe is
  //generated using the below code.
$level = 1;
  $ifcondition = "if(c".$level.".pid <> 0, concat(c".$level.".pid, ','),'')";
  $table = "c".$level;
$join =null;
  //First find the level of comments
do {

   if($level != 1) {
     $prvlevel = $level - 1;
$join .= " join {comments} c".$level." on c".$prvlevel.".pid=c".$level.".cid";
   }
$sql = "select c1.cid, concat('0,', ".$ifcondition." ) as parents from {comments} c1  ".$join;
$result = db_fetch_array(db_query($sql));
   if($result != NULL ) {
$origsql = $sql;
     $origjoin = $join;
$origifcond = $ifcondition;
   }
$level++;
   $table = "c".$level;
   $ifcondition = " if(c".$level.".pid <> 0, concat(c".$level.".pid, ','),''),".$ifcondition;
  }while($result != NULL );
  $sql = str_replace('join','left join',$origsql);
$sql = str_replace('as parents','as parents,0 as subscribe,0 as subscribenode',$sql);
/*$origjoin = str_replace('join','left join',$origjoin);*/
  $sql = "insert into {z_commentsubscribe} (cid, parents, subscribe, subscribenode) ".$sql."
left join {z_commentsubscribe} cs on c1.cid = cs.cid where cs.subscribe is null";
db_query($sql);
/*  db_query("update {comments} c1 $origjoin join {z_commentsubscribe} cs on c1.cid = cs.cid set cs.parents = concat('0,', ".$origifcond." )");*/
}

after these modification, if you use different prefix, it should work correctly.

#1

sybesis - September 6, 2008 - 23:19

Here is a patch.

AttachmentSize
comment.patch 1.41 KB

#2

zyxware - November 22, 2008 - 08:37

Faure

Fixed the issue in last commit

Thank you

#3

zyxware - November 22, 2008 - 08:38
Assigned to:sybesis» zyxware
Status:active» fixed

#4

System Message - December 6, 2008 - 08:46
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.