]> git.mxchange.org Git - friendica.git/commitdiff
Dependency of callstack moved one layer up
authorPhilipp Holzer <admin@philipp.info>
Sat, 16 Feb 2019 22:17:10 +0000 (23:17 +0100)
committerPhilipp Holzer <admin@philipp.info>
Sat, 16 Feb 2019 22:17:10 +0000 (23:17 +0100)
12 files changed:
src/App.php
src/Content/Text/BBCode.php
src/Content/Text/Markdown.php
src/Core/Addon.php
src/Core/Cache.php
src/Core/Logger.php
src/Core/Renderer.php
src/Core/Theme.php
src/Database/DBA.php
src/Object/Image.php
src/Util/Network.php
src/Util/Profiler.php

index 6e1f83fdd6bd5c9836e2ca4dcee69d40dd9ac90d..e61b8dbae4c9f09c1e6f06b55605ec2c40d15594 100644 (file)
@@ -493,7 +493,7 @@ class App
 
                unset($db_host, $db_user, $db_pass, $db_data, $charset);
 
-               $this->profiler->saveTimestamp($stamp1, 'network');
+               $this->profiler->saveTimestamp($stamp1, 'network', Core\System::callstack());
        }
 
        public function getScheme()
@@ -1189,7 +1189,7 @@ class App
                if (!$this->isBackend()) {
                        $stamp1 = microtime(true);
                        session_start();
-                       $this->profiler->saveTimestamp($stamp1, 'parser');
+                       $this->profiler->saveTimestamp($stamp1, 'parser', Core\System::callstack());
                        Core\L10n::setSessionVariable();
                        Core\L10n::setLangFromSession();
                } else {
index 75cb32b626950c9e7b4f8ea49973ff466f28d61f..e9b5f98d0b496deb0f6839f78a66b4b0e986a896 100644 (file)
@@ -1027,7 +1027,7 @@ class BBCode extends BaseObject
                        @curl_exec($ch);
                        $curl_info = @curl_getinfo($ch);
 
-                       $a->getProfiler()->saveTimestamp($stamp1, "network");
+                       $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                        if (substr($curl_info["content_type"], 0, 6) == "image/") {
                                $text = "[url=" . $match[1] . "]" . $match[1] . "[/url]";
@@ -1086,7 +1086,7 @@ class BBCode extends BaseObject
                        @curl_exec($ch);
                        $curl_info = @curl_getinfo($ch);
 
-                       $a->getProfiler()->saveTimestamp($stamp1, "network");
+                       $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                        // if its a link to a picture then embed this picture
                        if (substr($curl_info["content_type"], 0, 6) == "image/") {
@@ -1915,7 +1915,7 @@ class BBCode extends BaseObject
                // unmask the special chars back to HTML
                $text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['&lt;', '&gt;', '&amp;'], $text);
 
-               $a->getProfiler()->saveTimestamp($stamp1, "parser");
+               $a->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
 
                // Libertree has a problem with escaped hashtags.
                $text = str_replace(['\#'], ['#'], $text);
index 28ee215b2674aa3810e31b73f245f8ef3bd00694..e3e2cd3ac957750e56f04205179611a3038aac72 100644 (file)
@@ -7,6 +7,7 @@
 namespace Friendica\Content\Text;
 
 use Friendica\BaseObject;
+use Friendica\Core\System;
 use Friendica\Model\Contact;
 use Michelf\MarkdownExtra;
 
@@ -36,7 +37,7 @@ class Markdown extends BaseObject
                $html = $MarkdownParser->transform($text);
                $html = preg_replace('/<a(.*?)href="#/is', '<a$1href="' . ltrim($_SERVER['REQUEST_URI'], '/') . '#', $html);
 
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser");
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
 
                return $html;
        }
index 483882c3edc3036134ff8073fa094e4776b31590..7957e08350efefb0cd68c39287b4bd3c7a903fc4 100644 (file)
@@ -219,7 +219,7 @@ class Addon extends BaseObject
 
                $stamp1 = microtime(true);
                $f = file_get_contents("addon/$addon/$addon.php");
-               $a->getProfiler()->saveTimestamp($stamp1, "file");
+               $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
 
                $r = preg_match("|/\*.*\*/|msU", $f, $m);
 
index cd1581ef930a326418777509fe6162cd7a6c8a2b..cadb2444b50e4debee4b9eff7a9f55d6e47f1d60 100644 (file)
@@ -63,7 +63,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->getAllKeys($prefix);
 
-               self::getApp()->getProfiler()->saveTimestamp($time, 'cache');
+               self::getApp()->getProfiler()->saveTimestamp($time, 'cache', System::callstack());
 
                return $return;
        }
