Fix ExceptionLogViewPage erroring out when passed invalid logfile
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 19 Jul 2014 13:29:51 +0000 (15:29 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 19 Jul 2014 13:29:51 +0000 (15:29 +0200)
Closes #1762

wcfsetup/install/files/lib/acp/page/ExceptionLogViewPage.class.php

index 11ecfc76e7e1733c662ebb00ef8ec7b0b8235e91..a5b1be064ef66a4f859dd9a0634be48ad2a7ef3b 100644 (file)
@@ -117,12 +117,18 @@ class ExceptionLogViewPage extends MultipleLinkPage {
                $contents = $split->split($contents, Regex::SPLIT_NON_EMPTY_ONLY | Regex::CAPTURE_SPLIT_DELIMITER);
                
                // even items become keys, odd items become values
-               $this->exceptions = call_user_func_array('array_merge', array_map(
-                       function($v) {
-                               return array($v[0] => $v[1]);
-                       }, 
-                       array_chunk($contents, 2)
-               ));
+               try {
+                       $this->exceptions = call_user_func_array('array_merge', array_map(
+                               function($v) {
+                                       return array($v[0] => $v[1]);
+                               },
+                               array_chunk($contents, 2)
+                       ));
+               }
+               catch (\Exception $e) {
+                       // logfile contents are pretty malformed, abort
+                       return;
+               }
                
                if ($this->exceptionID) $this->searchPage($this->exceptionID);
                $this->calculateNumberOfPages();