mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Remove use of NULL_DATE constant in core
The NULL_DATE constant is defined conditionally in the DBA static class. This causes issues with static analyzing tools like PHPStan, because they can not really know if the constant is defined or not. We could make PHPStan ignore this, but since there already is a `get_null_date()` method on the `dba_driver` class, this patch changes the code to use this method instead. We could also use the public static attribute `$null_date` on the DBA class directly, but using a method feels cleaner, and allows for making the attribute private, or even removing it completely at some later time. I'm not removing the NULL_DATE constant for now, in case it is in use by any extensions.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* @brief Some functions to work with XML feeds.
|
||||
*/
|
||||
|
||||
use DBA;
|
||||
use Zotlabs\Lib\Config;
|
||||
use Zotlabs\Lib\MessageFilter;
|
||||
|
||||
@@ -25,7 +26,7 @@ function get_public_feed($channel, $params) {
|
||||
$params = [];
|
||||
|
||||
$params['type'] = ((x($params,'type')) ? $params['type'] : 'xml');
|
||||
$params['begin'] = ((x($params,'begin')) ? $params['begin'] : NULL_DATE);
|
||||
$params['begin'] = ((x($params,'begin')) ? $params['begin'] : DBA::$dba->get_null_date());
|
||||
$params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now'));
|
||||
$params['start'] = ((x($params,'start')) ? $params['start'] : 0);
|
||||
$params['records'] = ((x($params,'records')) ? $params['records'] : 40);
|
||||
@@ -1302,7 +1303,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
|
||||
if($r) {
|
||||
$parent_item = $r[0];
|
||||
if(intval($parent_item['item_nocomment']) || $parent_item['comment_policy'] === 'none'
|
||||
|| ($parent_item['comments_closed'] > NULL_DATE && $parent_item['comments_closed'] < datetime_convert())) {
|
||||
|| ($parent_item['comments_closed'] > DBA::$dba->get_null_date() && $parent_item['comments_closed'] < datetime_convert())) {
|
||||
logger('comments disabled for post ' . $parent_item['mid']);
|
||||
continue;
|
||||
}
|
||||
@@ -1459,7 +1460,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
|
||||
|
||||
$datarray['owner_xchan'] = $contact['xchan_hash'];
|
||||
|
||||
if(array_key_exists('created',$datarray) && $datarray['created'] > NULL_DATE && $expire_days) {
|
||||
if(array_key_exists('created',$datarray) && $datarray['created'] > DBA::$dba->get_null_date() && $expire_days) {
|
||||
$t1 = $datarray['created'];
|
||||
$t2 = datetime_convert('UTC','UTC','now - ' . $expire_days . 'days');
|
||||
if($t1 < $t2) {
|
||||
|
||||
Reference in New Issue
Block a user