]> git.mxchange.org Git - friendica.git/commitdiff
Delayed now return their id on insert
authorMichael <heluecht@pirati.ca>
Fri, 30 Jul 2021 06:20:10 +0000 (06:20 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 30 Jul 2021 06:20:10 +0000 (06:20 +0000)
src/Model/Post/Delayed.php

index 65d29188b54a5cd2b2c277455bb35b008c5a3339..49bf77a8346d9a8a64b139ddff035ea958ebb251 100644 (file)
@@ -43,13 +43,13 @@ class Delayed
         * @param string  $delayed
         * @param array   $taglist
         * @param array   $attachments
-        * @return bool insert success
+        * @return int    ID of the created delayed post entry
         */ 
        public static function add(string $uri, array $item, int $notify = 0, bool $unprepared = false, string $delayed = '', array $taglist = [], array $attachments = [])
        {
                if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
                        Logger::notice('No uid or already found');
-                       return false;
+                       return 0;
                }
 
                if (empty($delayed)) {
@@ -66,7 +66,7 @@ class Delayed
 
                $wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $unprepared, $uri);
                if (!$wid) {
-                       return false;
+                       return 0;
                }
 
                DI::pConfig()->set($item['uid'], 'system', 'last_publish', $next_publish);
@@ -78,7 +78,11 @@ class Delayed
                        'wid'     => $wid,
                ];
 
-               return DBA::insert('delayed-post', $delayed_post, Database::INSERT_IGNORE);
+               if (DBA::insert('delayed-post', $delayed_post, Database::INSERT_IGNORE)) {
+                       return DBA::lastInsertId();
+               } else {
+                       return 0;
+               }
        }
 
        /**