[wp-trac] [WordPress Trac] #57325: Fix the error 'Undefined array key' in 'wp-includes\class-requests.php' on line 214
WordPress Trac
noreply at wordpress.org
Wed Dec 14 02:24:50 UTC 2022
#57325: Fix the error 'Undefined array key' in 'wp-includes\class-requests.php' on
line 214
--------------------------+-----------------------------
Reporter: ilyachalov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I work on the 'Windows 10' operating system. I am using the 'IIS 10' web
server. I don't use solution stack packages like 'XAMPP', but install the
necessary programs separately: PHP interpreter version 8.1.10, DBMS
'MySQL' version 8.0.30.
I install the latest version of the 'WordPress' (6.1.1) locally to study
its operation on my computer in a directory {{{C:\inetpub\wwwroot\wp\}}}.
After installation, the 'WordPress' web application will be available in
the browser at the URL {{{http://localhost/wp/}}} or
{{{https://localhost/wp/}}} (I am using a self-signed certificate).
I am adding full access to the 'DefaultAppPool' account (for me, this is
the application pool of the 'IIS 10' web server through which the
'WordPress' web application runs) to the directory
{{{C:\inetpub\wwwroot\wp\}}} access control list (ACL), so that the
'WordPress' web application can create and modify files in this directory.
To configure the PHP interpreter, I used the 'php.ini-development' file
obtained from the 'PHP For Windows' distribution
(https://windows.php.net/download/). I copied the 'php.ini-development'
file, renamed it to 'php.ini' and included PHP interpreter extensions for
working with the 'MySQL' DBMS in it.
I didn't know that for the 'WordPress' web application to work, you need
to enable the PHP interpreter extension to work with the 'OpenSSL'
library, and therefore I didn't include it at first. When installing the
'WordPress' web application I was guided by the article
[https://wordpress.org/support/article/how-to-install-wordpress/ How to
install WordPress], article [https://wordpress.org/support/article/before-
you-install/ Before You Install] and
[https://wordpress.org/about/requirements/ official requirement page].
These three articles do not say that the 'WordPress' web application
requires the 'OpenSSL' library and the inclusion of the PHP interpreter
extension to work with this library.
Distribution 'wordpress-6.1.1.zip' I downloaded from the URL
https://wordpress.org/download/ to my desktop.
Below I will outline two scenarios (cases) for reproducing the error.
== Case 1.
''Installing the 'WordPress' web application version 6.1.1 with the PHP
interpreter extension NOT enabled to work with the OpenSSL library and
trying to install a language pack for the Russian language.''
1.1. Expand the archive 'wordpress-6.1.1.zip' on my desktop. By default,
the 'wordpress' folder with files is expanded from it.
1.2. Rename the 'wordpress' folder on the desktop to the 'wp' folder. Move
the 'wp' folder to the {{{C:\inetpub\wwwroot\}}} folder (this requires
computer administrator rights).
1.3. Add to the access control list for the folder
{{{C:\inetpub\wwwroot\wp\}}} element 'IIS AppPool\DefaultAppPool' with
full access (used for this folder, its subfolders and files).
1.4. Check if the 'MySQL' DBMS server (mysqld.exe) is running. This can be
done in the Task Manager (Ctrl+Shift+Esc) on the 'Processes' tab or the
'Details' tab. If the 'MySQL' DBMS server (mysqld.exe) is not running,
then it should be started.
1.5. Create a database (for example, with the name 'wordpressdb'). For
this I use the client {{{C:\Program Files\MySQL\MySQL Server
8.0\bin\mysql.exe}}} (you will need to enter the name of the database
administrator (DBA) and his password) from the command line. Create a user
(for example, with the name 'wordpressuser') and a password for it. Give
the created user full access to the created database. Log out of the
client. Something like this:
{{{
#!sql
mysql> CREATE DATABASE wordpressdb;
mysql> CREATE USER "wordpressuser"@"localhost" IDENTIFIED BY "password";
mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO
"wordpressuser"@"localhost";
mysql> FLUSH PRIVILEGES;
mysql> EXIT
}}}
1.6. Run the installation script {{{http://localhost/wp/wp-
admin/install.php}}} from the browser.
1.7. A list of languages will appear. Select the item 'Русский' (Russian)
from this list and click on the 'Продолжить' (Continue) button under the
list of languages. After that we will receive an error message in the
browser window:
{{{PHP Warning: Undefined array key "a:1:{s:3:"ssl";b:1;}" in
C:\inetpub\wwwroot\wp\wp-includes\class-requests.php on line 214}}}
== Case 2.
''Installing the 'WordPress' web application version 6.1.1 with the PHP
interpreter extension NOT enabled to work with the 'OpenSSL' library with
the default language pack (for English).''
(I deleted the 'wp' folder from {{{C:\inetpub\wwwroot\}}} and deleted the
database 'wordpressdb' (using the command {{{DROP DATABASE
wordpressdb;}}}), remaining after case 1, to start again with a clean
slate.)
2.1. Coincides with 1.1.
2.2. Coincides with 1.2.
2.3. Coincides with 1.3.
2.4. Coincides with 1.4.
2.5. Coincides with 1.5. I created the database 'wordpressdb' anew, and
the user 'wordpressuser' remained after case 1, so I used it instead of
creating a new one. Something like this:
{{{
#!sql
mysql> CREATE DATABASE wordpressdb;
mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO
"wordpressuser"@"localhost";
mysql> FLUSH PRIVILEGES;
mysql> EXIT
}}}
2.6. Coincides with 1.6.
2.7. A list of languages will appear, the item 'English (United States)'
is already selected in it by default. Click on the 'Continue' button under
the list of languages.
2.8. A screen opens with an explanation about the file 'wp-config.php'.
Click on the "Let's go!" button.
2.9. A screen opens for entering information for the file 'wp-config.php'.
Enter the database name (for example, 'wordpressdb'), the username (for
example, 'wordpressuser') and the user password created in paragraph 2.5.
Leave the default values for the fields 'Database Host' (localhost) and
'Table Prefix' (wp_). Click on the 'Submit' button.
2.10. The congratulation screen will open. Click on the 'Run the
installation' button.
2.11. A screen will open for entering information about the site. Enter
the site title (for example, 'My site title'), the site username (for
example, 'ilyachalov'), the site user password, the site user's email, the
"Search engine visibility" flag to leave unspecified. Click on the
'Install WordPress' button.
2.12. A screen will open with a message about the successful installation
of the 'WordPress' web application. Click on the 'Log In' button.
2.13. The script {{{http://localhost/wp/wp-login.php}}} will start. Enter
the site username and password created in paragraph 2.11. Click on the
'Log In' button.
2.14. The 'Dashboard' will open. In the menu on the left, select the item
'Tools', and inside it select the item 'Site Health'.
2.15. The 'Site Health' screen opens. On this screen, select the 'Info'
tab. After that we will receive an error message in the browser window:
{{{PHP Warning: Undefined array key "a:1:{s:3:"ssl";b:1;}" in
C:\inetpub\wwwroot\wp\wp-includes\class-requests.php on line 214}}}
== Error fix
This error also appears in other situations, not only in the two described
above.
If the PHP interpreter extension for working with the 'OpenSSL' library is
enabled, then in the cases described above, the described error will not
occur. (Library 'libssl-1_1-x64.dll' and PHP interpreter extension
'php_openssl.dll' are contained in the 'PHP For Windows' distribution.)
But I think that the above uncaught error needs to be caught, then the
user of the 'WordPress' web application in the cases described above will
not receive an incomprehensible error and his experience with the
'WordPress' web application will be more pleasant, without unnecessary
stress. (The user learns about the need to enable the PHP interpreter
extension to work with the 'OpenSSL' library from the 'Tools - Site
Health' tool in the 'Dashboard' and after that will be able to enable it.)
I suggest the following fix in the script {{{C:\inetpub\wwwroot\wp\wp-
includes\class-requests.php}}} in line 214.
Instead of (current version):
{{{
if (self::$transport[$cap_string] === null) {
}}}
fix on:
{{{
if (!isset(self::$transport[$cap_string])) {
}}}
The current version does not take into account the case when a key-value
pair with a key from the {{{$cap_string}}} variable is not defined in the
{{{self::$transport}}} array. Function
[https://www.php.net/manual/en/function.isset.php isset] track both cases:
the absence of a key-value pair with the key {{{$cap_string}}}, and the
case when the key {{{$cap_string}}} is defined, but the corresponding
value is {{{null}}}.
I will attach a patch file to this ticket. I hope its format is suitable
for the 'SVN' version control system. I will be creating a patch for the
'WordPress' web application for the first time, from the 'Git' program
using the 'git diff' command from the command line. (Please let me know if
the patch file format is incorrect, I will fix it.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57325>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list