XOOPS runs sql/mysql.sql only once, on a fresh install. When a site updates a module that's already installed, that file is never run again. Any new table has to be created by the module's update code instead, usually in onupdate.php or include/update.php.
The problem the inspection guards against:
1. Version 1.0 of a module ships with tables a and b.
2. In version 1.1 you add table c to mysql.sql.
3. New sites that install 1.1 get a, b and c.
4. Sites updating from 1.0 to 1.1 still have only a and b, because mysql.sql isn't run on update.
5. The first page that uses c fails with MySQL error 1146: Table doesn't exist.
The inspection looks at each CREATE TABLE in mysql.sql and checks whether the update code mentions that table anywhere. If it doesn't, you get this note: "updating sites might never get this table."
Why it's only a weak note:
The plugin can't tell whether the table is new or old. It only sees the current code, not which tables earlier releases shipped.
- If the table has existed since the module's first release, every site already has it and nothing needs to be done. The note is harmless.
- If the table was added in a later version, updating sites are missing it, and you need to add creation code to the update script.
Only the author knows which case applies, so the plugin reports it quietly instead of calling it an error.
What to do when you see it:
- If the table was there from the start, ignore it.
- If you added the table after a release, make the update script create it when it's missing. For example, use CREATE TABLE IF NOT EXISTS in your update callback, or use XMF's migrate or table-loading tools.
Here are two good examples, each adds a table in sql/mysql.sql for new installs, and its update script also creates that table for sites updating from an older version.
1. xnewsletter: modules/xnewsletter/include/onupdate.php
This is the clearest one, because each release that added a table has its own step:
function xoops_module_update_xnewsletter(XoopsObject $xoopsModule, $oldversion = null)
{
...
if ($oldversion < 103) { ... } // calls xoops_module_update_xnewsletter_103()
if ($oldversion < 104) { ... } // calls xoops_module_update_xnewsletter_104()
if ($oldversion < 130) { ... } // calls xoops_module_update_xnewsletter_130()
- Version 1.03 added the import table. xoops_module_update_xnewsletter_103() runs CREATE TABLE mod_xnewsletter_import (line 332).
- Version 1.04 added the task table. ..._104() runs CREATE TABLE mod_xnewsletter_task (line 296).
- Version 1.30 added templates. ..._130() runs CREATE TABLE xnewsletter_template (line 193).
A site still on 1.02 gets all three tables when it updates. A fresh install gets them straight from mysql.sql.
2. news: modules/news/include/onupdate.php
if ($previousVersion < 174) {
...
} elseif (!Utility::existTable($xoopsDB->prefix('news_stories_files'))) {
// 1) Create, if it does not exists, the stories_files table
$sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_files') . " (
It does the same for news_stories_votedata at line 173. It checks whether the table exists first, so running it twice does no harm.
In both modules, the table appears in two places, in sql/mysql.sql for new installs and in the update script for sites that already have the module. If you add a table to mysql.sql and don't add the matching block to the update script, every site that updates will hit "Table doesn't exist" (error 1146). That's exactly what the inspection warns about. For these tables the warning doesn't appear, because the update script mentions them.