Skip to content

Commit 6cdf6d1

Browse files
committed
Use PDO\Sqlite::createFunction() instead of deprecated PDO::sqliteCreateFunction()
1 parent 1047bda commit 6cdf6d1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

wp-includes/sqlite/class-wp-sqlite-pdo-user-defined-functions.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ class WP_SQLite_PDO_User_Defined_Functions {
2626
* Registers the user defined functions for SQLite to a PDO instance.
2727
* The functions are registered using PDO::sqliteCreateFunction().
2828
*
29-
* @param PDO $pdo The PDO object.
29+
* @param PDO|PDO\SQLite $pdo The PDO object.
3030
*/
31-
public static function register_for( PDO $pdo ): self {
31+
public static function register_for( $pdo ): self {
3232
$instance = new self();
3333
foreach ( $instance->functions as $f => $t ) {
34-
$pdo->sqliteCreateFunction( $f, array( $instance, $t ) );
34+
if ( $pdo instanceof PDO\SQLite ) {
35+
$pdo->createFunction( $f, array( $instance, $t ) );
36+
} else {
37+
$pdo->sqliteCreateFunction( $f, array( $instance, $t ) );
38+
}
3539
}
3640
return $instance;
3741
}

0 commit comments

Comments
 (0)