File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,8 +20,35 @@ public function isSupported()
2020
2121 public function save (array $ data )
2222 {
23+ if (isset ($ data ['profile ' ])) {
24+ $ data ['profile ' ] = $ this ->encodeProfile ($ data ['profile ' ]);
25+ }
26+
2327 $ result = parent ::save ($ data );
2428
2529 return !empty ($ result );
2630 }
31+
32+ /**
33+ * MongoDB can't save keys with values containing a dot:
34+ *
35+ * InvalidArgumentException: invalid document for insert: keys cannot contain ".":
36+ * "Zend_Controller_Dispatcher_Standard::loadClass==>load::controllers/ArticleController.php"
37+ *
38+ * Replace the dots with underscrore in keys.
39+ *
40+ * @link https://github.com/perftools/xhgui/issues/209
41+ */
42+ private function encodeProfile (array $ profile )
43+ {
44+ $ results = array ();
45+ foreach ($ profile as $ k => $ v ) {
46+ if (strpos ($ k , '. ' ) !== false ) {
47+ $ k = str_replace ('. ' , '_ ' , $ k );
48+ }
49+ $ results [$ k ] = $ v ;
50+ }
51+
52+ return $ results ;
53+ }
2754}
You can’t perform that action at this time.
0 commit comments