Automattic / Automattic/wordbless
sqlite dumps a bunch of database errors at startup
- Dominant language
- PHP
- Stars
- 145
- Forks
- 11
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
On a fresh run (i.e. no persisted database) using sqlite, `wp-settings.php` dumps two database errors to the console during PHPUnit startup as it tries to access tables that don't exist yet. This doesn't cause tests to fail, but it's unsightly.
You can see it in your own CI runs, e.g. https://github.com/Automattic/wordbless/actions/runs/32192936412/job/95891013816#step:11:35
```
> ./vendor/phpunit/phpunit/phpunit --colors=always --bootstrap tests/bootstrap-sqlite.php --testsuite sqlite
WordPress database error
WordPress database error: [<div style="clear:both"> </div>
<div class="queries" style="clear:both;margin-bottom:2px;border:red dotted thin;">
<p>MySQL query:</p>
<p>SELECT option_value FROM wp_options WHERE option_name = 'siteurl' LIMIT 1</p>
<p>Queries made or created this session were:</p>
<ol>
<li>Executing: BEGIN | (no parameters)</li>
<li>Executing: SELECT option_value FROM wp_options WHERE option_name = :param0 LIMIT 1 | parameters: siteurl</li>
<li>Executing: ROLLBACK | (no parameters)</li>
</ol>
</div>
<div style="clear:both;margin-bottom:2px;border:red dotted thin;" class="error_message" style="border-bottom:dotted blue thin;">
Error occurred at line 4164 in Function <code>handle_error</code>. Error message was: SQLSTATE[HY000]: General error: 1 no such table: wp_options.
</div>
<p>Backtrace:</p>
<pre>#0 /home/runner/work/wordbless/wordbless/wordpress/wp-content/plugins/wp-sqlite-integration/wp-includes/sqlite/class-wp-sqlite-db.php(287): WP_SQLite_Translator->get_error_message()
#1 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/class-wpdb.php(3069): WP_SQLite_DB->query()
#2 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/option.php(206): wpdb->get_row()
#3 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/default-constants.php(176): get_option()
#4 /home/runner/work/wordbless/wordbless/wordpress/wp-settings.php(488): wp_plugin_directory_constants()
#5 /home/runner/work/wordbless/wordbless/src/Load.php(50): require('...')
#6 /home/runner/work/wordbless/wordbless/tests/bootstrap-sqlite.php(17): WorDBless\Load::load()
#7 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once('...')
#8 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
#9 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(567): PHPUnit\Util\FileLoader::checkAndLoad()
#10 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(345): PHPUnit\TextUI\Command->handleBootstrap()
#11 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(114): PHPUnit\TextUI\Command->handleArguments()
#12 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run()
#13 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#14 {main}</pre>
MySQL query:
SELECT option_value FROM wp_options WHERE option_name = 'siteurl' LIMIT 1
Queries made or created this session were:
- Executing: BEGIN | (no parameters)
- Executing: SELECT option_value FROM wp_options WHERE option_name = :param0 LIMIT 1 | parameters: siteurl
- Executing: ROLLBACK | (no parameters)
Backtrace:
#0 /home/runner/work/wordbless/wordbless/wordpress/wp-content/plugins/wp-sqlite-integration/wp-includes/sqlite/class-wp-sqlite-db.php(287): WP_SQLite_Translator->get_error_message()
#1 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/class-wpdb.php(3069): WP_SQLite_DB->query()
#2 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/option.php(206): wpdb->get_row()
#3 /home/runner/work/wordbless/wordbless/wordpress/wp-includes/default-constants.php(176): get_option()
#4 /home/runner/work/wordbless/wordbless/wordpress/wp-settings.php(488): wp_plugin_directory_constants()
#5 /home/runner/work/wordbless/wordbless/src/Load.php(50): require('...')
#6 /home/runner/work/wordbless/wordbless/tests/bootstrap-sqlite.php(17): WorDBless\Load::load()
#7 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once('...')
#8 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
#9 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(567): PHPUnit\Util\FileLoader::checkAndLoad()
#10 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(345): PHPUnit\TextUI\Command->handleBootstrap()
#11 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(114): PHPUnit\TextUI\Command->handleArguments()
#12 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run()
#13 /home/runner/work/wordbless/wordbless/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#14 {main}
for query SELECT option_value FROM wp_options WHERE option_name = 'siteurl' LIMIT 1 made by PHPUnit\TextUI\Command::main, PHPUnit\TextUI\Command->run, PHPUnit\TextUI\Command->handleArguments, PHPUnit\TextUI\Command->handleBootstrap, PHPUnit\Util\FileLoader::checkAndLoad, PHPUnit\Util\FileLoader::load, include_once('/home/runner/work/wordbless/wordbless/tests/bootstrap-sqlite.php'), WorDBless\Load::load, require('wp-settings.php'), wp_plugin_directory_constants, get_option, WP_SQLite_DB->query, WP_SQLite_DB->print_error
]
SELECT option_value FROM wp_options WHERE option_name = 'siteurl' LIMIT 1..... 5 / 5 (100%)
Time: 00:00.048, Memory: 42.50 MB
OK (5 tests, 28 assertions)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with tests/bootstrap-sqlite.php and src/Load.php, then trace the startup path through wp-settings.php and wp-includes/sqlite/class-wp-sqlite-db.php. Run the SQLite PHPUnit command from the issue to reproduce the startup output. Done means the five tests still pass without database errors being printed on a fresh database.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sqlite, wordpress
- Domain
- database, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100