Closed (fixed)
Project:
phpBB2Drupal
Version:
master
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2008 at 22:49 UTC
Updated:
3 Nov 2008 at 21:12 UTC
No idea what, but it seems there is a bug in the following code, which shows errors in the pages calling this function:
function _phpbb2drupal_check_tables( $tables = array(), $db = 'default' , $prefix = 1) {
_phpbb2drupal_db_connect() ;
db_set_active($db);
$out['html'] = '<ul>';
$out['result']= 1;
foreach ($tables as $table) {
if ($prefix) {
$table = db_prefix_tables('{'. $table .'}');
}
if ($GLOBALS['db_type'] == 'pgsql') {
// adapt from db_table_exists in database.pgsql.inc
$result = (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '%s'", $table));
}
else {
// adapt from db_table_exists in database.mysql.inc
$result = (bool) db_fetch_object(db_query("SHOW TABLES LIKE '%s'", $table));
}
if ($result) {
$out['html'] .= '<li>'. t('Table %table: OK!', array('%table' => $table)) .'</li>';
}
else {
$out['html'] .= '<li><span class="marker">'. t('Table <strong>%table</strong> does not exist!', array('%table' => $table)) .'</span></li>';
$out['result']= 0;
}
}
$out['html'] .= '</ul>';
db_set_active('default');
return $out;
}
Comments
Comment #1
litwol commentedPlease attach which errors it is showing so we know what to expect when debugging this code.
Comment #2
naheemsays commentedhehe, you asked for it :P
It only happens when the phpbb_data is in a separate database.
to reproduce, go to admin/settings/phpbb2drupal, in "Location of phpBB data", untick the same db box, save page, go back and enter the details of another database.
EDIT - seems that Drupal.org will not show it. Pastebin: http://pastebin.com/f4d2a648e
Comment #3
litwol commentedi had similar problem in one of my own modules when i switched database and didnt switch back immediately after the query. the issue is that you let drupal execute other queries against a table that doesnt have drupal's own tables, such as cache table.
if error occurs while doing a query, it will try to write to watchdog table which also doesnt exist in your switched to database.
so there,after you perform query, you must switch database back to original right away.
Comment #4
naheemsays commentedI (think) I am.
The function that called the above function for this error is
EDIT - I have quoted the same function again. D'oh!
Comment #5
litwol commentedsee you use the t() function.. that function looks into locale module and cache table and other fun stuff. that is what i think triggers your error when you switch the database.
Comment #6
naheemsays commented\o/
Thanks!
Been trying to track this down for quite a while now, and you managed to find it in just a few minutes!
Once this is fixed, all I need is a stable privatemsg.module and a working phpass module and version 2.0 of phpbb2drupal can be released. (actually, I may not wait that long...)
Comment #7
naheemsays commentedFixed in HEAD: http://drupal.org/cvs?commit=147700
Fixed in 1.x-dev: http://drupal.org/cvs?commit=147701
and once again, litwol: thanks.
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.