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;
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;
}
* @brief Clear cache entries
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function clearCache(App $a)
{
}
$condition = ['`uid` = 0 AND `resource-id` LIKE "pic:%" AND `created` < NOW() - INTERVAL ? SECOND', $cachetime];
- DBA::delete('photo', $condition);
+ Photo::delete($condition);
}
// Delete the cached OEmbed entries that are older than three month
* @brief Repair missing values in Diaspora contacts
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function repairDiaspora(App $a)
{
/// - 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");
+ }
+ }
}