Make WordPress Core

Changeset 47585 for trunk


Ignore:
Timestamp:
04/16/2020 08:18:49 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Site Health: Detect an active PHP session as a possible reason for HTTP requests timing out.

PHP sessions created by a session_start() function call may interfere with REST API and loopback requests.

An active session should be closed by session_write_close() before making any HTTP requests.

Props matthieumota, netweblogic, Clorith, afragen, vjik, SergeyBiryukov.
Fixes #47320.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r47528 r47585  
    10851085
    10861086        /**
     1087         * Test if there's an active PHP session that can affect loopback requests.
     1088         *
     1089         * @since 5.5.0
     1090         *
     1091         * @return array The test results.
     1092         */
     1093        public function get_test_php_sessions() {
     1094                $result = array(
     1095                        'label'       => __( 'No PHP sessions detected' ),
     1096                        'status'      => 'good',
     1097                        'badge'       => array(
     1098                                'label' => __( 'Performance' ),
     1099                                'color' => 'blue',
     1100                        ),
     1101                        'description' => sprintf(
     1102                                '<p>%s</p>',
     1103                                sprintf(
     1104                                        /* translators: 1: session_start(), 2: session_write_close() */
     1105                                        __( 'PHP sessions created by a %1$s function call may interfere with REST API and loopback requests. An active session should be closed by %2$s before making any HTTP requests.' ),
     1106                                        '<code>session_start()</code>',
     1107                                        '<code>session_write_close()</code>'
     1108                                )
     1109                        ),
     1110                        'test'        => 'php_sessions',
     1111                );
     1112
     1113                if ( PHP_SESSION_ACTIVE === session_status() ) {
     1114                        $result['status'] = 'critical';
     1115
     1116                        $result['label'] = __( 'An active PHP session was detected' );
     1117
     1118                        $result['description'] = sprintf(
     1119                                '<p>%s</p>',
     1120                                sprintf(
     1121                                        /* translators: 1: session_start(), 2: session_write_close() */
     1122                                        __( 'A PHP session was created by a %1$s function call. This interferes with REST API and loopback requests. The session should be closed by %2$s before making any HTTP requests.' ),
     1123                                        '<code>session_start()</code>',
     1124                                        '<code>session_write_close()</code>'
     1125                                )
     1126                        );
     1127                }
     1128
     1129                return $result;
     1130        }
     1131
     1132        /**
    10871133         * Test if the SQL server is up to date.
    10881134         *
     
    19391985                                        'label' => __( 'PHP Default Timezone' ),
    19401986                                        'test'  => 'php_default_timezone',
     1987                                ),
     1988                                'php_sessions'         => array(
     1989                                        'label' => __( 'PHP Sessions' ),
     1990                                        'test'  => 'php_sessions',
    19411991                                ),
    19421992                                'sql_server'           => array(
Note: See TracChangeset for help on using the changeset viewer.