From 4a7ca0d44fc623a8579390c1653fae83cd390a7d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 19 Jul 2017 05:51:39 +0000 Subject: [PATCH] Fix crash with expiration, false logger constant, no empty postings --- include/dbstructure.php | 2 +- include/items.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index e455ee3333..eaa7d9ce40 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -52,7 +52,7 @@ function update_fail($update_id, $error_message) { // No valid result? if (!dbm::is_result($adminlist)) { - logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING); + logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL); // Don't continue return; diff --git a/include/items.php b/include/items.php index 1e11c08c4b..75b2b09bb9 100644 --- a/include/items.php +++ b/include/items.php @@ -569,9 +569,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $r = q("SELECT expire FROM user WHERE uid = %d", intval($uid)); if (dbm::is_result($r)) { $expire_interval = $r[0]['expire']; - if ($expire_interval>0) { - $expire_date = new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC')); - $created_date = new DateTime($arr['created'], new DateTimeZone('UTC')); + if ($expire_interval > 0) { + $expire_date = datetime_convert('UTC', 'UTC', '- '.$expire_interval.' days'); + $created_date = datetime_convert('UTC', 'UTC', $arr['created']); if ($created_date < $expire_date) { logger('item-store: item created ('.$arr['created'].') before expiration time ('.$expire_date->format(DateTime::W3C).'). ignored. ' . print_r($arr,true), LOGGER_DEBUG); return 0; @@ -654,6 +654,11 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $arr['inform'] = ((x($arr, 'inform')) ? trim($arr['inform']) : ''); $arr['file'] = ((x($arr, 'file')) ? trim($arr['file']) : ''); + // When there is no content then we don't post it + if ($arr['body'].$arr['title'] == '') { + return 0; + } + // Items cannot be stored before they happen ... if ($arr['created'] > datetime_convert()) { $arr['created'] = datetime_convert();