litespeedtech / litespeedtech/lscache_wp

PHP warning from `wp_parse_url()` in `LiteSpeed\REST::is_rest()`

Open
#569 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
257
Forks
123
PR merge metrics
No merged PRs in 30d

Description

In LSCWP 5.5.0.

> PHP Warning: Trying to access array offset on value of type bool in plugins/litespeed-cache/src/rest.cls.php on line 328

The `wp_parse_url()` function is returning `false` under certain circumstances in `LiteSpeed\REST::is_rest()` (I am unaware what the faulty URL is).

Given that `false` is an expected return type from WordPress' function, we've patched it in project like so:

```diff
$current_url = wp_parse_url( $url );
// Debug2::debug( '[Util] is_rest check [base] ', $rest_url );
// Debug2::debug( '[Util] is_rest check [curr] ', $current_url );
// Debug2::debug( '[Util] is_rest check [curr2] ', wp_parse_url( add_query_arg( array( ) ) ) );
+ if ( ! $current_url ) {
+ return false;
+ }
return strpos( $current_url[ 'path' ], $rest_url[ 'path' ] ) === 0;
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in plugins/litespeed-cache/src/rest.cls.php at line 328, in LiteSpeed\REST::is_rest(), and inspect how the wp_parse_url() result is used. Verify the WordPress return contract and reproduce or review the reported false case; done means the REST check handles that result without a PHP warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
api, backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.