| @@ -36,12 +36,31 @@ | ||
| 36 | 36 | { |
| 37 | 37 | return; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if (!self::isStarted()) | |
| 40 | + /** | |
| 41 | + * Do not go ahead in case the session has been already started, otherwise duplicate | |
| 42 | + * calls to this method risks to register the same hook more than once. | |
| 43 | + * | |
| 44 | + * @since 10.1.70 | |
| 45 | + */ | |
| 46 | + if (self::isStarted()) | |
| 41 | 47 | { |
| 42 | - session_start(); | |
| 48 | + return; | |
| 43 | 49 | } |
| 50 | + | |
| 51 | + /** | |
| 52 | + * In case the headers have been already sent, trigger warning and abort. | |
| 53 | + * | |
| 54 | + * @since 10.1.70 | |
| 55 | + */ | |
| 56 | + if (headers_sent()) | |
| 57 | + { | |
| 58 | + trigger_error('Session cannot be started after headers have already been sent', E_USER_WARNING); | |
| 59 | + return; | |
| 60 | + } | |
| 61 | + | |
| 62 | + session_start(); | |
| 44 | 63 | |
| 45 | 64 | /** |
| 46 | 65 | * Filters whether to preempt an HTTP request's return value. |
| 47 | 66 | * It is needed to support concurrent cURL requests (see Site Health). |