Skip to content

Commit 0c6699f

Browse files
committed
Fix PHP < 8.0 compatibility issues
1 parent 3733bad commit 0c6699f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

wp-includes/sqlite-ast/class-wp-pdo-proxy-statement.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ trait WP_PDO_Proxy_Statement_PHP_Compat {
3535
* @return bool True on success, false on failure.
3636
*/
3737
public function setFetchMode( $mode, $params = null ): bool {
38+
// Do not pass additional arguments when they are NULL to prevent
39+
// "fetch mode doesn't allow any extra arguments" error.
40+
if ( null === $params ) {
41+
return $this->setDefaultFetchMode( $mode );
42+
}
3843
return $this->setDefaultFetchMode( $mode, $params );
3944
}
4045

@@ -47,6 +52,11 @@ public function setFetchMode( $mode, $params = null ): bool {
4752
* @return array The result set as an array of rows.
4853
*/
4954
public function fetchAll( $mode = null, $class_name = null, $constructor_args = null ): array {
55+
// Do not pass additional arguments when they are NULL to prevent
56+
// "Extraneous additional parameters" error.
57+
if ( null === $class_name && null === $constructor_args ) {
58+
return $this->fetchAllRows( $mode );
59+
}
5060
return $this->fetchAllRows( $mode, $class_name, $constructor_args );
5161
}
5262
}

0 commit comments

Comments
 (0)