I was attempting to install the package into a
MariaDB
(
fork of MySQL), database named ann_smf
. The table prefix
I specified during the installation of the SMF software was dreaming_
. You can find those values in Settings.php
in the forum
software directory. E.g.:
########## Database Info ##########
$db_type = 'mysql';
$db_server = 'localhost';
$db_name = 'ann_smf';
$db_user = 'ann';
$db_passwd = 'Some-Password';
$ssi_db_user = '';
$ssi_db_passwd = '';
$db_prefix = 'dreaming_';
$db_persist = 0;
$db_error_send = 1;
You can also view them within the forum by choosing Admin then Configuration then Server Settings and looking under Database and Paths.
I logged into the MariaDB database software with mysql -p
and looked for the referenced table, ann_smf.dreaming_log_httpBL
;
it didn't exist as the error message indicated. You can also use
phpMyAdmin to examine
the tables in a database.
Since the error message was coming from
Packages/temp/install_2.php
, I examined that file. When you
attempt to install a mod, the files within the zip file for the mod are
extracted into the Packages/temp
directory. Inside that
file, I saw the following PHP code:
if ($db_type == "mysql") { $query_old_table = $smcFunc['db_query']('', ' SHOW TABLES FROM `'.$db_name.'` LIKE {string:table_name}', array( 'table_name' => '%log_httpBL', ) ); $old_table_exists = $smcFunc['db_num_rows']($query_old_table); $smcFunc['db_free_result']($query_old_table); if ($old_table_exists) { $result = $smcFunc['db_query']('', ' DESCRIBE {db_prefix}log_httpBL errorNumber', array( ) ); $updating = $smcFunc['db_num_rows']($result) == 0; $smcFunc['db_free_result']($result); } }
You can find information on smcFunc
at the Simple Machines
Forum wiki at
$smcFunc, but it appeared the following check was causing the issue:
SHOW TABLES FROM `'.$db_name.'` LIKE {string:table_name}', array( 'table_name' => '%log_httpBL', )
The PHP code was resulting in a MySQL query SHOW TABLES FROM ann_smf
LIKE '%log_httpBL'
to be issued, since the variable $db_name
equated to ann_smf
. That would not have been a problem,
except there were two other SMF forums within the same database each with its
own database prefix. Since there were separate database prefixes, SMF knows
which tables belong to which forum, but the PHP code for httpBL in
install_2.php
, which is the install.php file used if you have a
SMF 2.x forum, was assuming that a forum's tables are in a database in which no
other forum's tables exist. If I issued the command manually, I could see
the cause of the problem:
MariaDB [ann_smf]> SHOW TABLES FROM ann_smf LIKE '%log_httpBL'; +---------------------------------+ | Tables_in_ann_smf (%log_httpBL)| +---------------------------------+ | alot_log_httpBL | | backup_alot_log_httpBL | | backup_ourclub_log_httpBL | | ourclub_log_httpBL | +---------------------------------+ 4 rows in set (0.00 sec) MariaDB [ann_smf]>
There were two other sites that had tables with names ending in
log_httpBL
, so $old_table_exists
was getting a
value that made the "if" test for $old_table_exists
true and
resulting in DESCRIBE {db_prefix}log_httpBL errorNumber
being
executed. Since I knew there was not actually an old version of the
log_httpBL
table for this forum, I changed the line below in
install_2.php
in the original zip file.
$old_table_exists = $smcFunc['db_num_rows']($query_old_table);
I changed it to be the following:
$old_table_exists = 0;
The zero would make the "if" test false and result in the install process
proceeding as if it did not find any other tables ending with log_httpBL
.
I had to change the install_2.php
file in the original zip file;
changing the install_2.php
file in the temp
directory at that point won't fix the problem. When I hit
Back
on the SMF web page where the error occurred and then
clicked on the Install Now button again, I saw the error message below:
So I went to the Packages page and started the installation process
from the beginning again. I clicked on Install Mod for httpBL.
I chose to install the mod for all themes again. Again I received the error
message "Table 'ann_smf.dreaming_log_httpBL' doesn't exist" referencing
Packages/temp/install_2.php
. And when I checked install_2.php
I found it was back to what it had been previously, i.e., my change
wasn't there, so then I unziped the original httpBL_v2_5_1.zip
file.
$ unzip httpBL_v2_5_1.zip Archive: httpBL_v2_5_1.zip inflating: SMF Mod TOS Draft.doc inflating: httpBL.template.php inflating: httpBL_2_Config.php inflating: httpBL_Config.php inflating: httpBL_Subs.php inflating: httpBL_css.css inflating: install_1.php inflating: install_1.xml inflating: install_2.php inflating: install_2.xml inflating: languages.xml inflating: languages_utf8.xml inflating: package-info.xml inflating: readme.txt inflating: warning.php inflating: warning_css.css
I then modified the line in install_2.php
and zipped the files
into a zip file again. That led to other errors as noted in
Package Manager - An Error Has
Occurred!. I finally discovered that there was apparently some problem
with the zip file I created on the Linux server where the forum resides.
When I made the same modification to install_2.php
on a Microsoft
Windows system and created a new zip file there, which I uploaded with the
Package Manager for the forum, I was able to successfully install
the httpBL mod.
Created: Sunday August 23, 2015