From 66c72331f80d089644d1d0557bde9412c1a6dd70 Mon Sep 17 00:00:00 2001 From: Roberto Spadim Date: Thu, 23 May 2013 19:34:07 -0300 Subject: [PATCH 1/4] Changed orders of append file With this new file the functions of xhprof are logged too The funciton return if xhprof_disable() isn't an array --- inc/append.php | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/inc/append.php b/inc/append.php index 5923e7e..1ca2d2f 100644 --- a/inc/append.php +++ b/inc/append.php @@ -1,26 +1,16 @@ save($xhprof_data); -}); \ No newline at end of file + $v=xhprof_disable(); + if(!is_array($v)) return; + $xhprof_data_obj->save($v); +}); From b6c817ab22f6e098dea4ce3c6af3871ade4bd4fc Mon Sep 17 00:00:00 2001 From: Roberto Spadim Date: Thu, 23 May 2013 19:54:10 -0300 Subject: [PATCH 2/4] hash key, PSR-2 changed request_uris to allow hash_value instead of index over uri am index over hash_value is better to find uri uri now is longblob can have very big uri values changed append to PSR-2 --- inc/append.php | 32 +++++++++++++++++++------------- setup/database.sql | 6 +++--- xhprof/classes/data.php | 13 +++++++++---- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/inc/append.php b/inc/append.php index 1ca2d2f..d50de8c 100644 --- a/inc/append.php +++ b/inc/append.php @@ -1,16 +1,22 @@ save($v); + $config = require __DIR__ . '/../xhprof/includes/config.inc.php'; + require_once __DIR__ . '/../xhprof/classes/data.php'; + $xhprof_data_obj = new \ay\xhprof\Data($config['pdo']); + $v=xhprof_disable(); + if (!is_array($v)) { + return; + } + $xhprof_data_obj->save($v); }); diff --git a/setup/database.sql b/setup/database.sql index f4670eb..5fe0a89 100644 --- a/setup/database.sql +++ b/setup/database.sql @@ -106,10 +106,10 @@ DROP TABLE IF EXISTS `request_uris`; CREATE TABLE `request_uris` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uri` varchar(255) NOT NULL DEFAULT '', + `hash_value` varchar(255) NOT NULL DEFAULT '', + `uri` LONGBLOB NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `uri` (`uri`), - KEY `id` (`id`,`uri`) + UNIQUE KEY `hash_value` (`hash_value`) USING HASH, ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/xhprof/classes/data.php b/xhprof/classes/data.php index 8c01db5..f811201 100644 --- a/xhprof/classes/data.php +++ b/xhprof/classes/data.php @@ -142,9 +142,13 @@ public function save(array $xhprof_data) UNION ALL (SELECT 'host_id', `id` FROM `request_hosts` WHERE `host` = :host LIMIT 1) UNION ALL - (SELECT 'uri_id', `id` FROM `request_uris` WHERE `uri` = :uri LIMIT 1);"); + (SELECT 'uri_id', `id` FROM `request_uris` WHERE `uri` = :uri AND `hash_value` = :hash_value LIMIT 1);"); - $sth->execute(array('method' => $_SERVER['REQUEST_METHOD'], 'host' => $_SERVER['HTTP_HOST'], 'uri' => $_SERVER['REQUEST_URI'])); + $sth->execute(array( + 'method' => $_SERVER['REQUEST_METHOD'], + 'host' => $_SERVER['HTTP_HOST'], + 'uri' => $_SERVER['REQUEST_URI'], + 'hash_value' => sha1($_SERVER['REQUEST_URI']) )); $request = $sth->fetchAll(PDO::FETCH_KEY_PAIR); @@ -169,8 +173,9 @@ public function save(array $xhprof_data) if(!isset($request['uri_id'])) { $this->db - ->prepare("INSERT INTO `request_uris` SET `uri` = :uri;") - ->execute(array('uri' => $_SERVER['REQUEST_URI'])); + ->prepare("INSERT INTO `request_uris` SET `uri` = :uri, `hash_value` = :hash_value;") + ->execute(array('uri' => $_SERVER['REQUEST_URI'], + 'hash_value' => sha1($_SERVER['REQUEST_URI']) )); $request['uri_id'] = $this->db->lastInsertId(); } From b6572f21ceea1ecad42ea346f183d5f903c69d83 Mon Sep 17 00:00:00 2001 From: Roberto Spadim Date: Thu, 23 May 2013 20:09:10 -0300 Subject: [PATCH 3/4] removed xhprof.io in append don't put functions of xhprof, sorry, didn't tested before xhprof calls make very dificult to understand code load --- inc/append.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/append.php b/inc/append.php index d50de8c..ae8b009 100644 --- a/inc/append.php +++ b/inc/append.php @@ -1,7 +1,11 @@ save($v); }); From f5c358e0a2a5a27135802a560eb828d326f9d757 Mon Sep 17 00:00:00 2001 From: Roberto Spadim Date: Thu, 23 May 2013 20:13:06 -0300 Subject: [PATCH 4/4] Changed prepend to don't run if function don't exists and if in cli --- inc/prepend.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/inc/prepend.php b/inc/prepend.php index a77e0d1..884393b 100644 --- a/inc/prepend.php +++ b/inc/prepend.php @@ -1,8 +1,4 @@