]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Merge remote-tracking branch 'upstream/develop' into 1702-null-date
[friendica.git] / boot.php
index 504a524ed7d321e340f48ecf07688e991ecd613f..32e0c0e147604553ad8896a38b29a7402d2ceb52 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -38,9 +38,9 @@ require_once('include/dbstructure.php');
 
 define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
-define ( 'FRIENDICA_VERSION',      '3.5.1-dev' );
+define ( 'FRIENDICA_VERSION',      '3.5.2-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1214      );
+define ( 'DB_UPDATE_VERSION',      1215      );
 
 /**
  * @brief Constant with a HTML line break.
@@ -442,6 +442,14 @@ define('SR_SCOPE_ALL',  'all');
 define('SR_SCOPE_TAGS', 'tags');
 /* @}*/
 
+/**
+ * Lowest possible date time value
+ */
+
+//define ('NULL_DATE', '0001-01-01 00:00:00');
+define ('NULL_DATE', '0000-00-00 00:00:00');
+
+
 // Normally this constant is defined - but not if "pcntl" isn't installed
 if (!defined("SIGTERM"))
        define("SIGTERM", 15);
@@ -1457,7 +1465,7 @@ class App {
                        return false;
                }
                if (!is_writable($directory)) {
-                       logger('Path "'.$temppath.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
+                       logger('Path "'.$directory.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
                        return false;
                }
                return true;
@@ -2039,7 +2047,7 @@ function proc_run($cmd){
        }
 
        // Checking number of workers
-       $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
+       $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE));
 
        // Get number of allowed number of worker threads
        $queues = intval(get_config("system", "worker_queues"));
@@ -2367,7 +2375,7 @@ function get_itemcachepath() {
 
        $itemcache = get_config('system','itemcache');
        if (($itemcache != "") AND App::directory_usable($itemcache)) {
-               return($itemcache);
+               return $itemcache;
        }
 
        $temppath = get_temppath();
@@ -2380,7 +2388,7 @@ function get_itemcachepath() {
 
                if (App::directory_usable($itemcache)) {
                        set_config("system", "itemcache", $itemcache);
-                       return($itemcache);
+                       return $itemcache;
                }
        }
        return "";
@@ -2389,25 +2397,32 @@ function get_itemcachepath() {
 function get_lockpath() {
        $lockpath = get_config('system','lockpath');
        if (($lockpath != "") AND App::directory_usable($lockpath)) {
-               return($lockpath);
+               // We have a lock path and it is usable
+               return $lockpath;
        }
 
+       // We don't have a working preconfigured lock path, so we take the temp path.
        $temppath = get_temppath();
 
        if ($temppath != "") {
+               // To avoid any interferences with other systems we create our own directory
                $lockpath = $temppath."/lock";
-
                if (!is_dir($lockpath)) {
                        mkdir($lockpath);
-               } elseif (!App::directory_usable($lockpath)) {
-                       $lockpath = $temppath;
                }
 
                if (App::directory_usable($lockpath)) {
+                       // The new path is usable, we are happy
                        set_config("system", "lockpath", $lockpath);
-                       return($lockpath);
+                       return $lockpath;
+               } else {
+                       // We can't create a subdirectory, strange.
+                       // But the directory seems to work, so we use it but don't store it.
+                       return $temppath;
                }
        }
+
+       // Reaching this point means that the operating system is configured badly.
        return "";
 }
 
@@ -2419,50 +2434,68 @@ function get_lockpath() {
 function get_spoolpath() {
        $spoolpath = get_config('system','spoolpath');
        if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
-               return($spoolpath);
+               // We have a spool path and it is usable
+               return $spoolpath;
        }
 
+       // We don't have a working preconfigured spool path, so we take the temp path.
        $temppath = get_temppath();
 
        if ($temppath != "") {
+               // To avoid any interferences with other systems we create our own directory
                $spoolpath = $temppath."/spool";
-
                if (!is_dir($spoolpath)) {
                        mkdir($spoolpath);
-               } elseif (!App::directory_usable($spoolpath)) {
-                       $spoolpath = $temppath;
                }
 
                if (App::directory_usable($spoolpath)) {
+                       // The new path is usable, we are happy
                        set_config("system", "spoolpath", $spoolpath);
-                       return($spoolpath);
+                       return $spoolpath;
+               } else {
+                       // We can't create a subdirectory, strange.
+                       // But the directory seems to work, so we use it but don't store it.
+                       return $temppath;
                }
        }
+
+       // Reaching this point means that the operating system is configured badly.
        return "";
 }
 
 function get_temppath() {
        $a = get_app();
 
-       $temppath = get_config("system","temppath");
+       $temppath = get_config("system", "temppath");
 
        if (($temppath != "") AND App::directory_usable($temppath)) {
-               return($temppath);
+               // We have a temp path and it is usable
+               return $temppath;
        }
 
+       // We don't have a working preconfigured temp path, so we take the system path.
        $temppath = sys_get_temp_dir();
-       if (($temppath != "") AND App::directory_usable($temppath)) {
-               $temppath .= "/".$a->get_hostname();
-               if (!is_dir($temppath))
-                       mkdir($temppath);
 
-               if (App::directory_usable($temppath)) {
-                       set_config("system", "temppath", $temppath);
-                       return($temppath);
+       // Check if it is usable
+       if (($temppath != "") AND App::directory_usable($temppath)) {
+               // To avoid any interferences with other systems we create our own directory
+               $new_temppath .= "/".$a->get_hostname();
+               if (!is_dir($new_temppath))
+                       mkdir($new_temppath);
+
+               if (App::directory_usable($new_temppath)) {
+                       // The new path is usable, we are happy
+                       set_config("system", "temppath", $new_temppath);
+                       return $new_temppath;
+               } else {
+                       // We can't create a subdirectory, strange.
+                       // But the directory seems to work, so we use it but don't store it.
+                       return $temppath;
                }
        }
 
-       return("");
+       // Reaching this point means that the operating system is configured badly.
+       return '';
 }
 
 /// @deprecated