' . PHP_EOL;
+ $output .= '
' . PHP_EOL;
$output .= '
MySQL query:
' . PHP_EOL;
$output .= '
' . $this->mysql_query . '
' . PHP_EOL;
$output .= '
Queries made or created this session were:
' . PHP_EOL;
@@ -2949,13 +3417,12 @@ public function get_error_message() {
$output .= '' . PHP_EOL;
$output .= '
' . PHP_EOL;
foreach ( $this->error_messages as $num => $m ) {
- $output .= '
' . PHP_EOL;
+ $output .= '
' . PHP_EOL;
$output .= sprintf(
'Error occurred at line %1$d in Function %2$s. Error message was: %3$s.',
- (int) $this->errors[ $num ]['line'],
+ (int) $this->errors[ $num ]['line'],
'' . htmlspecialchars( $this->errors[ $num ]['function'] ) . '
',
- $m
- ) . PHP_EOL;
+ $m ) . PHP_EOL;
$output .= '
' . PHP_EOL;
}
@@ -2963,14 +3430,14 @@ public function get_error_message() {
throw new Exception();
} catch ( Exception $e ) {
$output .= '
Backtrace:
' . PHP_EOL;
- $output .= '
' . htmlspecialchars( $e->getTraceAsString() ) . '
' . PHP_EOL;
+ $output .= '
' . $e->getTraceAsString() . '
' . PHP_EOL;
}
return $output;
}
/**
- * Executes a query in SQLite – for internal use only.
+ * Executes a query in SQLite.
*
* @param mixed $sql The query to execute.
* @param mixed $params The parameters to bind to the query.
@@ -2982,14 +3449,27 @@ public function get_error_message() {
* @type * $result The value returned by $stmt.
* }
*/
- private function execute_sqlite_query( $sql, $params = array() ) {
+ public function execute_sqlite_query( $sql, $params = array() ) {
$this->executed_sqlite_queries[] = array(
'sql' => $sql,
'params' => $params,
);
- $stmt = $this->pdo->prepare( $sql );
- $this->last_exec_returned = $stmt->execute( $params );
+ $stmt = $this->pdo->prepare( $sql );
+ if ( false === $stmt || null === $stmt ) {
+ $this->last_exec_returned = null;
+ $info = $this->pdo->errorInfo();
+ $this->last_sqlite_error = $info[0] . ' ' . $info[2];
+ throw new PDOException( implode( ' ', array( 'Error:', $info[0], $info[2], 'SQLite:', $sql ) ), $info[1] );
+ }
+ $returned = $stmt->execute( $params );
+ $this->last_exec_returned = $returned;
+ if ( ! $returned ) {
+ $info = $stmt->errorInfo();
+ $this->last_sqlite_error = $info[0] . ' ' . $info[2];
+ throw new PDOException( implode( ' ', array( 'Error:', $info[0], $info[2], 'SQLite:', $sql ) ), $info[1] );
+ }
+
return $stmt;
}
@@ -3025,18 +3505,21 @@ private function set_result_from_affected_rows( $override = null ) {
* Method to clear previous data.
*/
private function flush() {
- $this->mysql_query = '';
- $this->results = null;
- $this->last_exec_returned = null;
- $this->last_insert_id = null;
- $this->affected_rows = null;
- $this->column_data = array();
- $this->num_rows = null;
- $this->return_value = null;
- $this->error_messages = array();
- $this->is_error = false;
- $this->executed_sqlite_queries = array();
- $this->last_exec_returned = null;
+ $this->mysql_query = '';
+ $this->results = null;
+ $this->last_exec_returned = null;
+ $this->last_insert_id = null;
+ $this->affected_rows = null;
+ $this->column_data = array();
+ $this->num_rows = null;
+ $this->return_value = null;
+ $this->error_messages = array();
+ $this->is_error = false;
+ $this->executed_sqlite_queries = array();
+ $this->like_expression_nesting = 0;
+ $this->like_escape_count = 0;
+ $this->is_information_schema_query = false;
+ $this->has_group_by = false;
}
/**
diff --git a/wp-includes/sqlite/install-functions.php b/wp-includes/sqlite/install-functions.php
index 1233c6b6..736034ca 100644
--- a/wp-includes/sqlite/install-functions.php
+++ b/wp-includes/sqlite/install-functions.php
@@ -40,9 +40,9 @@ function sqlite_make_db_sqlite() {
continue;
}
- $result = $translator->query($query);
- if( false === $result ) {
- throw new PDOException($translator->get_error_message());
+ $result = $translator->query( $query );
+ if ( false === $result ) {
+ throw new PDOException( $translator->get_error_message() );
}
}
$translator->commit();