mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Use more canonical (object)[] instead of new stdClass
Both styles create the exact same object. Casting an array to an object creates an stdClass object as well. The main benefit of this syntax is that there is much less repetition. Everything is one token instead of individual lines, where each line might contain a typo. Change-Id: Id43fa2c4b6bd5d9dbc60008427d4a9e14ae3811c
This commit is contained in:
parent
9474b9c942
commit
e5fead8b42
|
@ -392,24 +392,25 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
- (int)$timestampsByWiki[$a]->getTimestamp( TS_UNIX );
|
||||
} );
|
||||
|
||||
$row = new stdClass;
|
||||
$row->event_id = -1;
|
||||
$row->event_type = 'foreign';
|
||||
$row->event_variant = null;
|
||||
$row->event_agent_id = $user->getId();
|
||||
$row->event_agent_ip = null;
|
||||
$row->event_page_id = null;
|
||||
$row->event_extra = serialize( [
|
||||
'section' => $section ?: 'all',
|
||||
'wikis' => $wikis,
|
||||
'count' => $count
|
||||
] );
|
||||
$row->event_deleted = 0;
|
||||
$row = (object)[
|
||||
'event_id' => -1,
|
||||
'event_type' => 'foreign',
|
||||
'event_variant' => null,
|
||||
'event_agent_id' => $user->getId(),
|
||||
'event_agent_ip' => null,
|
||||
'event_page_id' => null,
|
||||
'event_extra' => serialize( [
|
||||
'section' => $section ?: 'all',
|
||||
'wikis' => $wikis,
|
||||
'count' => $count
|
||||
] ),
|
||||
'event_deleted' => 0,
|
||||
|
||||
$row->notification_user = $user->getId();
|
||||
$row->notification_timestamp = $maxTimestamp;
|
||||
$row->notification_read_timestamp = null;
|
||||
$row->notification_bundle_hash = md5( 'bogus' );
|
||||
'notification_user' => $user->getId(),
|
||||
'notification_timestamp' => $maxTimestamp,
|
||||
'notification_read_timestamp' => null,
|
||||
'notification_bundle_hash' => md5( 'bogus' ),
|
||||
];
|
||||
|
||||
// Format output like any other notification
|
||||
$notif = EchoNotification::newFromRow( $row );
|
||||
|
|
|
@ -134,7 +134,7 @@ class NotificationControllerTest extends MediaWikiTestCase {
|
|||
// expected result
|
||||
[ 123 ],
|
||||
// users returned from locator
|
||||
[ null, 'foo', User::newFromId( 123 ), new stdClass, 456 ],
|
||||
[ null, 'foo', User::newFromId( 123 ), (object)[], 456 ],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue