]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
DB Version was forgotten ...
[friendica.git] / boot.php
index de99e96574804ee61decdb0638f4d88e8507e946..4ef30eadac888d2752e558ac93107cde9e4bb7a1 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -36,7 +36,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1191      );
+define ( 'DB_UPDATE_VERSION',      1194      );
 
 /**
  * @brief Constant with a HTML line break.
@@ -467,6 +467,7 @@ class App {
        public  $is_tablet;
        public  $is_friendica_app;
        public  $performance = array();
+       public  $callstack = array();
 
        public $nav_sel;
 
@@ -529,6 +530,8 @@ class App {
        private $cached_profile_image;
        private $cached_profile_picdate;
 
+       private static $a;
+
        /**
         * @brief App constructor.
         */
@@ -554,6 +557,12 @@ class App {
                $this->performance["marktime"] = 0;
                $this->performance["markstart"] = microtime(true);
 
+               $this->callstack["database"] = array();
+               $this->callstack["network"] = array();
+               $this->callstack["file"] = array();
+               $this->callstack["rendering"] = array();
+               $this->callstack["parser"] = array();
+
                $this->config = array();
                $this->page = array();
                $this->pager= array();
@@ -703,6 +712,8 @@ class App {
                        }
                }
 
+               self::$a = $this;
+
        }
 
        function get_basepath() {
@@ -727,6 +738,10 @@ class App {
 
        function get_baseurl($ssl = false) {
 
+               // Is the function called statically?
+               if (!is_object($this))
+                       return(self::$a->get_baseurl($ssl));
+
                $scheme = $this->scheme;
 
                if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) {
@@ -903,6 +918,10 @@ class App {
        }
 
        function get_cached_avatar_image($avatar_image){
+               return $avatar_image;
+
+               // The following code is deactivated. It doesn't seem to make any sense and it slows down the system.
+               /*
                if($this->cached_profile_image[$avatar_image])
                        return $this->cached_profile_image[$avatar_image];
 
@@ -922,6 +941,7 @@ class App {
                        }
                }
                return $this->cached_profile_image[$avatar_image];
+               */
        }
 
 
@@ -1016,6 +1036,20 @@ class App {
 
                $this->performance[$value] += (float)$duration;
                $this->performance["marktime"] += (float)$duration;
+
+               // Trace the different functions with their timestamps
+               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
+
+               array_shift($trace);
+
+               $function = array();
+               foreach ($trace AS $func)
+                       $function[] = $func["function"];
+
+               $function = implode(", ", $function);
+
+               $this->callstack[$value][$function] += (float)$duration;
+
        }
 
        function mark_timestamp($mark) {
@@ -1350,7 +1384,7 @@ function get_guid($size=16, $prefix = "") {
                $prefix = substr($prefix, 0, $size - 22);
                return(str_replace(".", "", uniqid($prefix, true)));
        } else {
-               $prefix = substr($prefix, 0, $size - 13);
+               $prefix = substr($prefix, 0, max($size - 13, 0));
                return(uniqid($prefix));
        }
 }
@@ -2060,3 +2094,25 @@ function current_load() {
 
        return max($load_arr);
 }
+
+/**
+ * @brief get c-style args
+ * 
+ * @return int
+ */
+function argc() {
+       return get_app()->argc;
+}
+
+/**
+ * @brief Returns the value of a argv key
+ * 
+ * @param int $x argv key
+ * @return string Value of the argv key
+ */
+function argv($x) {
+       if(array_key_exists($x,get_app()->argv))
+               return get_app()->argv[$x];
+
+       return '';
+}