@@ -82,7 +82,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->get($key);
 
-               self::getApp()->getProfiler()->saveTimestamp($time, 'cache');
+               self::getApp()->getProfiler()->saveTimestamp($time, 'cache', System::callstack());
 
                return $return;
        }
@@ -105,7 +105,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->set($key, $value, $duration);
 
-               self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write');
+               self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write', System::callstack());
 
                return $return;
        }
@@ -124,7 +124,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->delete($key);
 
-               self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write');
+               self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write', System::callstack());
 
                return $return;
        }
index 69be501a3d3efa59af37a10f53874b73a4763726..0712c91b1c921485e1d480df5f99477ddc1194d5 100644 (file)
@@ -155,7 +155,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->emergency($message, $context);
-               self::getApp()->GetProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->GetProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -179,7 +179,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->alert($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -202,7 +202,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->critical($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -225,7 +225,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->error($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -249,7 +249,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->warning($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -270,7 +270,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->notice($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -293,7 +293,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->info($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
        /**
@@ -314,7 +314,7 @@ class Logger extends BaseObject
 
                $stamp1 = microtime(true);
                self::$logger->debug($message, $context);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file');
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack());
        }
 
     /**
@@ -334,7 +334,7 @@ class Logger extends BaseObject
 
         $stamp1 = microtime(true);
                self::$logger->log($level, $msg);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, "file");
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
     }
 
        /**
@@ -355,6 +355,6 @@ class Logger extends BaseObject
 
         $stamp1 = microtime(true);
         self::$devLogger->log($level, $msg);
-               self::getApp()->getProfiler()->saveTimestamp($stamp1, "file");
+               self::getApp()->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
     }
 }
index c032448c984b73f7f12113226e5521cac2ead9de..8844f26881c35183e84874ccfd5431881415a00e 100644 (file)
@@ -74,7 +74,7 @@ class Renderer extends BaseObject
             exit();
         }
 
-               $a->getProfiler()->saveTimestamp($stamp1, "rendering");
+               $a->getProfiler()->saveTimestamp($stamp1, "rendering", System::callstack());
 
         return $output;
     }
@@ -101,7 +101,7 @@ class Renderer extends BaseObject
             exit();
         }
 
-        $a->getProfiler()->saveTimestamp($stamp1, "file");
+        $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
 
         return $template;
     }
index dbfc0fd908bcfbcf0e76bb17f1c6b5ec6a28a46b..5479f8f46f8e2deeb097d1dd0c98d9401da0cccb 100644 (file)
@@ -51,7 +51,7 @@ class Theme
                $a = \get_app();
                $stamp1 = microtime(true);
                $theme_file = file_get_contents("view/theme/$theme/theme.php");
-               $a->getProfiler()->saveTimestamp($stamp1, "file");
+               $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
 
                $result = preg_match("|/\*.*\*/|msU", $theme_file, $matches);
 
index 7c24ecfd336ae42b5297bef1afd37eb1aad7230e..edef30901539c35a9a908d040729c0122b234826 100644 (file)
@@ -587,7 +587,7 @@ class DBA
                        self::$errorno = $errorno;
                }
 
-               self::$profiler->saveTimestamp($stamp1, 'database');
+               self::$profiler->saveTimestamp($stamp1, 'database', System::callstack());
 
                if (self::$configCache->get('system', 'db_log')) {
                        $stamp2 = microtime(true);
@@ -658,7 +658,7 @@ class DBA
                        self::$errorno = $errorno;
                }
 
-               self::$profiler->saveTimestamp($stamp, "database_write");
+               self::$profiler->saveTimestamp($stamp, "database_write", System::callstack());
 
                return $retval;
        }
@@ -827,7 +827,7 @@ class DBA
                                }
                }
 
-               self::$profiler->saveTimestamp($stamp1, 'database');
+               self::$profiler->saveTimestamp($stamp1, 'database', System::callstack());
 
                return $columns;
        }
@@ -1564,7 +1564,7 @@ class DBA
                                break;
                }
 
