]> git.mxchange.org Git - friendica.git/blobdiff - include/cron.php
Fixes E_WARNING from foreach() because count() seem to return TRUE even when $r is...
[friendica.git] / include / cron.php
index d8ebf7de62486cc2c6419893c14500e484b2782c..3acf711dd163056234b822a1eb27f39387108a7b 100644 (file)
@@ -163,6 +163,9 @@ function cron_run(&$argv, &$argc){
        // Repair missing Diaspora values in contacts
        cron_repair_diaspora($a);
 
+       // Repair entries in the database
+       cron_repair_database();
+
        $manual_id  = 0;
        $generation = 0;
        $force      = false;
@@ -416,6 +419,23 @@ function cron_repair_diaspora(&$a) {
        }
 }
 
+/**
+ * @brief Do some repairs in database entries
+ *
+ */
+function cron_repair_database() {
+
+       // Set the parent if it wasn't set. (Shouldn't happen - but does sometimes)
+       // This call is very "cheap" so we can do it at any time without a problem
+       q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0");
+
+       /// @todo
+       /// - remove thread entries without item
+       /// - remove sign entries without item
+       /// - remove children when parent got lost
+       /// - set contact-id in item when not present
+}
+
 if (array_search(__file__,get_included_files())===0){
        cron_run($_SERVER["argv"],$_SERVER["argc"]);
        killme();