Skip to content

v1.6.13

Choose a tag to compare

@mastacontrola mastacontrola released this 22 Aug 14:55
· 9 commits to main since this release
bf9b18a

Build plugin tables through createTableSql(), so optional columns get defaults (#23).

A column declared NOT NULL with no DEFAULT is only mandatory if something enforces it. For nine years nothing did — PDODB cleared sql_mode on every connection, so the server downgraded the error to a warning and substituted an implicit zero. Removing the clear turned every one of those declarations into a real constraint, and an INSERT that omits one now fails with error 1364 (GH-1245).

Core's schema step 348 repairs the tables an install already has. It cannot repair a plugin's: createSql() runs as step 0 of each plugin's own schema(), so a plugin installed after the migration got a table built the old way — every optional column mandatory again.

All 25 table-building call sites now go through FOGManagerController::createTableSql(), which takes the identical arguments and fills a default into every NOT NULL column that has none. Three kinds of column stay bare: the primary key and auto-increment column, anything the model declares required, and anything whose name ends in ID — because an INSERT that forgets the row it hangs off should fail rather than make a silent orphan. A default a manager passes explicitly always wins, so nothing already stated here changes.

Measured against a live 1.6 install, across the 23 tables the probe can build:

before after
DDL accepted by the server 23/23 23/23
columns carrying a default 29 60
columns left bare 83 52

Each of the 52 is bare for one of the three stated reasons.

Requires core carrying the seamFOGManagerController::createTableSql(), FOGProject/fogproject #1275 on working-1.6. Without it a plugin install dies on Call to undefined method, so this release must be paired with a FOG_PLUGINS_VERSION bump to a core that has it.