@@ -767,6 +767,7 @@ class WP_MySQL_On_SQLite extends PDO {
767767 * Optional driver options.
768768 *
769769 * Numeric keys are handled as standard PDO constructor options.
770+ * Driver-specific PDO options are not supported.
770771 *
771772 * @type int $mysql_version Optional. MySQL version to emulate. Default 80038.
772773 * @type PDO|null $pdo Optional. Existing SQLite PDO connection.
@@ -832,10 +833,17 @@ function ( $key ) {
832833 ARRAY_FILTER_USE_KEY
833834 );
834835
836+ $ connection_pdo_options = array ();
837+ if ( array_key_exists ( PDO ::ATTR_PERSISTENT , $ pdo_options ) ) {
838+ // Persistence is connection-time-only. Do not apply it again after initialization.
839+ $ connection_pdo_options [ PDO ::ATTR_PERSISTENT ] = $ pdo_options [ PDO ::ATTR_PERSISTENT ];
840+ unset( $ pdo_options [ PDO ::ATTR_PERSISTENT ] );
841+ }
842+
835843 $ connection_options = array (
836844 'journal_mode ' => $ options ['journal_mode ' ] ?? null ,
837845 'synchronous ' => $ options ['synchronous ' ] ?? null ,
838- 'pdo_options ' => $ pdo_options ,
846+ 'pdo_options ' => $ connection_pdo_options ,
839847 );
840848 if ( isset ( $ options ['pdo ' ] ) ) {
841849 $ connection_options ['pdo ' ] = $ options ['pdo ' ];
@@ -935,11 +943,6 @@ function ( string $sql, array $params ) {
935943 );
936944
937945 foreach ( $ pdo_options as $ attribute => $ value ) {
938- // Persistence is a connection-time-only option and was already passed
939- // to the underlying PDO constructor when creating a new connection.
940- if ( PDO ::ATTR_PERSISTENT === $ attribute ) {
941- continue ;
942- }
943946 $ this ->setAttribute ( $ attribute , $ value );
944947 }
945948 }
@@ -1383,6 +1386,12 @@ public function inTransaction(): bool {
13831386 * @return bool True on success, false on failure.
13841387 */
13851388 public function setAttribute ( $ attribute , $ value ): bool {
1389+ // PDO reserves IDs starting at 1000 for driver-specific attributes.
1390+ // These differ for MySQL and SQLite and are currently not supported.
1391+ if ( is_int ( $ attribute ) && 1000 <= $ attribute ) {
1392+ return false ;
1393+ }
1394+
13861395 // Track the caller's error mode while keeping internal SQLite operations in exception mode.
13871396 if ( PDO ::ATTR_ERRMODE === $ attribute ) {
13881397 $ pdo = $ this ->connection ->get_pdo ();
0 commit comments