Merge pull request #10003 from annando/issue-9799
issue-9799: Ensure that the first post date is after the registration
This commit is contained in:
commit
ba0b6c679f
|
@ -463,7 +463,7 @@ class Widget
|
||||||
|
|
||||||
$cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
|
$cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
|
||||||
$dthen = DI::cache()->get($cachekey);
|
$dthen = DI::cache()->get($cachekey);
|
||||||
if (!empty($dthen)) {
|
if (empty($dthen)) {
|
||||||
$dthen = Item::firstPostDate($uid, $wall);
|
$dthen = Item::firstPostDate($uid, $wall);
|
||||||
DI::cache()->set($cachekey, $dthen, Duration::HOUR);
|
DI::cache()->set($cachekey, $dthen, Duration::HOUR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2177,9 +2177,15 @@ class Item
|
||||||
|
|
||||||
public static function firstPostDate($uid, $wall = false)
|
public static function firstPostDate($uid, $wall = false)
|
||||||
{
|
{
|
||||||
$condition = ['gravity' => GRAVITY_PARENT, 'uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true];
|
$user = User::getById($uid, ['register_date']);
|
||||||
|
if (empty($user)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = ["`uid` = ? AND `wall` = ? AND NOT `deleted` AND `visible` AND `received` >= ?",
|
||||||
|
$uid, $wall, $user['register_date']];
|
||||||
$params = ['order' => ['received' => false]];
|
$params = ['order' => ['received' => false]];
|
||||||
$thread = Post::selectFirst(['received'], $condition, $params);
|
$thread = Post::selectFirstThread(['received'], $condition, $params);
|
||||||
if (DBA::isResult($thread)) {
|
if (DBA::isResult($thread)) {
|
||||||
$postdate = substr(DateTimeFormat::local($thread['received']), 0, 10);
|
$postdate = substr(DateTimeFormat::local($thread['received']), 0, 10);
|
||||||
return $postdate;
|
return $postdate;
|
||||||
|
|
|
@ -181,6 +181,31 @@ class Post
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single record from the post-thread table and returns it in an associative array
|
||||||
|
*
|
||||||
|
* @param array $fields
|
||||||
|
* @param array $condition
|
||||||
|
* @param array $params
|
||||||
|
* @return bool|array
|
||||||
|
* @throws \Exception
|
||||||
|
* @see DBA::select
|
||||||
|
*/
|
||||||
|
public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
|
||||||
|
{
|
||||||
|
$params['limit'] = 1;
|
||||||
|
|
||||||
|
$result = self::selectThread($fields, $condition, $params);
|
||||||
|
|
||||||
|
if (is_bool($result)) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
$row = self::fetch($result);
|
||||||
|
DBA::close($result);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select rows from the post table and returns them as an array
|
* Select rows from the post table and returns them as an array
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user