From 4137a6250bf95a5ffd793c76e3e890d3783dbaba Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 30 Jul 2021 06:20:10 +0000 Subject: [PATCH] Delayed now return their id on insert --- src/Model/Post/Delayed.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Model/Post/Delayed.php b/src/Model/Post/Delayed.php index 65d29188b5..49bf77a834 100644 --- a/src/Model/Post/Delayed.php +++ b/src/Model/Post/Delayed.php @@ -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; + } } /**