Skip to content

Commit e77132d

Browse files
committed
CS fixes
1 parent b6a3363 commit e77132d

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

wp-includes/sqlite/class-wp-sqlite-translator.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public function __construct( $pdo = null ) {
320320
new WP_SQLite_PDO_User_Defined_Functions( $pdo );
321321

322322
// MySQL data comes across stringified by default.
323-
$pdo->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
323+
$pdo->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true ); // phpcs:ignore WordPress.DB.RestrictedClasses.mysql__PDO
324324
$pdo->query( WP_SQLite_Translator::CREATE_DATA_TYPES_CACHE_TABLE );
325325

326326
$this->pdo = $pdo;
@@ -1078,11 +1078,13 @@ private function is_create_table_field_terminator( $token, $definition_depth, $c
10781078

10791079
/**
10801080
* Executes a DELETE statement.
1081+
*
1082+
* @throws Exception If the table could not be found.
10811083
*/
10821084
private function execute_delete() {
1083-
$this->rewriter->consume(); // DELETE
1085+
$this->rewriter->consume(); // DELETE.
10841086

1085-
// Process expressions and extract bound parameters
1087+
// Process expressions and extract bound parameters.
10861088
$params = array();
10871089
while ( true ) {
10881090
$token = $this->rewriter->peek();
@@ -1105,7 +1107,7 @@ private function execute_delete() {
11051107

11061108
$updated_query = $this->rewriter->get_updated_query();
11071109

1108-
// Perform DELETE-specific translations
1110+
// Perform DELETE-specific translations.
11091111

11101112
// Naive rewriting of DELETE JOIN query.
11111113
// @TODO: Actually rewrite the query instead of using a hardcoded workaround.
@@ -1235,7 +1237,7 @@ private function execute_delete() {
12351237
* Executes a SELECT statement.
12361238
*/
12371239
private function execute_select() {
1238-
$this->rewriter->consume(); // SELECT
1240+
$this->rewriter->consume(); // SELECT.
12391241

12401242
$params = array();
12411243
$table_name = null;
@@ -1340,6 +1342,8 @@ private function execute_truncate() {
13401342

13411343
/**
13421344
* Executes a DESCRIBE statement.
1345+
*
1346+
* @throws PDOException When the table is not found.
13431347
*/
13441348
private function execute_describe() {
13451349
$this->rewriter->skip();
@@ -1392,7 +1396,7 @@ private function execute_describe() {
13921396
* Executes an UPDATE statement.
13931397
*/
13941398
private function execute_update() {
1395-
$this->rewriter->consume(); // UPDATE
1399+
$this->rewriter->consume(); // Update.
13961400

13971401
$params = array();
13981402
while ( true ) {
@@ -1760,6 +1764,7 @@ private function translate_concat_function( $token ) {
17601764
) {
17611765
return false;
17621766
}
1767+
17631768
/*
17641769
* Skip the CONCAT function but leave the parentheses.
17651770
* There is another code block below that replaces the
@@ -1827,7 +1832,6 @@ private function translate_date_add_sub( $token ) {
18271832
* Translate VALUES() function.
18281833
*
18291834
* @param WP_SQLite_Token $token The token to translate.
1830-
* @param bool $is_in_duplicate_section Whether the VALUES() function is in a duplicate section.
18311835
*
18321836
* @return bool
18331837
*/
@@ -2232,7 +2236,6 @@ private function get_sqlite_create_table( $table_name ) {
22322236
* Translate ALTER query.
22332237
*
22342238
* @throws Exception If the subject is not 'table', or we're performing an unknown operation.
2235-
*
22362239
*/
22372240
private function execute_alter() {
22382241
$this->rewriter->consume();
@@ -2993,6 +2996,11 @@ private function execute_sqlite_query( $sql, $params = array() ) {
29932996
return $stmt;
29942997
}
29952998

2999+
/**
3000+
* Method to set the results from the fetched data.
3001+
*
3002+
* @param array $data The data to set.
3003+
*/
29963004
private function set_results_from_fetched_data( $data ) {
29973005
if ( null === $this->results ) {
29983006
$this->results = $data;
@@ -3004,6 +3012,11 @@ private function set_results_from_fetched_data( $data ) {
30043012
$this->return_value = $this->results;
30053013
}
30063014

3015+
/**
3016+
* Method to set the results from the affected rows.
3017+
*
3018+
* @param int|null $override Override the affected rows.
3019+
*/
30073020
private function set_result_from_affected_rows( $override = null ) {
30083021
/*
30093022
* SELECT CHANGES() is a workaround for the fact that

wp-includes/sqlite/install-functions.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* @since 1.0.0
1515
*
1616
* @return boolean
17+
*
18+
* @throws PDOException If the database connection fails.
1719
*/
1820
function sqlite_make_db_sqlite() {
1921
include_once ABSPATH . 'wp-admin/includes/schema.php';
@@ -40,9 +42,9 @@ function sqlite_make_db_sqlite() {
4042
continue;
4143
}
4244

43-
$result = $translator->query($query);
44-
if( false === $result ) {
45-
throw new PDOException($translator->get_error_message());
45+
$result = $translator->query( $query );
46+
if ( false === $result ) {
47+
throw new PDOException( $translator->get_error_message() );
4648
}
4749
}
4850
$translator->commit();
@@ -73,7 +75,7 @@ function sqlite_make_db_sqlite() {
7375
$port = $host_parts[1];
7476
}
7577
$dsn = 'mysql:host=' . $host . '; port=' . $port . '; dbname=' . DB_NAME;
76-
$pdo_mysql = new PDO( $dsn, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) );
78+
$pdo_mysql = new PDO( $dsn, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); // phpcs:ignore WordPress.DB.RestrictedClasses.mysql__PDO
7779
$pdo_mysql->query( 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' );
7880
$pdo_mysql->query( 'SET time_zone = "+00:00";' );
7981
foreach ( $queries as $query ) {

0 commit comments

Comments
 (0)