Merge pull request #5324 from annando/issue-5322

Fixes issue 5322 - events now again are having a plink
This commit is contained in:
Hypolite Petovan 2018-07-04 16:03:26 -04:00 committed by GitHub
commit bd1056a61e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -268,9 +268,9 @@ class Event extends BaseObject
if ($event['id']) { if ($event['id']) {
// has the event actually changed? // has the event actually changed?
$existing_event = dba::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]); $existing_event = dba::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
if ((! DBM::is_result($existing_event)) || ($existing_event['edited'] === $event['edited'])) { if (!DBM::is_result($existing_event) || ($existing_event['edited'] === $event['edited'])) {
$item = dba::selectFirst('item', [], ['event-id' => $event['id'], 'uid' => $event['uid']]); $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
return DBM::is_result($item) ? $item['id'] : 0; return DBM::is_result($item) ? $item['id'] : 0;
} }
@ -289,7 +289,7 @@ class Event extends BaseObject
dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]); dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
$item = dba::selectFirst('item', ['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]); $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBM::is_result($item)) { if (DBM::is_result($item)) {
$object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($event['uri']) . '</id>'; $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($event['uri']) . '</id>';
$object .= '<content>' . xmlify(self::getBBCode($event)) . '</content>'; $object .= '<content>' . xmlify(self::getBBCode($event)) . '</content>';
@ -464,8 +464,7 @@ class Event extends BaseObject
} }
// Query for the event by event id // Query for the event by event id
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, $r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event`
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra", WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
intval($owner_uid), intval($owner_uid),
@ -505,8 +504,7 @@ class Event extends BaseObject
// Query for the event by date. // Query for the event by date.
// @todo Slow query (518 seconds to run), to be optimzed // @todo Slow query (518 seconds to run), to be optimzed
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, $r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event`
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
WHERE `event`.`uid` = %d AND event.ignore = %d WHERE `event`.`uid` = %d AND event.ignore = %d
AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s') AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
@ -542,6 +540,11 @@ class Event extends BaseObject
$last_date = ''; $last_date = '';
$fmt = L10n::t('l, F j'); $fmt = L10n::t('l, F j');
foreach ($event_result as $event) { foreach ($event_result as $event) {
$item = Item::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link'], ['id' => $event['itemid']]);
if (DBM::is_result($item)) {
$event = array_merge($event, $item);
}
$start = $event['adjust'] ? DateTimeFormat::local($event['start'], 'c') : DateTimeFormat::utc($event['start'], 'c'); $start = $event['adjust'] ? DateTimeFormat::local($event['start'], 'c') : DateTimeFormat::utc($event['start'], 'c');
$j = $event['adjust'] ? DateTimeFormat::local($event['start'], 'j') : DateTimeFormat::utc($event['start'], 'j'); $j = $event['adjust'] ? DateTimeFormat::local($event['start'], 'j') : DateTimeFormat::utc($event['start'], 'j');
$day = $event['adjust'] ? DateTimeFormat::local($event['start'], $fmt) : DateTimeFormat::utc($event['start'], $fmt); $day = $event['adjust'] ? DateTimeFormat::local($event['start'], $fmt) : DateTimeFormat::utc($event['start'], $fmt);