| | 1089 | * Test if there's an active PHP session that can affect loopback requests. |
| | 1090 | * |
| | 1091 | * @since 5.5.0 |
| | 1092 | * |
| | 1093 | * @return array The test results. |
| | 1094 | */ |
| | 1095 | public function get_test_php_sessions() { |
| | 1096 | $result = array( |
| | 1097 | 'label' => __( 'No PHP sessions detected' ), |
| | 1098 | 'status' => 'good', |
| | 1099 | 'badge' => array( |
| | 1100 | 'label' => __( 'Performance' ), |
| | 1101 | 'color' => 'blue', |
| | 1102 | ), |
| | 1103 | 'description' => sprintf( |
| | 1104 | '<p>%s</p>', |
| | 1105 | sprintf( |
| | 1106 | /* translators: 1: session_start(), 2: session_write_close() */ |
| | 1107 | __( 'PHP sessions created by a %1$s function call interfere with REST API and loopback requests. An active session should be closed by %2$s before making any HTTP requests.' ), |
| | 1108 | '<code>session_start()</code>', |
| | 1109 | '<code>session_write_close()</code>' |
| | 1110 | ) |
| | 1111 | ), |
| | 1112 | 'test' => 'php_sessions', |
| | 1113 | ); |
| | 1114 | |
| | 1115 | if ( PHP_SESSION_ACTIVE === session_status() ) { |
| | 1116 | $result['status'] = 'critical'; |
| | 1117 | |
| | 1118 | $result['label'] = __( 'An active PHP session detected' ); |
| | 1119 | |
| | 1120 | $result['description'] = sprintf( |
| | 1121 | '<p>%s</p>', |
| | 1122 | sprintf( |
| | 1123 | /* translators: 1: session_start(), 2: session_write_close() */ |
| | 1124 | __( '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.' ), |
| | 1125 | '<code>session_start()</code>', |
| | 1126 | '<code>session_write_close()</code>' |
| | 1127 | ) |
| | 1128 | ); |
| | 1129 | } |
| | 1130 | |
| | 1131 | return $result; |
| | 1132 | } |
| | 1133 | |
| | 1134 | /** |