function _phpbb2drupal_check_tables() causes theming errors
nbz - July 13, 2008 - 22:49
| Project: | phpBB2Drupal |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
No idea what, but it seems there is a bug in the following code, which shows errors in the pages calling this function:
<?php
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;
}
?>
#1
Please attach which errors it is showing so we know what to expect when debugging this code.
#2
hehe, 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
#3
i 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.
#4
I (think) I am.
The function that called the above function for this error is
EDIT - I have quoted the same function again. D'oh!
#5
see 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.
#6
\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...)
#7
Fixed in HEAD: http://drupal.org/cvs?commit=147700
Fixed in 1.x-dev: http://drupal.org/cvs?commit=147701
and once again, litwol: thanks.
#8
Automatically closed -- issue fixed for two weeks with no activity.