Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
265 commits
Select commit Hold shift + click to select a range
b617ef9
Record CREATE TABLE table info in information schema
JanJakes Dec 19, 2024
dbd50e6
Record CREATE TABLE column info in information schema
JanJakes Dec 19, 2024
6bdb7aa
Record CREATE TABLE constraint info in information schema
JanJakes Dec 19, 2024
afeeb18
Record CREATE TABLE inline constraint info in information schema
JanJakes Dec 19, 2024
2eaf077
Sync constraint info to columns table when constraints are modified
JanJakes Dec 19, 2024
d03892d
Record ALTER TABLE ADD COLUMN(s) in information schema
JanJakes Dec 19, 2024
93f536e
Record ALTER TABLE ADD CONSTRAINT in information schema
JanJakes Dec 19, 2024
6940a5b
Record ALTER TABLE CHANGE/MODIFY COLUMN in information schema
JanJakes Dec 19, 2024
127efc2
Record ALTER TABLE DROP COLUMN in information schema
JanJakes Dec 19, 2024
71265ed
Record ALTER TABLE DROP INDEX in information schema
JanJakes Dec 20, 2024
71e8d08
Execute CREATE TABLE using information schema
JanJakes Dec 20, 2024
4b4fb8f
Execute ALTER TABLE using information schema
JanJakes Dec 20, 2024
a0a67c0
Implement SHOW CREATE TABLE using information schema
JanJakes Dec 20, 2024
837655c
Implement SHOW INDEX using information schema
JanJakes Dec 20, 2024
f11fb09
Implement SHOW GRANTS
JanJakes Dec 20, 2024
cf6008d
Implement DESCRIBE using information schema
JanJakes Dec 20, 2024
f5a52ca
Ignore index hints
JanJakes Dec 20, 2024
174916a
Add support for LIKE BINARY
JanJakes Jan 10, 2025
335388b
Add support for REGEXP functions
JanJakes Jan 10, 2025
191864c
Merge branch 'develop' into ast-sqlite-driver
adamziel Jan 10, 2025
86a577c
Add support for LEFT function
JanJakes Jan 10, 2025
0b3ba08
Add support for DATE_ADD and DATE_SUB functions
JanJakes Jan 10, 2025
aa9ad47
Add support for DATE_FORMAT()
JanJakes Jan 13, 2025
f1c89ec
Implement SQL_CALC_FOUND_ROWS and FOUND_ROWS()
JanJakes Jan 15, 2025
d356021
Implement FROM DUAL
JanJakes Jan 15, 2025
8432d2a
Implement "CAST(... AS BINARY)"
JanJakes Jan 15, 2025
ab1e94f
Add support for CURRENT_TIMESTAMP() and NOW()
JanJakes Jan 15, 2025
6f2ffb0
Translate datetime literals, fix string literal processing
JanJakes Jan 15, 2025
6933c72
Add support for HAVING without GROUP BY
JanJakes Jan 15, 2025
32c72bf
Implement DROP for multiple and temporary tables
JanJakes Jan 16, 2025
822464a
Implement ON DUPLICATE KEY UPDATE
JanJakes Jan 16, 2025
94fa134
Implement INSERT IGNORE and UPDATE IGNORE
JanJakes Jan 16, 2025
f8af977
Implement DROP TABLE in information schema
JanJakes Jan 16, 2025
28bb50d
Implement SHOW TABLE STATUS
JanJakes Jan 16, 2025
13cd58f
Implement SHOW TABLES
JanJakes Jan 17, 2025
eecc39b
Fix saving and displaying index info
JanJakes Jan 17, 2025
b8fc7d8
Implement ON UPDATE CURRENT_TIMESTAMP
JanJakes Jan 17, 2025
ff8afed
Prefix index names in SQLite to prevent conflicts
JanJakes Jan 17, 2025
a6d5c38
Support type names as KEY names
bgrgicak Jan 21, 2025
698dd2f
Clean up and update inline docs
bgrgicak Jan 21, 2025
c072254
Apply suggestions from code review
bgrgicak Jan 21, 2025
eba8ab5
Fix PHP 7.2 compatibility
bgrgicak Jan 21, 2025
ae0cd50
Add constraint as a column name to the test
bgrgicak Jan 21, 2025
d3637f3
Update inline docs
bgrgicak Jan 21, 2025
ae66749
Remove accidentally pasted text
bgrgicak Jan 21, 2025
4c1ff9f
Split test into two
bgrgicak Jan 21, 2025
fada3e6
Remove unused key from test
bgrgicak Jan 21, 2025
b227db5
Add support for multi-table delete statements
JanJakes Jan 21, 2025
9939dc3
Remove no longer relevant TODOs
JanJakes Jan 21, 2025
32a3a94
Remove no longer used data types cache
JanJakes Jan 21, 2025
3dfc043
Remove destructor
JanJakes Jan 21, 2025
7501c36
Remove unused variable
JanJakes Jan 21, 2025
7d87421
Remove unused property
JanJakes Jan 23, 2025
bb49c90
Simplify setting foreign keys pragma
JanJakes Jan 23, 2025
09edeaa
Use AST to detect transactional statements
JanJakes Jan 23, 2025
86f3b7f
Convert IFs to switch statement
JanJakes Jan 23, 2025
49c9794
Remove outdated comment, add TODO
JanJakes Jan 23, 2025
b0a4520
Improve comment
JanJakes Jan 23, 2025
e2453b7
Use get_child_node() calls to make translation unambiguous
JanJakes Jan 23, 2025
d556c09
Add a TODO comment for AST-querying API
JanJakes Jan 23, 2025
9c1feea
Handle foreign key checks in ALTER TABLE
JanJakes Jan 23, 2025
57287db
Improve query method docs and naming
JanJakes Jan 23, 2025
fa903bc
Fix identifier escaping
JanJakes Jan 23, 2025
38d3491
Throw exceptions for unsupported throw statements
JanJakes Jan 23, 2025
76285ea
Unify identifier quoting
JanJakes Jan 23, 2025
3530023
Improve API of user defined functions
JanJakes Jan 23, 2025
677bca4
Add a TODO for SQLite client info
JanJakes Jan 23, 2025
53eb81e
Use a unified prefix for internal objects
JanJakes Jan 23, 2025
fd6c2fa
Fetch column info only for needed columns when adding a constraint
JanJakes Jan 24, 2025
5b95d96
Preserve ROWIDs in ALTER TABLE statements
JanJakes Jan 24, 2025
e14660e
Fix and improve translation tests
JanJakes Jan 24, 2025
3cfaf92
Use correct string literal quotes
JanJakes Jan 24, 2025
b8b0bef
Use table schema value in all information schema queries
JanJakes Jan 24, 2025
d805979
Remove prototype classes
JanJakes Jan 24, 2025
b6d900b
Remove WIP namespacing (the new classes don't conflict with the exist…
JanJakes Jan 24, 2025
232b1c1
Enable usage of PDO in phpcs
JanJakes Jan 24, 2025
c564fc9
Add a feature flag to use the new driver
JanJakes Jan 27, 2025
c7e121f
Use strict SQLite tables to validate data types
JanJakes Jan 28, 2025
d903016
Select information_schema using a nested query
bgrgicak Jan 29, 2025
7ab0100
Ensure WHERE works
bgrgicak Jan 29, 2025
2478ce4
Remove system tables from information schema results
bgrgicak Jan 29, 2025
7d471e1
Store last insert ID
JanJakes Jan 28, 2025
9297782
Translate CONCAT function to concat pipes
JanJakes Jan 28, 2025
417d37f
Correctly translate REPLACE statements
JanJakes Jan 28, 2025
10dcfc1
Add basic SHOW VARIABLES support
JanJakes Jan 28, 2025
8a08243
Add support for IF NOT EXISTS when creating a table
JanJakes Jan 28, 2025
56dfd83
Improve string literal translation
JanJakes Jan 28, 2025
5db45db
Fix backslash escaping in a test
JanJakes Jan 28, 2025
39b1aba
Fix identifier translation, use backtics due to issues with double qu…
JanJakes Jan 28, 2025
118c57a
Do not execute statements when there are no IDs to delete
JanJakes Jan 28, 2025
b78d0ad
Add basic support for CHAR_LENGTH
JanJakes Jan 28, 2025
3cbb647
Handle null characters in strings
JanJakes Jan 29, 2025
50d0bd2
Fix column default value handling
JanJakes Jan 29, 2025
bbe6470
Display info when the AST driver is used
JanJakes Jan 29, 2025
069f1ef
Add a test for the reason to use backtick identifier escaping
JanJakes Jan 30, 2025
24d1fad
Add missing schema fields
bgrgicak Feb 3, 2025
545fcb7
Revert table status change
bgrgicak Feb 3, 2025
a2c23a5
Use floor instead of round in test
bgrgicak Feb 3, 2025
2c7e39b
Fix PHP 7 support
bgrgicak Feb 3, 2025
20906ae
Remove CREATE_TABLE column
bgrgicak Feb 3, 2025
7cf06a9
Add TODO
bgrgicak Feb 3, 2025
70c0ea9
Clarify why we allow empty table names
bgrgicak Feb 4, 2025
b5a9fba
Merge pull request #2 from Automattic/update/support-type-names-as-ke…
bgrgicak Feb 4, 2025
b870b2a
Merge pull request #3 from Automattic/update/mysql-information-schema…
bgrgicak Feb 4, 2025
487bf54
Use PDO to load SQLite version, improve docs
JanJakes Feb 3, 2025
c63607e
Remove all remaining usages of SQLite 3
JanJakes Feb 3, 2025
39ac173
Declare PDO and PDO SQLite requirements in composer.json
JanJakes Feb 3, 2025
d2be9d8
Use getters instead of public properties
JanJakes Feb 3, 2025
8b74f33
Fix query dumping script
JanJakes Feb 3, 2025
625ca4a
Simplify SQLite lock wait logic
JanJakes Feb 4, 2025
d19c9aa
Remove legacy hooks
JanJakes Feb 4, 2025
67c1fff
Closely mirror wpdb::query() and wpdb::_do_query()
JanJakes Feb 4, 2025
0f8dc09
Simplify driver state
JanJakes Feb 4, 2025
59c4451
Remove uselsess return values
JanJakes Feb 4, 2025
a83a5f8
Change FIX comments to CHANGED
JanJakes Feb 4, 2025
f7c99c1
Improve parser node method naming
JanJakes Feb 5, 2025
8b27c85
Fix FROM/IN handling for SHOW statements
JanJakes Feb 5, 2025
c27b571
Add tests for UNION and UNION ALL
JanJakes Feb 5, 2025
0f7060f
Configure the SQLite driver using an $options array
JanJakes Feb 5, 2025
e961bf5
Use custom exception class for driver errors
JanJakes Feb 6, 2025
fda096c
Ignore transaction rollback errors when an exception occurs
JanJakes Feb 6, 2025
e4df6b9
Return true for transactional commands
JanJakes Feb 6, 2025
96e0208
Move database directory creation outside of the driver, revamp it
JanJakes Feb 6, 2025
cb4d6a3
Extract debug mode setting to an option
JanJakes Feb 6, 2025
54c27a2
Improve driver docs and property naming
JanJakes Feb 6, 2025
beaa51d
Revamp error handling, extract error notice creation out from the driver
JanJakes Feb 6, 2025
09fbcd9
Improve docs and naming
JanJakes Feb 7, 2025
4d9d432
Check for mimimum SQLite version
JanJakes Feb 7, 2025
078e2ce
Remove the AST driver files from .gitattributes
JanJakes Jan 29, 2025
b95341e
Fix grammar compression regression causing array index gaps
JanJakes Feb 10, 2025
6947019
Improve constant name
JanJakes Feb 12, 2025
9c0c9b5
Use past tense in @CHANGED comments
JanJakes Feb 12, 2025
5dfd5fa
Merge pull request #1 from Automattic/ast-sqlite-driver
adamziel Feb 12, 2025
e59c77a
Merge pull request #11 from Automattic/fix-grammar-compression
JanJakes Feb 13, 2025
c756a0b
Update version to 2.1.17-alpha
bgrgicak Feb 18, 2025
2fb5cbb
Merge pull request #18 from Automattic/update/2.1.17-alpha
bgrgicak Feb 18, 2025
dd462c9
Port recently added tests to the new driver test suite
JanJakes Feb 12, 2025
bd9b1aa
Include index column subparts (lenghts) in SHOW CREATE TABLE
JanJakes Feb 12, 2025
9d2f8b2
Port query test suite to the new driver
JanJakes Feb 12, 2025
e3b62c8
Implement SHOW COLUMNS statement
JanJakes Feb 12, 2025
dbc4bda
Use reserved driver prefix also for information schema tables
JanJakes Feb 12, 2025
94c865f
Improve correctness of column identifiers as per sql_yacc.yy
JanJakes Feb 14, 2025
a4c55f3
Improve "alterOrderList" grammar fix as per sql_yacc.yy
JanJakes Feb 14, 2025
15634f8
Use "simpleIdentifier" as per sql_yacc.yy
JanJakes Feb 14, 2025
5c405be
Fix comment
JanJakes Feb 14, 2025
06427c1
Add missing version constraints
JanJakes Feb 14, 2025
1fc98ab
Translate information schema table references
JanJakes Feb 12, 2025
81aa42b
Add support for USE <database> statement (supports main DB and inform…
JanJakes Feb 12, 2025
d43ca92
Fix exact values of row format and create options in information schema
JanJakes Feb 17, 2025
0d989b6
Implement TRUNCATE TABLE statement
JanJakes Feb 17, 2025
dbf54c8
Implement ANALYZE TABLE statement
JanJakes Feb 28, 2025
b38106e
Implement CHECK TABLE statement
JanJakes Feb 28, 2025
00db965
Implement OPTIMIZE TABLE and REPAIR TABLE statements
JanJakes Feb 28, 2025
bc6189f
Use correct PDO exception and code when table not found
JanJakes Mar 3, 2025
3502b1f
Port metadata test suite to the new driver
JanJakes Mar 3, 2025
08043bc
Add test for skiping index hints
JanJakes Mar 3, 2025
aa659c7
Unify temp schema quotes, add DROP TEMPORARY TABLE test
JanJakes Mar 3, 2025
4dae813
Add some more TODO comments
JanJakes Mar 3, 2025
0690f44
Check for auto increment edge case, add test
JanJakes Mar 3, 2025
99c0350
Disallow accessing object with reserved prefix
JanJakes Mar 3, 2025
b48f210
Make infromation schema tables readonly
JanJakes Mar 4, 2025
bb0e22f
Fix undefined method call
JanJakes Mar 4, 2025
ca775d2
Merge pull request #22 from Automattic/fix-undefined-method-crash
JanJakes Mar 5, 2025
abdd93e
Add comments explaining <prefix> placeholder
JanJakes Mar 5, 2025
c6bc3cb
Improve TODO comment
JanJakes Mar 5, 2025
fac0506
Merge pull request #21 from Automattic/driver-parity
JanJakes Mar 10, 2025
4b5f383
Allow using the new driver for initial database creation
JanJakes Mar 8, 2025
a68b358
Setup and run WordPress PHPUnit tests
JanJakes Mar 8, 2025
368e395
Fix _real_escape behavior for non-scalar values
JanJakes Mar 10, 2025
11576c5
Do not bypass esc_like for the new driver
JanJakes Mar 10, 2025
2d0e59d
Fix _real_escape() implementation as per WPDB
JanJakes Mar 10, 2025
545f95a
Merge pull request #26 from Automattic/wp-unit-tests
JanJakes Mar 11, 2025
bdc12f3
Correctly support temp tables by using temp information schema
JanJakes Mar 11, 2025
0d0349e
Explicitly disable CREATE TABLE ... [AS] SELECT statements
JanJakes Mar 11, 2025
dfee2dd
Move IF NOT EXISTS tests to driver tests
JanJakes Mar 12, 2025
40cef5b
Remove a forgotten call to a non-existent method
JanJakes Mar 12, 2025
b865620
Create temporary information schema tables at most once per session
JanJakes Mar 12, 2025
a056876
Merge pull request #27 from Automattic/temporary-table-support
JanJakes Mar 13, 2025
91ca58f
Fix ReflectionException in PHPUnit tests
JanJakes Mar 21, 2025
ad3beb8
Pass $dbname into WP_SQLite_DB
JanJakes Mar 24, 2025
c9b443b
Merge pull request #32 from Automattic/fix-reflection-exception
JanJakes Mar 25, 2025
52769f0
Implement emulation of MySQL non-strict mode for INSERT queries
JanJakes Mar 18, 2025
257e916
Implement emulation of MySQL non-strict mode for UPDATE queries
JanJakes Mar 18, 2025
73132a6
Implement setting session SQL modes
JanJakes Mar 20, 2025
172fd72
Implement reading session SQL modes
JanJakes Mar 20, 2025
b48a8ad
Implement WPDB's set_sql_mode() method for SQLite
JanJakes Mar 20, 2025
ad8256a
Preserve ordinal position when changing column
JanJakes Mar 18, 2025
0387361
Fix TRUNCATE in a database with no sequences
JanJakes Mar 18, 2025
71de197
Make an optional parameter required
JanJakes Mar 18, 2025
2fe31e6
Do not pre-create WP schema for metadata tests
JanJakes Mar 18, 2025
1acd611
Remove now passing tests from exclusion lists
JanJakes Mar 20, 2025
ad474af
Add more non-strict mode tests
JanJakes Mar 21, 2025
d6f6b6d
Bail out with error for unsupported SET statements
JanJakes Mar 25, 2025
f922251
Improve non-strict mode method docs
JanJakes Mar 25, 2025
d39df53
Add a test for REPLACE statement in non-strict mode
JanJakes Mar 25, 2025
079166d
Add a test to ensure ON DUPLICATE KEY UPDATE clause ignores non-stric…
JanJakes Mar 25, 2025
69493b1
Fix typo
JanJakes Mar 25, 2025
4074c52
Merge pull request #29 from Automattic/strict-sql-mode
JanJakes Mar 25, 2025
6e83c19
Fix warnings on site health screen
JanJakes Mar 25, 2025
3faa553
Add a comment explaining why "WHERE true" clause is used
JanJakes Mar 26, 2025
6452601
Merge pull request #34 from Automattic/fix-site-health-warnings
JanJakes Mar 26, 2025
767d246
Check if $_ENV['WP_SQLITE_AST_DRIVER'] is defined (#37)
bgrgicak Mar 28, 2025
6a641f9
Implement a database configurator service for DB initialization and m…
JanJakes Apr 15, 2025
12d3063
Implement more robust plugin version definition and CI check
JanJakes Apr 15, 2025
9a6da9d
Load AST classes for tests in test bootstrap
JanJakes Apr 16, 2025
7727cfa
Implement information schema reconstructor
JanJakes Apr 16, 2025
23331b3
Reconstruct WordPress tables using "wp_get_db_schema" function
JanJakes Apr 17, 2025
ed959fb
Avoid race conditions when configuring the SQLite database
JanJakes Apr 17, 2025
287f4f4
Improve docs
JanJakes Apr 22, 2025
907be69
Fix identifier unquoting
JanJakes Apr 22, 2025
b178b97
In WordPress, make sure the "wp_get_db_schema()" function is defined
JanJakes Apr 22, 2025
5edd7f7
Filter out reserved tables using LIKE
JanJakes Apr 22, 2025
5dddd50
Improve the clarity of primary key reconstruction
JanJakes Apr 22, 2025
95b1a19
Document SQLite column affinity inline
JanJakes Apr 22, 2025
51b22fa
Do not acquire an exclusive lock for every version check, lock only c…
JanJakes Apr 22, 2025
d904064
Fix $wpdb dependency loop when using schema reconstructor in WP
JanJakes Apr 23, 2025
69381d8
Add support for multi-query parsing
JanJakes Apr 23, 2025
cde7da8
Store and expose byte start and length in tokens and nodes
JanJakes Apr 23, 2025
0283884
Parse queries from "wp_get_db_schema()"
JanJakes Apr 23, 2025
e657ad0
Pass input in tokens and get token values lazily
JanJakes Apr 23, 2025
30c8212
Move multi-query parsing to WP_MySQL_Parser, improve naming and docs
JanJakes Apr 23, 2025
6a3b370
Return parser instance rather than a generator
JanJakes Apr 23, 2025
1121fcc
Refactor and document key column definition inference
JanJakes Apr 24, 2025
231bab2
Refactor and document key definition inference
JanJakes Apr 24, 2025
be2841d
Improve and document default column value detection
JanJakes Apr 24, 2025
fd55809
Extract WP schema to a method, improve naming and docs
JanJakes Apr 25, 2025
baa22c3
For multisite installs, reconstruct WP schema for all sites
JanJakes Apr 25, 2025
c67f6c4
Refactor default value handling, add escaping and tests
JanJakes Apr 25, 2025
747ee35
Fix deprecation of implicitly marking parameter as nullable in PHP 8.4
JanJakes Apr 25, 2025
35950e7
Add PHP 8.4 unit tests to CI
JanJakes Apr 25, 2025
959505e
Fix schema inference for WordPress tables
JanJakes Apr 25, 2025
d1dfd2c
Fix removing schema records for non-existent tables
JanJakes Apr 25, 2025
859fb9f
Improve CI job name
JanJakes Apr 27, 2025
94e582c
Always quote identifiers in driver and reconstructor
JanJakes Apr 28, 2025
b0009d6
Extract SQLite connection management to WP_SQLite_Connection
JanJakes Apr 28, 2025
1d284e6
Consolidate SQLite identifier escaping in WP_SQLite_Connection, impro…
JanJakes Apr 28, 2025
4df273e
Fix and refactor test setup
JanJakes Apr 29, 2025
838967a
Always quote identifiers in information schema builder
JanJakes Apr 29, 2025
c745a66
Unify quoting also for $wpdb->blogs table name
JanJakes Apr 29, 2025
9b21ab3
Fix parser API, explicitly disable multi-queries in WP_SQLite_Driver:…
JanJakes Apr 29, 2025
b27339c
Merge pull request #43 from Automattic/fixes
JanJakes Apr 30, 2025
4a327fb
Merge pull request #45 from Automattic/php-8.4
JanJakes Apr 30, 2025
5004c07
Fix and improve default value formatting
JanJakes Apr 30, 2025
fcd6669
Add unique constraints to information schema tables
JanJakes Apr 30, 2025
2a13304
Improve test readability
JanJakes May 1, 2025
82eed09
Merge pull request #42 from Automattic/driver-migration
JanJakes May 5, 2025
278d41c
Fix identifier (un)escaping (#47)
JanJakes May 7, 2025
5652edb
Update minimum required PHP version to 7.2 (#48)
JanJakes May 12, 2025
a2ea9f8
Information schema cleanup and improvements (#49)
JanJakes May 26, 2025
a6a760e
New driver fixes from manual testing (#51)
JanJakes May 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
composer.json export-ignore
phpcs.xml.dist export-ignore
phpunit.xml.dist export-ignore
wp-setup.sh export-ignore
/.github export-ignore
/grammar-tools export-ignore
/tests export-ignore
/wip export-ignore
/wp-includes/mysql export-ignore
/wp-includes/parser export-ignore
/wp-includes/sqlite/class-wp-sqlite-crosscheck-db.php export-ignore
/wordpress export-ignore
5 changes: 1 addition & 4 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
# NOTE: There does not appear to be a single phpunit version that supports all
# PHP versions tested here. For now, we are removing PHP 7.0. and 7.1 tests
# in order to run a single phpunit version for PHP 7.2 and up.
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]

with:
os: ${{ matrix.os }}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/verify-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Verify plugin version

on:
push:
branches:
- main
pull_request:

jobs:
verify-version:
name: Assert the WordPress plugin header declares the same version as the SQLITE_DRIVER_VERSION constant
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Extract version from "load.php"
id: load_version
run: |
VERSION=$(grep "Version:" load.php | sed "s/.*Version: \([^ ]*\).*/\1/")
echo "load_version=$VERSION" >> $GITHUB_OUTPUT

- name: Extract version from "version.php"
id: const_version
run: |
VERSION=$(php -r "require 'version.php'; echo SQLITE_DRIVER_VERSION;")
echo "const_version=$VERSION" >> $GITHUB_OUTPUT

- name: Compare versions
run: |
if [ "${{ steps.load_version.outputs.load_version }}" != "${{ steps.const_version.outputs.const_version }}" ]; then
echo "Version mismatch detected!"
echo " load.php version: ${{ steps.load_version.outputs.load_version }}"
echo " version.php constant: ${{ steps.const_version.outputs.const_version }}"
exit 1
fi
142 changes: 142 additions & 0 deletions .github/workflows/wp-tests-phpunit-run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Wrap the "composer run wp-tests-phpunit" command to process tests
* that are expected to error and fail at the moment.
*
* This makes sure that the CI job passes, while explicitly tracking
* the issues that need to be addressed. Ideally, over time this script
* will become obsolete when all errors and failures are resolved.
*/
const { execSync } = require( 'child_process' );
const fs = require( 'fs' );
const path = require( 'path' );

const expectedErrors = [
'Tests_DB_Charset::test_strip_invalid_text',
'Tests_DB::test_db_reconnect',
'Tests_DB::test_get_col_info',
'Tests_DB::test_process_fields_value_too_long_for_field with data set &quot;invalid chars&quot;',
'Tests_DB::test_process_fields_value_too_long_for_field with data set &quot;too long&quot;',
'Tests_DB::test_process_fields',
];

const expectedFailures = [
'Tests_Admin_wpSiteHealth::test_object_cache_thresholds with data set #2',
'Tests_Admin_wpSiteHealth::test_object_cache_thresholds with data set #3',
'Tests_Comment::test_wp_new_comment_respects_comment_field_lengths',
'Tests_Comment::test_wp_update_comment',
'Tests_DB_dbDelta::test_spatial_indices',
'Tests_DB::test_charset_switched_to_utf8mb4',
'Tests_DB::test_close',
'Tests_DB::test_delete_value_too_long_for_field with data set &quot;too long&quot;',
'Tests_DB::test_has_cap',
'Tests_DB::test_insert_value_too_long_for_field with data set &quot;too long&quot;',
'Tests_DB::test_mysqli_flush_sync',
'Tests_DB::test_non_unicode_collations',
'Tests_DB::test_query_value_contains_invalid_chars',
'Tests_DB::test_replace_value_too_long_for_field with data set &quot;too long&quot;',
'Tests_DB::test_replace',
'Tests_DB::test_supports_collation',
'Tests_DB::test_update_value_too_long_for_field with data set &quot;too long&quot;',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #1',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #2',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #3',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #4',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #5',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #6',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #7',
'Tests_Menu_wpNavMenu::test_wp_nav_menu_should_not_have_has_children_class_with_custom_depth',
'WP_Test_REST_Posts_Controller::test_get_items_orderby_modified_query',
];

console.log( 'Running WordPress PHPUnit tests with expected failures tracking...' );
console.log( 'Expected errors:', expectedErrors );
console.log( 'Expected failures:', expectedFailures );

try {
try {
execSync(
`composer run wp-test-phpunit -- --log-junit=phpunit-results.xml --verbose`,
{ stdio: 'inherit' }
);
console.log( '\n⚠️ All tests passed, checking if expected errors/failures occurred...' );
} catch ( error ) {
console.log( '\n⚠️ Some tests errored/failed (expected). Analyzing results...' );
}

// Read the JUnit XML test output:
const junitOutputFile = path.join( __dirname, '..', '..', 'wordpress', 'phpunit-results.xml' );
if ( ! fs.existsSync( junitOutputFile ) ) {
console.error( 'Error: JUnit output file not found!' );
process.exit( 1 );
}
const junitXml = fs.readFileSync( junitOutputFile, 'utf8' );

// Extract test info from the XML:
const actualErrors = [];
const actualFailures = [];
for ( const testcase of junitXml.matchAll( /<testcase([^>]*)\/>|<testcase([^>]*)>([\s\S]*?)<\/testcase>/g ) ) {
const attributes = {};
const attributesString = testcase[2] ?? testcase[1];
for ( const attribute of attributesString.matchAll( /(\w+)="([^"]*)"/g ) ) {
attributes[attribute[1]] = attribute[2];
}

const content = testcase[3] ?? '';
const fqn = attributes.class ? `${attributes.class}::${attributes.name}` : attributes.name;
const hasError = content.includes( '<error' );
const hasFailure = content.includes( '<failure' );

if ( hasError ) {
actualErrors.push( fqn );
}

if ( hasFailure ) {
actualFailures.push( fqn );
}
}

let isSuccess = true;

// Check if all expected errors actually errored
const unexpectedNonErrors = expectedErrors.filter( test => ! actualErrors.includes( test ) );
if ( unexpectedNonErrors.length > 0 ) {
console.error( '\n❌ The following tests were expected to error but did not:' );
unexpectedNonErrors.forEach( test => console.error( ` - ${test}` ) );
isSuccess = false;
}

// Check if all expected failures actually failed
const unexpectedPasses = expectedFailures.filter( test => ! actualFailures.includes( test ) );
if ( unexpectedPasses.length > 0 ) {
console.error( '\n❌ The following tests were expected to fail but passed:' );
unexpectedPasses.forEach( test => console.error( ` - ${test}` ) );
isSuccess = false;
}

// Check for unexpected errors
const unexpectedErrors = actualErrors.filter( test => ! expectedErrors.includes( test ) );
if ( unexpectedErrors.length > 0 ) {
console.error( '\n❌ The following tests errored unexpectedly:' );
unexpectedErrors.forEach( test => console.error( ` - ${test}` ) );
isSuccess = false;
}

// Check for unexpected failures
const unexpectedFailures = actualFailures.filter( test => ! expectedFailures.includes( test ) );
if ( unexpectedFailures.length > 0 ) {
console.error( '\n❌ The following tests failed unexpectedly:' );
unexpectedFailures.forEach( test => console.error( ` - ${test}` ) );
isSuccess = false;
}

if ( isSuccess ) {
console.log( '\n✅ All tests behaved as expected!' );
process.exit( 0 );
} else {
console.log( '\n❌ Some tests did not behave as expected!' );
process.exit( 1 );
}
} catch ( error ) {
console.error( '\n❌ Script execution error:', error.message );
process.exit( 1 );
}
38 changes: 38 additions & 0 deletions .github/workflows/wp-tests-phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: WordPress Tests

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: WordPress PHPUnit Tests
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set UID and GID for PHP in WordPress images
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV

- name: Setup WordPress test environment
run: composer run wp-setup

- name: Start WordPress test environment
run: composer run wp-test-start

- name: Run WordPress PHPUnit tests
run: node .github/workflows/wp-tests-phpunit-run.js

- name: Stop Docker containers
if: always()
run: composer run wp-test-clean
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ composer.lock
._.DS_Store
.DS_Store
._*
/wordpress
4 changes: 2 additions & 2 deletions activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function ( $result ) {
* When the plugin gets merged in wp-core, this is not to be ported.
*/
function sqlite_plugin_copy_db_file() {
// Bail early if the SQLite3 class does not exist.
if ( ! class_exists( 'SQLite3' ) ) {
// Bail early if the PDO SQLite extension is not loaded.
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ function sqlite_plugin_admin_notice() {
return;
}

// If SQLite is not detected, bail early.
if ( ! class_exists( 'SQLite3' ) ) {
// If PDO SQLite is not loaded, bail early.
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
esc_html__( 'The SQLite Integration plugin is active, but the SQLite3 class is missing from your server. Please make sure that SQLite is enabled in your PHP installation.', 'sqlite-database-integration' )
esc_html__( 'The SQLite Integration plugin is active, but the PDO SQLite extension is missing from your server. Please make sure that PDO SQLite is enabled in your PHP installation.', 'sqlite-database-integration' )
);
return;
}
Expand Down
9 changes: 3 additions & 6 deletions admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ function sqlite_integration_admin_screen() {
?>
</p>
<?php else : ?>
<?php if ( ! class_exists( 'SQLite3' ) ) : ?>
<div class="notice notice-error">
<p><?php esc_html_e( 'We detected that the SQLite3 class is missing from your server. Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
</div>
<?php elseif ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
<?php if ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
<div class="notice notice-error">
<p><?php esc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
</div>
Expand Down Expand Up @@ -130,7 +126,8 @@ function sqlite_plugin_adminbar_item( $admin_bar ) {
global $wpdb;

if ( defined( 'SQLITE_DB_DROPIN_VERSION' ) && defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ) {
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'sqlite-database-integration' ) . '</span>';
$suffix = defined( 'WP_SQLITE_AST_DRIVER' ) && WP_SQLITE_AST_DRIVER ? ' (AST)' : '';
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'sqlite-database-integration' ) . $suffix . '</span>';
} elseif ( stripos( $wpdb->db_server_info(), 'maria' ) !== false ) {
$title = '<span style="color:#DC3232;">' . __( 'Database: MariaDB', 'sqlite-database-integration' ) . '</span>';
} else {
Expand Down
23 changes: 21 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"issues": "https://github.com/wordpress/sqlite-database-integration/issues"
},
"require": {
"php": ">=7.0"
"php": ">=7.2",
"ext-pdo": "*",
"ext-pdo_sqlite": "*"
},
"require-dev": {
"ext-mbstring": "*",
Expand All @@ -24,7 +26,8 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"process-timeout": 3600
},
"scripts": {
"check-cs": [
Expand All @@ -35,6 +38,22 @@
],
"test": [
"phpunit"
],
"wp-setup": [
"./wp-setup.sh"
],
"wp-run": [
"npm --prefix wordpress run"
],
"wp-test-start": [
"npm --prefix wordpress run env:start",
"npm --prefix wordpress run env:install"
],
"wp-test-phpunit": [
"npm --prefix wordpress run test:php --"
],
"wp-test-clean": [
"npm --prefix wordpress run env:clean"
]
}
}
5 changes: 5 additions & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@
define( 'FQDB', FQDBDIR . '.ht.sqlite' );
}
}

// Allow enabling the SQLite AST driver via environment variable.
if ( ! defined( 'WP_SQLITE_AST_DRIVER' ) && isset( $_ENV['WP_SQLITE_AST_DRIVER'] ) && 'true' === $_ENV['WP_SQLITE_AST_DRIVER'] ) {
define( 'WP_SQLITE_AST_DRIVER', true );
}
Loading