1 | <?php |
||
28 | class SessionStartHandler |
||
29 | { |
||
30 | const OPTION_NAME_SESSION_SAVE_HANDLER_STATUS = 'ee_session_save_handler_status'; |
||
31 | const REQUEST_PARAM_RETRY_SESSION = 'ee_retry_session'; |
||
32 | const SESSION_SAVE_HANDLER_STATUS_FAILED = 'session_save_handler_failed'; |
||
33 | const SESSION_SAVE_HANDLER_STATUS_SUCCESS = 'session_save_handler_success'; |
||
34 | const SESSION_SAVE_HANDLER_STATUS_UNKNOWN = 'session_save_handler_untested'; |
||
35 | |||
36 | /** |
||
37 | * @var RequestInterface $request |
||
38 | */ |
||
39 | protected $request; |
||
40 | |||
41 | /** |
||
42 | * StartSession constructor. |
||
43 | * |
||
44 | * @param RequestInterface $request |
||
45 | */ |
||
46 | public function __construct(RequestInterface $request) |
||
50 | |||
51 | /** |
||
52 | * Check if a custom session save handler is in play |
||
53 | * and attempt to start the PHP session |
||
54 | * |
||
55 | * @since 4.9.68.p |
||
56 | */ |
||
57 | public function startSession() |
||
69 | |||
70 | /** |
||
71 | * Returns `true` if the 'session.save_handler' ini setting matches a known custom handler |
||
72 | * |
||
73 | * @since 4.9.68.p |
||
74 | * @return bool |
||
75 | */ |
||
76 | private function hasKnownCustomSessionSaveHandler() |
||
86 | |||
87 | /** |
||
88 | * Attempt to start the PHP session when a custom Session Save Handler is known to be set. |
||
89 | * |
||
90 | * @since 4.9.68.p |
||
91 | */ |
||
92 | private function checkCustomSessionSaveHandler() |
||
113 | |||
114 | |||
115 | /** |
||
116 | * retrieves the value for the 'ee_session_save_handler_status' WP option. |
||
117 | * default value = 'session_save_handler_untested' |
||
118 | * |
||
119 | * @since 4.9.68.p |
||
120 | * @return string |
||
121 | */ |
||
122 | private function getSessionSaveHandlerStatus() |
||
129 | |||
130 | /** |
||
131 | * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_failed' |
||
132 | * which can then be upgraded is everything works correctly |
||
133 | * |
||
134 | * @since 4.9.68.p |
||
135 | * @return bool |
||
136 | */ |
||
137 | private function initializeSessionSaveHandlerStatus() |
||
144 | |||
145 | /** |
||
146 | * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_success' |
||
147 | * |
||
148 | * @since 4.9.68.p |
||
149 | * @return bool |
||
150 | */ |
||
151 | private function setSessionSaveHandlerStatusToValid() |
||
158 | |||
159 | /** |
||
160 | * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_untested' |
||
161 | * |
||
162 | * @since 4.9.68.p |
||
163 | * @return bool |
||
164 | */ |
||
165 | private function resetSessionSaveHandlerStatus() |
||
172 | |||
173 | /** |
||
174 | * Returns `true` if the 'ee_session_save_handler_status' WP option value |
||
175 | * is equal to 'session_save_handler_success' |
||
176 | * |
||
177 | * @since 4.9.68.p |
||
178 | * @return bool |
||
179 | */ |
||
180 | private function sessionSaveHandlerIsValid() |
||
184 | |||
185 | /** |
||
186 | * Returns `true` if the 'ee_session_save_handler_status' WP option value |
||
187 | * is equal to 'session_save_handler_failed' |
||
188 | * |
||
189 | * @since 4.9.68.p |
||
190 | * @return bool |
||
191 | */ |
||
192 | private function sessionSaveHandlerFailed() |
||
196 | |||
197 | /** |
||
198 | * Returns `true` if no errors were detected with the session save handler, |
||
199 | * otherwise attempts to work notify the appropriate authorities |
||
200 | * with a suggestion for how to fix the issue, and returns `false`. |
||
201 | * |
||
202 | * |
||
203 | * @since 4.9.68.p |
||
204 | * @return bool |
||
205 | */ |
||
206 | private function handleSessionSaveHandlerErrors() |
||
230 | |||
231 | /** |
||
232 | * Generates an EE_Error notice regarding the current session woes |
||
233 | * but only if the current user is an admin with permission to 'install_plugins'. |
||
234 | * |
||
235 | * @since 4.9.68.p |
||
236 | */ |
||
237 | private function displaySessionSaveHandlerErrorNotice() |
||
260 | } |
||
261 |