Error in SQL-Queries
| Project: | Multiping |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I found an error in multiping.modules in function _multiping_checkpings() that causes an error in generated sql-queries. Generated sql-queries shows like this:
SELECT max(created) FROM drupal_drupal_node n WHERE n.status>0 AND n.promote>0
You can see the double prefix drupal_ in front of node. The cause are to many { and } in function _multiping_checkpings(). I replaced
$res_time = db_query('SELECT max(created) FROM {'.$sql_from.'} WHERE '.$sql_where);
and
$res_time = db_query('SELECT max(changed) FROM {'.$sql_from.'} WHERE '.$sql_where);
with
$res_time = db_query('SELECT max(created) FROM '.$sql_from.' WHERE '.$sql_where);
and
$res_time = db_query('SELECT max(changed) FROM '.$sql_from.' WHERE '.$sql_where);
and all works fine.
It would be nice, if you can fix this issue for one of the next releases of module multiping for drupal 6.x.
Greetings,
anrichter

#1
That's exactly it! Without the fix from anrichter it would look like / it looks like:
user warning: Table 'DB.prefx_prefx_node' doesn't exist query: SELECT max(created) FROM prefx_prefx_node n WHERE n.status>0 AND (n.type='artikel' OR n.type='blog' OR n.type='simplenews' OR n.type='poll') in /server-x/drupal-installation/sites/all/modules/multiping/multiping.module on line 174.#2
Anrichter is correct, can somebody please commit the changes?
#3
Hi,
Are you sure you labelled this issue correctly? The 6.x version (which is only in dev and not changed since 13th November 2008) does not have this bug. Also neither do either of the Drupal5 versions available. The only place I have seen this problem is when it was introduced by the code 'clean up' patch for D5 given in in #241366: Drupal Coding Standards Cleanup. If you applied that patch then you can undo it by re-downloading the original. Or maybe the bug was introduced to the D6 version and it was subsequently fixed without any mention here.
Marking this as fixed because none of the code currently available to download exhibits the bug, but please re-open if you are still having difficulties.
Jonathan
#4
Reopening, the DRUPAL-6--1 version from CVS and the HEAD version are affected.
Index: multiping.module===================================================================
--- multiping.module (.../vendors/multiping-DRUPAL-6--1) (Revision 97)
+++ multiping.module (.../trunk/multiping) (Arbeitskopie)
@@ -171,11 +171,11 @@
//watchdog("debug","Multiping ".$row->name.": SELECT * FROM ".$sql_from." WHERE ".$sql_where);
// Get max creation and modification time
$max_created = 0;
- $res_time = db_query('SELECT max(created) FROM {'.$sql_from.'} WHERE '.$sql_where);
+ $res_time = db_query('SELECT max(created) FROM '.$sql_from.' WHERE '.$sql_where);
$row_time = db_fetch_array($res_time);
if ($row_time) $max_created=$row_time['max(created)'];
$max_changed = 0;
- $res_time = db_query('SELECT max(changed) FROM {'.$sql_from.'} WHERE '.$sql_where);
+ $res_time = db_query('SELECT max(changed) FROM '.$sql_from.' WHERE '.$sql_where);
$row_time = db_fetch_array($res_time);
if ($row_time) $max_changed=$row_time['max(changed)'];
if ($max_created>$max_changed)