sandrocardoso86 / webgrind

Automatically exported from code.google.com/p/webgrind
Other
0 stars 0 forks source link

TODO in getInvokeUrl. Patch. done. :-) #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Use Windows or new version of XDebug or different configuration of XDebug
or whatever formats XDebug with:

\n
==== NEW PROFILING FILE =====...===\n
version: 0.9.6\n
cmd: /full/path/here\n

What is the expected output? What do you see instead?
The popup for the grind files is bad, with NEW PROFILE FILE ====== instead
of the actual invokeUrl.

There's a TODO comment about this in ~/library/FileHandler.php actually.

What version of the product are you using? On what operating system?
current and Windows XP sp2.

Please provide any additional information below.
Patch:
--- FileHandler.php.original    2008-07-23 09:49:53.603817300 -0500
+++ FileHandler.php     2008-07-23 10:00:08.135067300 -0500
@@ -51,12 +51,17 @@
         * @return void string
         */
        private function getInvokeUrl($file){
+               if (preg_match('/.webgrind$/', $file)) return 'Binary!';
                // Grab name of invoked file.
-               // TODO: Makes assumptions about where the "cmd"-header is
in a trace file. Not so cool, but a fast way to do it.
-           $fp = fopen($file, 'r');
-           fgets($fp);
-           $invokeUrl = trim(substr(fgets($fp), 5));
-           fclose($fp);
+               $fp = fopen($file, 'r');
+               $invokeUrl = '';
+               while ((($line = fgets($fp)) !== FALSE) &&
!strlen($invokeUrl)){
+                       if (preg_match('/^cmd: (.*)$/', $line, $parts)){
+                               $invokeUrl = isset($parts[1]) ? $parts[1] : '';
+                       }
+               }
+               fclose($fp);
+               if (!strlen($invokeUrl)) $invokeUrl = 'Unknown!';
                return $invokeUrl;
        }

@@ -130,4 +135,4 @@
                return ($a['mtime'] > $b['mtime']) ? -1 : 1;
        }

-}
\ No newline at end of file
+}

Original issue reported on code.google.com by richardl...@gmail.com on 23 Jul 2008 at 3:07

GoogleCodeExporter commented 8 years ago
The issue seems to surface when xdebug is set to append profiles. Thank you for 
the patch, fixed in r131

Original comment by gugakf...@gmail.com on 1 Aug 2008 at 10:28