Skip to content

Commit 5a2576b

Browse files
authored
Fix PHP 8 issue with strtoupper() (#132)
Fixes #54
1 parent 2ceb315 commit 5a2576b

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function matches( $type = null, $flags = null, $values = null ) {
218218
return (
219219
( null === $type || $this->type === $type )
220220
&& ( null === $flags || ( $this->flags & $flags ) )
221-
&& ( null === $values || in_array( strtoupper( $this->value ), $values, true ) )
221+
&& ( null === $values || in_array( strtoupper( $this->value ?? '' ), $values, true ) )
222222
);
223223
}
224224

@@ -241,7 +241,7 @@ public function is_semantically_void() {
241241
private function extract() {
242242
switch ( $this->type ) {
243243
case self::TYPE_KEYWORD:
244-
$this->keyword = strtoupper( $this->token );
244+
$this->keyword = strtoupper( $this->token ?? '' );
245245
if ( ! ( $this->flags & self::FLAG_KEYWORD_RESERVED ) ) {
246246
/*
247247
* Unreserved keywords should stay the way they are
@@ -256,7 +256,7 @@ private function extract() {
256256
return ' ';
257257

258258
case self::TYPE_BOOL:
259-
return strtoupper( $this->token ) === 'TRUE';
259+
return strtoupper( $this->token ?? '' ) === 'TRUE';
260260

261261
case self::TYPE_NUMBER:
262262
$ret = str_replace( '--', '', $this->token ); // e.g. ---42 === -42.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ private function skip_index_hint() {
15531553
array( 'JOIN', 'ORDER', 'GROUP' )
15541554
) ) {
15551555
$this->rewriter->skip(); // JOIN, ORDER, GROUP.
1556-
if ( 'BY' === strtoupper( $this->rewriter->peek()->value ) ) {
1556+
if ( 'BY' === strtoupper( $this->rewriter->peek()->value ?? '' ) ) {
15571557
$this->rewriter->skip(); // BY.
15581558
}
15591559
}
@@ -1575,7 +1575,7 @@ private function skip_index_hint() {
15751575
*/
15761576
private function execute_truncate() {
15771577
$this->rewriter->skip(); // TRUNCATE.
1578-
if ( 'TABLE' === strtoupper( $this->rewriter->peek()->value ) ) {
1578+
if ( 'TABLE' === strtoupper( $this->rewriter->peek()->value ?? '' ) ) {
15791579
$this->rewriter->skip(); // TABLE.
15801580
}
15811581
$this->rewriter->add( new WP_SQLite_Token( 'DELETE', WP_SQLite_Token::TYPE_KEYWORD ) );
@@ -2042,7 +2042,7 @@ private function skip_from_dual( $token ) {
20422042
return false;
20432043
}
20442044
$from_table = $this->rewriter->peek_nth( 2 )->value;
2045-
if ( 'DUAL' !== strtoupper( $from_table ) ) {
2045+
if ( 'DUAL' !== strtoupper( $from_table ?? '' ) ) {
20462046
return false;
20472047
}
20482048

@@ -2564,7 +2564,7 @@ private function capture_group_by( $token ) {
25642564
return false;
25652565
}
25662566
$next = $this->rewriter->peek_nth( 2 )->value;
2567-
if ( 'BY' !== strtoupper( $next ) ) {
2567+
if ( 'BY' !== strtoupper( $next ?? '' ) ) {
25682568
return false;
25692569
}
25702570

@@ -2915,8 +2915,8 @@ private function execute_alter() {
29152915
new WP_SQLite_Token( $this->table_name, WP_SQLite_Token::TYPE_KEYWORD ),
29162916
)
29172917
);
2918-
$op_type = strtoupper( $this->rewriter->consume()->token );
2919-
$op_subject = strtoupper( $this->rewriter->consume()->token );
2918+
$op_type = strtoupper( $this->rewriter->consume()->token ?? '' );
2919+
$op_subject = strtoupper( $this->rewriter->consume()->token ?? '' );
29202920
$mysql_index_type = $this->normalize_mysql_index_type( $op_subject );
29212921
$is_index_op = (bool) $mysql_index_type;
29222922

@@ -3251,8 +3251,8 @@ private function execute_drop() {
32513251
*/
32523252
private function execute_show() {
32533253
$this->rewriter->skip();
3254-
$what1 = strtoupper( $this->rewriter->consume()->token );
3255-
$what2 = strtoupper( $this->rewriter->consume()->token );
3254+
$what1 = strtoupper( $this->rewriter->consume()->token ?? '' );
3255+
$what2 = strtoupper( $this->rewriter->consume()->token ?? '' );
32563256
$what = $what1 . ' ' . $what2;
32573257
switch ( $what ) {
32583258
case 'CREATE PROCEDURE':

0 commit comments

Comments
 (0)