-               self::$profiler->saveTimestamp($stamp1, 'database');
+               self::$profiler->saveTimestamp($stamp1, 'database', System::callstack());
 
                return $ret;
        }
index c43955375402984a4249864a9c89de3709219bf7..45c8bedeaf58397abe15b1b7684a009156f63cad 100644 (file)
@@ -656,7 +656,7 @@ class Image
 
                $stamp1 = microtime(true);
                file_put_contents($path, $string);
-               $a->getProfiler()->saveTimestamp($stamp1, "file");
+               $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
        }
 
        /**
@@ -802,7 +802,7 @@ class Image
                                        $a = \get_app();
                                        $stamp1 = microtime(true);
                                        file_put_contents($tempfile, $img_str);
-                                       $a->getProfiler()->saveTimestamp($stamp1, "file");
+                                       $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
 
                                        $data = getimagesize($tempfile);
                                        unlink($tempfile);
@@ -910,7 +910,7 @@ class Image
 
                        $stamp1 = microtime(true);
                        $imagedata = @file_get_contents($url);
-                       $a->getProfiler()->saveTimestamp($stamp1, "file");
+                       $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
                }
 
                $maximagesize = Config::get('system', 'maximagesize');
@@ -924,7 +924,7 @@ class Image
 
                $stamp1 = microtime(true);
                file_put_contents($tempfile, $imagedata);
-               $a->getProfiler()->saveTimestamp($stamp1, "file");
+               $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
 
                $data = getimagesize($tempfile);
 
index 4d5afa3a362f218b16decfecdcbc09f94a4ed89a..cda8c9a71d7113ddb0812af350195943425cf6d8 100644 (file)
@@ -232,7 +232,7 @@ class Network
 
                @curl_close($ch);
 
-               $a->getProfiler()->saveTimestamp($stamp1, 'network');
+               $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack());
 
                return $curlResponse;
        }
@@ -334,7 +334,7 @@ class Network
 
                curl_close($ch);
 
-               $a->getProfiler()->saveTimestamp($stamp1, 'network');
+               $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack());
 
                Logger::log('post_url: end ' . $url, Logger::DATA);
 
@@ -641,7 +641,7 @@ class Network
                $http_code = $curl_info['http_code'];
                curl_close($ch);
 
-               $a->getProfiler()->saveTimestamp($stamp1, "network");
+               $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                if ($http_code == 0) {
                        return $url;
@@ -683,7 +683,7 @@ class Network
                $body = curl_exec($ch);
                curl_close($ch);
 
-               $a->getProfiler()->saveTimestamp($stamp1, "network");
+               $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                if (trim($body) == "") {
                        return $url;
index 7bf30a2775d95cbecdba49e75a3d8aca4c77fd64..f65bede152ae3cb149ade2eef99e192abdf2aac4 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Friendica\Util;
 
-use Friendica\Core;
 use Psr\Container\ContainerExceptionInterface;
 use Psr\Container\ContainerInterface;
 use Psr\Container\NotFoundExceptionInterface;
@@ -58,8 +57,9 @@ class Profiler implements ContainerInterface
         *
         * @param int $timestamp the Timestamp
         * @param string $value A value to profile
+        * @param string $callstack The callstack of the current profiling data
         */
-       public function saveTimestamp($timestamp, $value)
+       public function saveTimestamp($timestamp, $value, $callstack = '')
        {
                if (!$this->enabled) {
                        return;
@@ -75,8 +75,6 @@ class Profiler implements ContainerInterface
                $this->performance[$value] += (float) $duration;
                $this->performance['marktime'] += (float) $duration;
 
-               $callstack = Core\System::callstack();
-
                if (!isset($this->callstack[$value][$callstack])) {
                        // Prevent ugly E_NOTICE
                        $this->callstack[$value][$callstack] = 0;