Repository navigation
Releases
Releases · nanasess/MDB2
v2.6.0
Highlights
Security fixes
matchPattern(): Escape the LIKE wildcards before the string, not after. The old order escaped the escape characters added for the string: on mysqli a pattern containing'ended the string literal, and on pgsql a literal%or_acted as a wildcard (#18)decimal/float: These values are written into the query unquoted, so a value that is not a valid number (e.g.1--) now returnsMDB2_ERROR_INVALID_NUMBER(#18)- NUL bytes: pgsql and sqlite3 return
MDB2_ERROR_INVALIDfor a string containing a NUL byte instead of silently truncating it at that byte (#18) - LOB values: A
clob/blobvalue that looks like a URL is only opened whenlob_allow_url_includeis enabled (the default is disabled). Before, prepared statements on pgsql opened it whatever the option said (#18) loadClass()/loadFile(): Only accept[A-Za-z0-9_](and/forloadFile()), since the name (e.g. thephptypeof a DSN) becomes a file path (#18)- pgsql
setLimit()with UPDATE / DELETE: Find theWHEREclause outside string literals, identifiers, comments and parentheses, and match the rows by(tableoid, ctid). A quoted value containingwhere ... --could otherwise widen the statement to every row, and rows of inherited tables could be updated or deleted by mistake (#19, #21)
Bug fixes
- pgsql: Map
timetz(TIME WITH TIME ZONE) to the MDB2timetype (#17, #20) - pgsql:
setLimit()with UPDATE / DELETE no longer throws aTypeErroron PHP 8, and no longer drops theSETclause on PHP 7 (#19, #21) setLimit(): Ignore string literals, delimited identifiers and comments when checking whether the query already has aLIMITclause, so a value such as'LIMIT 1'no longer stops the limit from being applied (#18)- Multibyte charsets: With Shift_JIS, CP932, GBK, Big5 or GB18030 connections, the query is read character by character, so a second byte of 0x5C is not taken for a backslash (#22)
Behavior changes
These inputs used to be accepted and now return an MDB2_Error:
| Input | Before | After |
|---|---|---|
quote('1-1', 'decimal'), quote('abc', 'float'), ... |
unquoted 1-1, empty string |
MDB2_ERROR_INVALID_NUMBER |
a string with a NUL byte on pgsql / sqlite3 (including sqlite3 blob) |
truncated at the NUL byte | MDB2_ERROR_INVALID |
a clob / blob URL that cannot be opened, with lob_allow_url_include enabled |
empty value | MDB2_ERROR_NOT_FOUND |
phptype with characters other than [A-Za-z0-9_] |
include attempted | MDB2_ERROR_NOT_FOUND |
query(), exec() and standaloneQuery() now connect before rewriting the query for setLimit(), so a connection error is returned before anything else is done.
Known issues
- pgsql
setLimit()with UPDATE / DELETE: A statement that cannot be parsed (e.g. a quoted table name orDELETE FROM ONLY t) is still run without the limit. - PHP 7.4 and Big5 on mysqli: The mysqlnd of PHP 7.4 does not take
0xA1 0x5Cfor one Big5 character, somysqli_real_escape_string()itself produces a string the server reads differently. This is a PHP issue and also affects 2.5.2. Use a different charset (e.g. utf8mb4) or a newer PHP. - The untested drivers (
mysql,mssql,oci8, ...) do not get these fixes.
What's Changed
- fix: harden quoting and LOB handling by @nanasess in #18
- fix: map PostgreSQL timetz to the MDB2 time type by @nanasess in #20
- fix: make setLimit() work with UPDATE / DELETE on pgsql by @nanasess in #21
- fix: read literals in the multibyte charset of the connection by @nanasess in #22
Full Changelog: 2.5.2...2.6.0
v2.5.2
Highlights
Bug fixes
- pgsql: Support
PgSql\Connection/PgSql\Resultobjects returned on PHP 8.1+ (#7, #8) - pgsql: Fix
getTableConstraintDefinition()/tableInfo()failing on PostgreSQL 12+ (#11) - mysqli: Return an MDB2_Error instead of throwing
mysqli_sql_exceptionon SQL and connection errors on PHP 8.1+ (#10) - sqlite3: Map native errors to MDB2 error codes. This also fixes
nextID()failing to create sequences on demand on PHP 8 (#9) - sqlite3: Fix
listTableFields()droppingREALcolumns and columns declared with an inlineUNIQUEconstraint (#6, #12) - sqlite3: Fix
tableInfo()failing on tables with an inlinePRIMARY KEY(#13) - sqlite3: Fix
alterTable()re-creatingDECIMAL(p,s)columns asDECIMAL(p,s,s)(#14)
Behavior change
- On PHP 8.1+, the mysqli driver no longer throws
mysqli_sql_exceptionon SQL errors. As with the other drivers, check the returned MDB2_Error instead. Themysqli_report()setting is left unchanged.
Other
- Add a PHPUnit test suite and GitHub Actions CI (PHP 7.4–8.5 × PostgreSQL / MySQL / SQLite3) (#15)
What's Changed
- fix: Add REAL type to SQLite column type regex in _getTableColumns by @nobuhiko in #6
- Support PgSql\Connection objects in pgsql driver (PHP 8.1+) by @seasoftjapan in #7
- fix: Support PgSql\Result objects in pgsql driver (PHP 8.1+) by @nanasess in #8
- test: Add unit tests and CI for pgsql/mysqli/sqlite3 by @nanasess in #15
- fix: Fix known bugs found by the tests (#9–#14) by @nanasess in #16
New Contributors
- @nobuhiko made their first contribution in #6
- @seasoftjapan made their first contribution in #7
Full Changelog: 2.5.1...2.5.2