]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/CronJobs.php
API: Fix the displaying of reshared posts
[friendica.git] / src / Worker / CronJobs.php
index ca50e0e75f48377c72c3769ad512dbd3a4f139a3..d0f417f4ffd0c530f561f61f63c89c0df9231e07 100644 (file)
@@ -10,6 +10,8 @@ use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\StorageManager;
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Database\PostUpdate;
 use Friendica\Model\Contact;
@@ -35,54 +37,46 @@ class CronJobs
 
                Logger::log("Starting cronjob " . $command, Logger::DEBUG);
 
-               // Call possible post update functions
-               // see src/Database/PostUpdate.php for more details
-               if ($command == 'post_update') {
-                       PostUpdate::update();
-                       return;
-               }
+               switch($command) {
+                       case 'post_update':
+                               PostUpdate::update();
+                               break;
 
-               // update nodeinfo data
-               if ($command == 'nodeinfo') {
-                       nodeinfo_cron();
-                       return;
-               }
+                       case 'nodeinfo':
+                               nodeinfo_cron();
+                               break;
 
-               // Expire and remove user entries
-               if ($command == 'expire_and_remove_users') {
-                       self::expireAndRemoveUsers();
-                       return;
-               }
+                       case 'expire_and_remove_users':
+                               self::expireAndRemoveUsers();
+                               break;
 
-               if ($command == 'update_contact_birthdays') {
-                       Contact::updateBirthdays();
-                       return;
-               }
+                       case 'update_contact_birthdays':
+                               Contact::updateBirthdays();
+                               break;
 
-               if ($command == 'update_photo_albums') {
-                       self::updatePhotoAlbums();
-                       return;
-               }
+                       case 'update_photo_albums':
+                               self::updatePhotoAlbums();
+                               break;
 
-               // Clear cache entries
-               if ($command == 'clear_cache') {
-                       self::clearCache($a);
-                       return;
-               }
+                       case 'clear_cache':
+                               self::clearCache($a);
+                               break;
 
-               // Repair missing Diaspora values in contacts
-               if ($command == 'repair_diaspora') {
-                       self::repairDiaspora($a);
-                       return;
-               }
+                       case 'repair_diaspora':
+                               self::repairDiaspora($a);
+                               break;
 
-               // Repair entries in the database
-               if ($command == 'repair_database') {
-                       self::repairDatabase();
-                       return;
-               }
+                       case 'repair_database':
+                               self::repairDatabase();
+                               break;
 
-               Logger::log("Xronjob " . $command . " is unknown.", Logger::DEBUG);
+                       case 'move_storage':
+                               self::moveStorage();
+                               break;
+
+                       default:
+                               Logger::log("Cronjob " . $command . " is unknown.", Logger::DEBUG);
+               }
 
                return;
        }
@@ -134,6 +128,7 @@ class CronJobs
         * @brief Clear cache entries
         *
         * @param App $a
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function clearCache(App $a)
        {
@@ -231,6 +226,8 @@ class CronJobs
         * @brief Repair missing values in Diaspora contacts
         *
         * @param App $a
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function repairDiaspora(App $a)
        {
@@ -298,4 +295,20 @@ class CronJobs
                /// - remove children when parent got lost
                /// - set contact-id in item when not present
        }
+
+       /**
+        * Moves up to 5000 attachments and photos to the current storage system.
+        * Self-replicates if legacy items have been found and moved.
+        *
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       private static function moveStorage()
+       {
+               $current = StorageManager::getBackend();
+               $moved = StorageManager::move($current);
+
+               if ($moved) {
+                       Worker::add(PRIORITY_LOW, "CronJobs", "move_storage");
+               }
+       }
 }