@@ -537,13 +537,59 @@ public function collectConsole(){
537
537
$ this ->data [$ name ] = $ collector ->collect ();
538
538
}
539
539
540
+ // Remove all invalid (non UTF-8) characters
541
+ array_walk_recursive ($ this ->data , function (&$ item ){
542
+ if (is_string ($ item ) && !mb_check_encoding ($ item , 'UTF-8 ' )){
543
+ $ item = mb_convert_encoding ($ item , 'UTF-8 ' , 'UTF-8 ' );
544
+ }
545
+ });
546
+
540
547
if ($ this ->storage !== null ) {
541
548
$ this ->storage ->save ($ this ->getCurrentRequestId (), $ this ->data );
542
549
}
543
550
544
551
return $ this ->data ;
545
552
}
546
553
554
+ /**
555
+ * Collects the data from the collectors
556
+ *
557
+ * @return array
558
+ */
559
+ public function collect ()
560
+ {
561
+ /** @var Request $request */
562
+ $ request = $ this ->app ['request ' ];
563
+
564
+ $ this ->data = array (
565
+ '__meta ' => array (
566
+ 'id ' => $ this ->getCurrentRequestId (),
567
+ 'datetime ' => date ('Y-m-d H:i:s ' ),
568
+ 'utime ' => microtime (true ),
569
+ 'method ' => $ request ->getMethod (),
570
+ 'uri ' => $ request ->getRequestUri (),
571
+ 'ip ' => $ request ->getClientIp ()
572
+ )
573
+ );
574
+
575
+ foreach ($ this ->collectors as $ name => $ collector ) {
576
+ $ this ->data [$ name ] = $ collector ->collect ();
577
+ }
578
+
579
+ // Remove all invalid (non UTF-8) characters
580
+ array_walk_recursive ($ this ->data , function (&$ item ){
581
+ if (is_string ($ item ) && !mb_check_encoding ($ item , 'UTF-8 ' )){
582
+ $ item = mb_convert_encoding ($ item , 'UTF-8 ' , 'UTF-8 ' );
583
+ }
584
+ });
585
+
586
+
587
+ if ($ this ->storage !== null ) {
588
+ $ this ->storage ->save ($ this ->getCurrentRequestId (), $ this ->data );
589
+ }
590
+
591
+ return $ this ->data ;
592
+ }
547
593
548
594
/**
549
595
* Magic calls for adding messages
0 commit comments