Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS: remove unnecessary ignore annotations [2] (Trac 59650) #5518

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 36 additions & 40 deletions src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2910,31 +2910,29 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
*/

// Extract type, name and columns from the definition.
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
preg_match(
'/^'
. '(?P<index_type>' // 1) Type of the index.
. 'PRIMARY\s+KEY|(?:UNIQUE|FULLTEXT|SPATIAL)\s+(?:KEY|INDEX)|KEY|INDEX'
. ')'
. '\s+' // Followed by at least one white space character.
. '(?:' // Name of the index. Optional if type is PRIMARY KEY.
. '`?' // Name can be escaped with a backtick.
. '(?P<index_name>' // 2) Name of the index.
. '(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+'
. ')'
. '`?' // Name can be escaped with a backtick.
. '\s+' // Followed by at least one white space character.
. ')*'
. '\(' // Opening bracket for the columns.
. '(?P<index_columns>'
. '.+?' // 3) Column names, index prefixes, and orders.
. ')'
. '\)' // Closing bracket for the columns.
. '$/im',
'/^
(?P<index_type> # 1) Type of the index.
PRIMARY\s+KEY|(?:UNIQUE|FULLTEXT|SPATIAL)\s+(?:KEY|INDEX)|KEY|INDEX
)
\s+ # Followed by at least one white space character.
(?: # Name of the index. Optional if type is PRIMARY KEY.
`? # Name can be escaped with a backtick.
(?P<index_name> # 2) Name of the index.
(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+
)
`? # Name can be escaped with a backtick.
\s+ # Followed by at least one white space character.
)*
\( # Opening bracket for the columns.
(?P<index_columns>
.+? # 3) Column names, index prefixes, and orders.
)
\) # Closing bracket for the columns.
$/imx',
$fld,
$index_matches
);
// phpcs:enable

// Uppercase the index type and normalize space characters.
$index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) );
Expand All @@ -2952,29 +2950,27 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// Normalize columns.
foreach ( $index_columns as $id => &$index_column ) {
// Extract column name and number of indexed characters (sub_part).
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
preg_match(
'/'
. '`?' // Name can be escaped with a backtick.
. '(?P<column_name>' // 1) Name of the column.
. '(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+'
. ')'
. '`?' // Name can be escaped with a backtick.
. '(?:' // Optional sub part.
. '\s*' // Optional white space character between name and opening bracket.
. '\(' // Opening bracket for the sub part.
. '\s*' // Optional white space character after opening bracket.
. '(?P<sub_part>'
. '\d+' // 2) Number of indexed characters.
. ')'
. '\s*' // Optional white space character before closing bracket.
. '\)' // Closing bracket for the sub part.
. ')?'
. '/',
'/
`? # Name can be escaped with a backtick.
(?P<column_name> # 1) Name of the column.
(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+
)
`? # Name can be escaped with a backtick.
(?: # Optional sub part.
\s* # Optional white space character between name and opening bracket.
\( # Opening bracket for the sub part.
\s* # Optional white space character after opening bracket.
(?P<sub_part>
\d+ # 2) Number of indexed characters.
)
\s* # Optional white space character before closing bracket.
\) # Closing bracket for the sub part.
)?
/x',
$index_column,
$index_column_matches
);
// phpcs:enable

// Escape the column name with backticks.
$index_column = '`' . $index_column_matches['column_name'] . '`';
Expand Down
Loading