Skip to content

Releases

v2.6.0

Choose a tag to compare

@nanasess nanasess released this 18 Nov 12:07
866c15f

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 returns MDB2_ERROR_INVALID_NUMBER (#18)
  • NUL bytes: pgsql and sqlite3 return MDB2_ERROR_INVALID for a string containing a NUL byte instead of silently truncating it at that byte (#18)
  • LOB values: A clob / blob value that looks like a URL is only opened when lob_allow_url_include is 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 / for loadFile()), since the name (e.g. the phptype of a DSN) becomes a file path (#18)
  • pgsql setLimit() with UPDATE / DELETE: Find the WHERE clause outside string literals, identifiers, comments and parentheses, and match the rows by (tableoid, ctid). A quoted value containing where ... -- 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 MDB2 time type (#17, #20)
  • pgsql: setLimit() with UPDATE / DELETE no longer throws a TypeError on PHP 8, and no longer drops the SET clause on PHP 7 (#19, #21)
  • setLimit(): Ignore string literals, delimited identifiers and comments when checking whether the query already has a LIMIT clause, 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 or DELETE 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 0x5C for one Big5 character, so mysqli_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

Choose a tag to compare

@nanasess nanasess released this 09 Oct 08:14
c8f7688

Highlights

Bug fixes

  • pgsql: Support PgSql\Connection / PgSql\Result objects 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_exception on 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() dropping REAL columns and columns declared with an inline UNIQUE constraint (#6, #12)
  • sqlite3: Fix tableInfo() failing on tables with an inline PRIMARY KEY (#13)
  • sqlite3: Fix alterTable() re-creating DECIMAL(p,s) columns as DECIMAL(p,s,s) (#14)

Behavior change

  • On PHP 8.1+, the mysqli driver no longer throws mysqli_sql_exception on SQL errors. As with the other drivers, check the returned MDB2_Error instead. The mysqli_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

Full Changelog: 2.5.1...2.5.2

v2.5.1

Choose a tag to compare

@nanasess nanasess released this 08 Oct 03:06
7bec1c1

What's Changed

  • Update MDB2.php … PHP 8.3でのWarning対応2($loaded_version_modules) by @sf-habu in #5
  • Update MDB2.php … PHP 8.3でのWarning対応($positions) by @sf-habu in #4

New Contributors

Full Changelog: 2.5.0...2.5.1

v2.5.0

Choose a tag to compare

@nanasess nanasess released this 11 Apr 07:13
4f079c7
  • packagist support
  • PHP8 support