Fix fatal error because var_export doesn't handle circular dependency.
authorNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sat, 2 Nov 2013 19:47:08 +0000 (20:47 +0100)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sun, 3 Nov 2013 16:11:41 +0000 (17:11 +0100)
In logs there were lines such as:
PHP Fatal error:  Nesting level too deep - recursive dependency? in /home/web/prod/platal/include/security.inc.php on line 108, referer: https://www.polytechnique.org/register

More information can be found at:
- http://stackoverflow.com/questions/12488661/is-it-possible-to-list-out-all-the-global-variables-in-php
- http://php.net/manual/fr/function.var-export.php (in the comments)

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
include/security.inc.php

index ae9d008..832432f 100644 (file)
@@ -105,7 +105,12 @@ function send_warning_mail($title, $body = '')
     $mailer->setFrom("webmaster@" . $globals->mail->domain);
     $mailer->addTo($globals->core->admin_email);
     $mailer->setSubject("[Plat/al Security Alert] $title");
-    $mailer->setTxtBody($body . "Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
+    // Note: we can't do $session = var_export($_SESSION, true) as var_export
+    // doesn't handle circular dependency correctly.
+    ob_start();
+    var_dump($_SESSION);
+    $session = ob_get_clean();
+    $mailer->setTxtBody($body . "Identifiants de session :\n" . $session . "\n\n"
         ."Identifiants de connexion :\n" . var_export($_SERVER, true));
     $mailer->send();
 }