Sergey Biryukov
18bda14e1e
Code Modernization: Check the return type of parse_url() in WP::parse_request().
...
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.
Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]
In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`. This will return `null` in the majority of cases, as – exсept for subdirectory-based sites – `home_url()` returns a URL without the trailing slash, like `http://example.org `.
The return value of `parse_url()` was subsequently passed to `trim()`, leading to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.
Fixed by adjusting the logic flow to:
* Only pass the return value of `parse_url()` to follow-on functions if it makes sense, i.e. if it isn't `null`, nor an empty string.
* Preventing calls to `preg_replace()` and `trim()` further down in the function logic flow, when `preg_replace()`/`trim()` would have nothing to do anyhow.
Follow-up to [25617].
Props jrf, hellofromTonya, SergeyBiryukov.
See #53635 .
git-svn-id: https://develop.svn.wordpress.org/trunk@51622 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 20:16:13 +00:00
..
2021-07-15 18:53:34 +00:00
2021-07-15 18:53:34 +00:00
2021-07-01 21:28:38 +00:00
2021-07-28 10:05:01 +00:00
2020-08-01 14:07:29 +00:00
2021-07-19 00:40:49 +00:00
2021-08-03 12:17:54 +00:00
2020-07-17 17:09:37 +00:00
2021-04-14 23:08:25 +00:00
2020-05-21 09:08:52 +00:00
2021-05-24 02:17:36 +00:00
2021-08-10 13:44:34 +00:00
2021-06-16 17:01:39 +00:00
2021-07-06 13:51:05 +00:00
2021-05-11 19:40:41 +00:00
2021-08-03 11:07:28 +00:00
2020-10-16 17:18:11 +00:00
2021-03-20 18:28:32 +00:00
2021-08-10 13:03:41 +00:00
2020-10-18 17:31:37 +00:00
2020-07-03 23:40:45 +00:00
2021-07-13 05:57:04 +00:00
2021-05-10 18:22:56 +00:00
2020-10-17 15:43:39 +00:00
2021-06-21 06:05:30 +00:00
2021-08-15 12:44:26 +00:00
2021-08-11 09:06:31 +00:00
2021-07-02 14:34:24 +00:00
2021-07-01 21:11:48 +00:00
2021-07-02 21:51:54 +00:00
2021-08-11 09:06:31 +00:00
2020-11-24 12:27:49 +00:00
2021-05-20 00:03:04 +00:00
2020-06-10 09:55:56 +00:00
2020-11-24 21:25:46 +00:00
2021-06-08 23:31:46 +00:00
2021-03-04 00:12:55 +00:00
2021-07-03 21:41:02 +00:00
2020-07-23 21:53:43 +00:00
2021-07-01 21:28:38 +00:00
2020-11-12 11:15:49 +00:00
2021-05-25 18:46:39 +00:00
2020-07-21 12:56:40 +00:00
2020-05-01 20:10:58 +00:00
2021-06-06 14:04:52 +00:00
2020-10-16 17:18:11 +00:00
2021-01-26 13:44:42 +00:00
2020-05-01 19:05:04 +00:00
2020-10-17 16:03:58 +00:00
2020-10-17 16:03:58 +00:00
2021-05-05 18:53:54 +00:00
2021-05-07 09:45:40 +00:00
2021-05-07 09:45:40 +00:00
2020-08-19 02:44:38 +00:00
2020-06-28 14:00:26 +00:00
2021-07-19 21:13:36 +00:00
2021-05-24 07:37:22 +00:00
2021-08-03 11:11:45 +00:00
2021-02-02 05:14:46 +00:00
2021-06-15 15:21:50 +00:00
2021-06-15 15:21:50 +00:00
2021-06-15 15:21:50 +00:00
2021-01-28 02:01:50 +00:00
2021-05-25 14:19:14 +00:00
2021-06-15 15:21:50 +00:00
2021-07-28 10:05:01 +00:00
2021-07-28 10:05:01 +00:00
2021-07-30 19:34:39 +00:00
2021-01-03 22:02:13 +00:00
2021-07-30 19:34:39 +00:00
2021-07-30 19:34:39 +00:00
2021-05-30 19:16:30 +00:00
2021-07-30 19:34:39 +00:00
2021-07-30 19:34:39 +00:00
2021-07-30 19:34:39 +00:00
2021-07-13 18:01:58 +00:00
2021-07-30 19:34:39 +00:00
2020-07-23 00:46:56 +00:00
2021-07-10 23:57:43 +00:00
2021-06-17 14:35:59 +00:00
2020-10-09 22:28:54 +00:00
2021-06-05 15:45:10 +00:00
2020-11-12 14:34:33 +00:00
2021-08-03 11:00:50 +00:00
2020-07-23 07:37:57 +00:00
2020-10-08 21:13:57 +00:00
2021-01-15 20:06:50 +00:00
2021-01-03 22:02:13 +00:00
2020-06-26 18:38:51 +00:00
2021-07-01 21:11:48 +00:00
2021-07-01 21:01:17 +00:00
2021-07-01 21:01:17 +00:00
2021-07-15 00:41:44 +00:00
2021-07-15 17:38:57 +00:00
2021-05-28 18:03:06 +00:00
2020-11-12 14:41:19 +00:00
2020-09-18 10:35:41 +00:00
2020-10-08 21:13:57 +00:00
2021-07-30 19:34:39 +00:00
2021-01-03 21:55:04 +00:00
2021-07-30 19:34:39 +00:00
2021-01-03 22:02:13 +00:00
2020-11-24 21:20:36 +00:00
2021-06-15 10:23:57 +00:00
2021-01-03 22:02:13 +00:00
2020-06-20 11:16:12 +00:00
2020-12-10 23:57:29 +00:00
2020-11-09 15:13:56 +00:00
2021-07-30 10:52:39 +00:00
2020-08-11 00:32:22 +00:00
2021-04-04 18:28:59 +00:00
2020-06-19 22:53:54 +00:00
2021-02-22 19:16:07 +00:00
2020-08-11 00:32:22 +00:00
2021-07-30 19:34:39 +00:00
2020-07-23 00:50:57 +00:00
2021-07-30 19:34:39 +00:00
2020-08-12 15:03:50 +00:00
2021-05-15 17:36:49 +00:00
2020-10-10 20:00:30 +00:00
2021-07-30 19:34:39 +00:00
2021-02-20 17:08:24 +00:00
2020-07-14 12:08:28 +00:00
2021-02-01 11:53:16 +00:00
2021-07-30 19:34:39 +00:00
2020-12-10 23:51:52 +00:00
2021-01-27 21:52:10 +00:00
2021-08-11 09:06:31 +00:00
2021-08-03 18:13:46 +00:00
2021-08-02 22:30:04 +00:00
2021-01-08 14:28:46 +00:00
2020-03-23 20:18:15 +00:00
2021-03-04 00:12:55 +00:00
2021-06-22 19:07:26 +00:00
2021-06-23 01:33:20 +00:00
2021-06-04 10:46:22 +00:00
2021-08-10 12:52:48 +00:00
2021-08-16 20:16:13 +00:00
2020-05-06 16:25:09 +00:00
2021-07-30 19:34:39 +00:00
2021-07-30 19:34:39 +00:00
2021-07-03 21:41:02 +00:00
2021-04-02 15:47:34 +00:00
2021-07-22 13:06:55 +00:00
2021-08-16 15:22:38 +00:00
2020-10-20 02:02:37 +00:00
2021-07-09 01:17:41 +00:00
2021-05-25 08:26:21 +00:00
2021-08-10 19:43:33 +00:00
2021-07-01 21:01:17 +00:00
2020-11-03 17:34:20 +00:00
2020-02-09 16:52:28 +00:00
2021-03-20 18:28:32 +00:00
2020-07-23 19:04:38 +00:00
2021-05-15 17:36:49 +00:00
2021-08-13 15:49:10 +00:00
2021-08-11 09:06:31 +00:00
2021-06-15 15:21:50 +00:00
2020-06-17 10:14:36 +00:00
2021-08-10 13:44:34 +00:00
2020-10-08 21:13:57 +00:00
2021-05-15 17:36:49 +00:00
2021-02-02 00:08:01 +00:00
2021-08-05 12:58:45 +00:00
2021-08-11 09:06:31 +00:00
2021-06-30 17:43:29 +00:00
2021-07-06 20:20:51 +00:00
2021-08-04 14:23:18 +00:00
2021-06-24 20:54:43 +00:00
2021-07-03 21:31:13 +00:00
2020-10-17 16:03:58 +00:00
2020-06-20 12:38:55 +00:00
2020-07-05 11:19:35 +00:00
2020-11-19 18:22:02 +00:00
2021-07-06 20:20:51 +00:00
2021-07-28 10:00:51 +00:00
2020-10-18 20:52:01 +00:00
2020-10-18 17:25:10 +00:00
2020-05-16 18:40:52 +00:00
2021-06-19 20:55:52 +00:00
2021-01-03 22:02:13 +00:00
2021-07-01 21:28:38 +00:00
2021-07-03 11:31:00 +00:00
2021-07-01 21:28:38 +00:00
2021-05-04 15:00:33 +00:00
2020-11-24 21:25:46 +00:00
2021-04-26 15:36:55 +00:00
2021-02-08 14:12:21 +00:00
2021-07-14 08:12:24 +00:00
2021-06-15 15:21:50 +00:00
2020-11-12 11:15:49 +00:00
2020-11-12 11:15:49 +00:00
2021-06-30 12:33:43 +00:00
2021-07-03 21:41:02 +00:00
2020-11-19 16:13:54 +00:00
2021-03-23 23:00:03 +00:00
2020-11-16 22:50:03 +00:00
2021-01-04 17:16:43 +00:00
2021-08-05 13:10:05 +00:00
2021-06-15 15:21:50 +00:00
2021-05-15 17:36:49 +00:00
2020-11-12 11:15:49 +00:00
2021-07-03 21:41:02 +00:00
2021-05-25 14:19:14 +00:00
2020-05-26 09:35:34 +00:00
2021-05-25 14:19:14 +00:00
2021-05-24 08:36:11 +00:00
2021-06-22 09:58:32 +00:00
2021-08-03 18:13:46 +00:00
2021-08-07 13:53:58 +00:00
2021-05-17 17:02:49 +00:00
2021-07-13 00:02:00 +00:00
2020-10-08 21:13:57 +00:00
2021-06-30 03:54:44 +00:00
2021-07-09 10:56:49 +00:00
2021-08-08 14:08:15 +00:00