Skip to content

Fix enabling and using the extension on MSSQL - #15

Merged
bonelifer merged 4 commits into
mainfrom
fix/mssql-enable
Nov 12, 2026
Merged

bonelifer merged 4 commits into
mainfrom
fix/mssql-enable

Conversation

@bonelifer

@bonelifer bonelifer commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The extension could not be enabled on a fresh MSSQL board, on phpBB 3.3 or 4.0, and a few pages failed there once it was.

Enabling

  • version_1_0_0 inserts the kb_options rows with fixed ids. MSSQL only takes an explicit value for an identity column with IDENTITY_INSERT on, so the insert now turns it on and off around the rows on MSSQL (phpBB's installer does the same for its ACL options).
  • version_1_0_0 and version_1_0_5 put numbers into kb_config.config_value, a text column, which MSSQL refuses ("Operand type clash: int is incompatible with ntext"). The values are now strings.
  • version_1_0_0 ran one query twice and never freed the first result, and version_2_0_0 never freed its result. MSSQL then refused the next transaction.

Pages

  • Adding the first category (and moving a category to the root) added 1 to MAX(right_id) of an empty table. phpBB's MSSQL driver returns that NULL as an empty string, which is a TypeError in PHP 8. It is now cast to an integer.
  • Search, the article edit form and article comments used SELECT DISTINCT over text columns, which MSSQL cannot compare. Each join matches a single row, so DISTINCT is dropped.

Tests

  • tests/kb_mssql_migration_test.php and tests/kb_acp_first_category_test.php cover the fixes above. Both fail on main.
  • tests/browser/kb_page_sweep.js is a new read-only browser check: as the seed-forum administrator it opens the main Knowledge Base pages and every Knowledge Base ACP module, and fails on a server error, a PHP error or an SQL error page.
  • docs/testing.md has a new section with the details.

Tested by Claude:

  • A fresh seed-forum board with the full Knowledge Base fixtures on phpBB 3.3.19 and 4.0.0-a3-dev with SQLite, MySQL 8.4, MariaDB, PostgreSQL 16 and MSSQL (SQL Server 2022): ten boards. Each loaded 24 of 24 pages cleanly in the sweep, and disable, purge and enable through phpBB's CLI worked (nothing left after the purge, all 40 migrations done after the enable).
  • The PHPUnit suite on phpBB 3.3.x and master with the MySQL and PostgreSQL fixtures: 511 tests before merging main and 574 after, none skipped, all pass. phpcs and EPV are clean on both branches.

With the fresh-PostgreSQL fix (#12)

#12 gives version_2_0_30's new option an explicit id, which MSSQL also only takes with IDENTITY_INSERT on, so this PR adds the same wrapper there. Before #12 reached main, the PostgreSQL boards ran this change merged with that branch; after merging main in, Claude ran fresh MSSQL boards on 3.3 and 4.0 again (all 43 migrations, including the new ones from #13 and #14) and the full suite (574 tests, none skipped).

Building the boards needed seed-forum fixes: phpbbmodders/seed-forum#35.


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

🤖 Generated with Claude Code

bonelifer and others added 4 commits November 12, 2026 04:10
A fresh phpBB 3.3 or 4.0 board on MSSQL could not enable the extension,
and several pages failed there once it was enabled:

- version_1_0_0 inserted the kb_options rows with fixed ids, which MSSQL
  only takes with IDENTITY_INSERT on.
- version_1_0_0 and version_1_0_5 put numbers into kb_config's text
  column ("Operand type clash: int is incompatible with ntext"); the
  values are now strings.
- version_1_0_0 ran one query twice and left the first result open, and
  version_2_0_0 never freed its result; MSSQL then refused the next
  transaction.
- Adding the first category added 1 to MAX(right_id) of an empty table,
  which MSSQL's driver returns as '' (TypeError in PHP 8). Same for
  moving a category to the root.
- Search, the edit form and article comments used SELECT DISTINCT over
  text columns, which MSSQL cannot compare. The joins are one-to-one, so
  DISTINCT is dropped.

Adds regression tests and a read-only browser sweep of the main pages
and every ACP module (tests/browser/kb_page_sweep.js).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the fresh-PostgreSQL fix (#12) and the kinerity import (#13).
version_2_0_30 now inserts kb_m_change_author with an explicit id, so it
gets the same IDENTITY_INSERT wrapper on MSSQL as version_1_0_0, with a
test. Both new docs/testing.md sections are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the index introduction (#14), which also clears the EPV
finding in inc/kinerity_import.php. Both new docs/testing.md sections
are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bonelifer

Copy link
Copy Markdown
Contributor Author

Merged main into this branch twice (60eff92, then c9e18bf) to resolve conflicts in docs/testing.md: the kinerity import (#13), the index introduction (#14) and this PR each added a section at the end, and all are kept. The second merge also brings in #14's fix for the EPV finding in inc/kinerity_import.php, which failed the EPV checks on 60eff92.

With the fresh-PostgreSQL fix (#12) now on main, version_2_0_30 inserts kb_m_change_author with an explicit id. MSSQL only takes that with IDENTITY_INSERT on, so the first merge adds the same wrapper there as in version_1_0_0, with two tests in kb_mssql_migration_test.php.

Claude checked c9e18bf:


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

@bonelifer
bonelifer merged commit 907eb19 into main Nov 12, 2026
14 checks passed
@bonelifer
bonelifer deleted the fix/mssql-enable branch November 12, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant