Skip to content

refactor: remove deprecations in Database#9986

Merged
paulbalandan merged 1 commit intocodeigniter4:4.8from
paulbalandan:cleanup-db
Feb 27, 2026
Merged

refactor: remove deprecations in Database#9986
paulbalandan merged 1 commit intocodeigniter4:4.8from
paulbalandan:cleanup-db

Conversation

@paulbalandan
Copy link
Member

Description
Removes deprecated items in database.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan added refactor Pull requests that refactor code 4.8 PRs that target the `4.8` branch. labels Feb 22, 2026
@paulbalandan paulbalandan force-pushed the cleanup-db branch 2 times, most recently from 0c550da to 1ab0d9a Compare February 22, 2026 14:00
@github-actions github-actions bot added the stale Pull requests with conflicts label Feb 23, 2026
@github-actions

This comment was marked as resolved.

@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Feb 23, 2026
@paulbalandan paulbalandan force-pushed the cleanup-db branch 8 times, most recently from e9532fe to 7a470bb Compare February 23, 2026 16:19
@paulbalandan
Copy link
Member Author

After all the fixes to the tests, I realise now why they are failing. MySQLi\Connection relies on the deprecated $strictOn property from BaseConnection. This code block is now ignored:

if ($this->strictOn !== null) {
            if ($this->strictOn) {
                $initCommands[] = "sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')";
            } else {
                $initCommands[] = "sql_mode = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
                                    @@sql_mode,
                                    'STRICT_ALL_TABLES,', ''),
                                ',STRICT_ALL_TABLES', ''),
                            'STRICT_ALL_TABLES', ''),
                        'STRICT_TRANS_TABLES,', ''),
                    ',STRICT_TRANS_TABLES', ''),
                'STRICT_TRANS_TABLES', '')";
            }
        }

My question now is why are the tests look stricter without this? Are our tests not strict by default? Personally, I like the stricter tests I just fixed.

@michalsn
Copy link
Member

@paulbalandan

My question now is why are the tests look stricter without this? Are our tests not strict by default? Personally, I like the stricter tests I just fixed.

When $strictOn is set to false, framework explicitly removes strict SQL modes from the session. Ignoring this logic means connections now inherit the server default sql_mode, which in MySQL 5.7+ includes strict mode.

Code that relied on non-strict behavior (e.g., silent truncation, implicit numeric casting) may now receive SQL errors instead of warnings.

For compatibility reasons, we have to allow this mode, although I have nothing against changing it to true by default.

@paulbalandan
Copy link
Member Author

Well, I have nothing against non-strict mode. For compatibility, yes, I would expect the framework to use non-strict mode but I'm annoyingly surprised the tests are not running strictly. IMO that's counter-intuitive to us promoting to use DBDebug as true but letting the DB driver swallow fatal errors.

Anyway, I'll open a PR to backport the fixes here to develop by turning $strictOn to true.

@paulbalandan paulbalandan marked this pull request as draft February 23, 2026 18:50
@github-actions github-actions bot added the stale Pull requests with conflicts label Feb 23, 2026
@github-actions

This comment was marked as resolved.

@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Feb 27, 2026
@paulbalandan paulbalandan force-pushed the cleanup-db branch 3 times, most recently from b1a5ec3 to 22feedb Compare February 27, 2026 12:15
@paulbalandan paulbalandan marked this pull request as ready for review February 27, 2026 12:36
@paulbalandan paulbalandan merged commit de063a8 into codeigniter4:4.8 Feb 27, 2026
48 of 49 checks passed
@paulbalandan paulbalandan deleted the cleanup-db branch February 27, 2026 17:08
JulianAtkins pushed a commit to JulianAtkins/CodeIgniter4 that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants