| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Notifications\Model; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use InvalidArgumentException; |
| 7 |
use MediaWiki\Extension\Notifications\Bundleable; |
| 8 |
use MediaWiki\Extension\Notifications\Controller\NotificationController; |
| 9 |
use MediaWiki\Extension\Notifications\DbFactory; |
| 10 |
use MediaWiki\Extension\Notifications\Hooks\HookRunner; |
| 11 |
use MediaWiki\Extension\Notifications\Mapper\EventMapper; |
| 12 |
use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper; |
| 13 |
use MediaWiki\Extension\Notifications\Services; |
| 14 |
use MediaWiki\Logger\LoggerFactory; |
| 15 |
use MediaWiki\MediaWikiServices; |
| 16 |
use MediaWiki\Revision\RevisionRecord; |
| 17 |
use MediaWiki\Title\Title; |
| 18 |
use MediaWiki\User\User; |
| 19 |
use MediaWiki\User\UserIdentity; |
| 20 |
use RuntimeException; |
| 21 |
use stdClass; |
| 22 |
use Wikimedia\Rdbms\IDBAccessObject; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class Event extends AbstractEntity implements Bundleable { |
| 29 |
|
| 30 |
|
| 31 |
protected $type = null; |
| 32 |
|
| 33 |
protected $id = null; |
| 34 |
|
| 35 |
protected $variant = null; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
protected $agent = null; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
protected $title = null; |
| 47 |
|
| 48 |
protected $pageId = null; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
protected $revision = null; |
| 56 |
|
| 57 |
|
| 58 |
protected $extra = []; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
protected $timestamp = null; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
protected $bundleHash; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
protected $bundledEvents; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
protected $deleted = 0; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
protected function __construct() { |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
public function __sleep() { |
| 99 |
if ( !$this->id ) { |
| 100 |
throw new RuntimeException( "Unable to serialize an uninitialized Event" ); |
| 101 |
} |
| 102 |
|
| 103 |
return [ 'id', 'timestamp' ]; |
| 104 |
} |
| 105 |
|
| 106 |
public function __wakeup() { |
| 107 |
$this->loadFromID( $this->id ); |
| 108 |
} |
| 109 |
|
| 110 |
public function __toString() { |
| 111 |
return "Event(id={$this->id}; type={$this->type})"; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
public static function create( $info = [] ) { |
| 138 |
global $wgEchoNotifications; |
| 139 |
|
| 140 |
$services = MediaWikiServices::getInstance(); |
| 141 |
|
| 142 |
if ( $services->getReadOnlyMode()->isReadOnly() |
| 143 |
|| DbFactory::newFromDefault()->getEchoDb( DB_PRIMARY )->isReadOnly() |
| 144 |
) { |
| 145 |
return false; |
| 146 |
} |
| 147 |
|
| 148 |
$obj = new Event; |
| 149 |
static $validFields = [ 'type', 'variant', 'agent', 'title', 'extra' ]; |
| 150 |
|
| 151 |
if ( empty( $info['type'] ) ) { |
| 152 |
throw new InvalidArgumentException( "'type' parameter is mandatory" ); |
| 153 |
} |
| 154 |
|
| 155 |
if ( !isset( $wgEchoNotifications[$info['type']] ) ) { |
| 156 |
return false; |
| 157 |
} |
| 158 |
|
| 159 |
$obj->id = false; |
| 160 |
$obj->timestamp = $info['timestamp'] ?? wfTimestampNow(); |
| 161 |
foreach ( $validFields as $field ) { |
| 162 |
if ( isset( $info[$field] ) ) { |
| 163 |
$obj->$field = $info[$field]; |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
if ( strlen( $obj->serializeExtra() ) > 50000 ) { |
| 172 |
wfDebugLog( __CLASS__, __FUNCTION__ . ': event extra data is too huge for ' . $info['type'] ); |
| 173 |
|
| 174 |
return false; |
| 175 |
} |
| 176 |
|
| 177 |
if ( $obj->title ) { |
| 178 |
if ( !$obj->title instanceof Title ) { |
| 179 |
throw new InvalidArgumentException( 'Invalid title parameter' ); |
| 180 |
} |
| 181 |
$obj->setTitle( $obj->title ); |
| 182 |
} |
| 183 |
|
| 184 |
if ( $obj->agent ) { |
| 185 |
if ( !$obj->agent instanceof UserIdentity ) { |
| 186 |
throw new InvalidArgumentException( "Invalid user parameter" ); |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
if ( !$obj->agent instanceof User ) { |
| 191 |
$obj->agent = $services->getUserFactory()->newFromUserIdentity( $obj->agent ); |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
$hookRunner = new HookRunner( $services->getHookContainer() ); |
| 196 |
if ( !$hookRunner->onBeforeEchoEventInsert( $obj ) ) { |
| 197 |
return false; |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
$obj->insert(); |
| 202 |
|
| 203 |
$hookRunner->onEventInsertComplete( $obj ); |
| 204 |
|
| 205 |
global $wgEchoUseJobQueue; |
| 206 |
|
| 207 |
NotificationController::notify( $obj, $wgEchoUseJobQueue ); |
| 208 |
|
| 209 |
$stats = $services->getStatsdDataFactory(); |
| 210 |
$type = $info['type']; |
| 211 |
$stats->increment( 'echo.event.all' ); |
| 212 |
$stats->increment( "echo.event.$type" ); |
| 213 |
|
| 214 |
return $obj; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
public function toDbArray() { |
| 222 |
$data = [ |
| 223 |
'event_type' => $this->type, |
| 224 |
'event_variant' => $this->variant, |
| 225 |
'event_deleted' => $this->deleted, |
| 226 |
'event_extra' => $this->serializeExtra() |
| 227 |
]; |
| 228 |
if ( $this->id ) { |
| 229 |
$data['event_id'] = $this->id; |
| 230 |
} |
| 231 |
if ( $this->agent ) { |
| 232 |
if ( !$this->agent->isRegistered() ) { |
| 233 |
$data['event_agent_ip'] = $this->agent->getName(); |
| 234 |
} else { |
| 235 |
$data['event_agent_id'] = $this->agent->getId(); |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
if ( $this->pageId ) { |
| 240 |
$data['event_page_id'] = $this->pageId; |
| 241 |
} elseif ( $this->title ) { |
| 242 |
$pageId = $this->title->getArticleID(); |
| 243 |
|
| 244 |
|
| 245 |
if ( $pageId ) { |
| 246 |
$data['event_page_id'] = $pageId; |
| 247 |
} |
| 248 |
} |
| 249 |
|
| 250 |
return $data; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
public function isEnabledEvent(): bool { |
| 258 |
global $wgEchoNotifications; |
| 259 |
return isset( $wgEchoNotifications[$this->getType()] ); |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
protected function insert() { |
| 266 |
$eventMapper = new EventMapper(); |
| 267 |
$this->id = $eventMapper->insert( $this ); |
| 268 |
|
| 269 |
$targetPages = self::resolveTargetPages( $this->getExtraParam( 'target-page' ) ); |
| 270 |
if ( $targetPages ) { |
| 271 |
$targetMapper = new TargetPageMapper(); |
| 272 |
foreach ( $targetPages as $title ) { |
| 273 |
$targetPage = TargetPage::create( $title, $this ); |
| 274 |
if ( $targetPage ) { |
| 275 |
$targetMapper->insert( $targetPage ); |
| 276 |
} |
| 277 |
} |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
protected static function resolveTargetPages( $targetPageIds ) { |
| 286 |
if ( !$targetPageIds ) { |
| 287 |
return []; |
| 288 |
} |
| 289 |
if ( !is_array( $targetPageIds ) ) { |
| 290 |
$targetPageIds = [ $targetPageIds ]; |
| 291 |
} |
| 292 |
$result = []; |
| 293 |
foreach ( $targetPageIds as $targetPageId ) { |
| 294 |
|
| 295 |
$title = Title::newFromID( $targetPageId ); |
| 296 |
|
| 297 |
if ( !$title ) { |
| 298 |
$title = Title::newFromID( $targetPageId, IDBAccessObject::READ_LATEST ); |
| 299 |
} |
| 300 |
if ( $title ) { |
| 301 |
$result[] = $title; |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
return $result; |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
public function loadFromRow( $row ) { |
| 315 |
$this->id = (int)$row->event_id; |
| 316 |
$this->type = $row->event_type; |
| 317 |
|
| 318 |
|
| 319 |
if ( !$this->timestamp ) { |
| 320 |
if ( isset( $row->notification_timestamp ) ) { |
| 321 |
$this->timestamp = wfTimestamp( TS_MW, $row->notification_timestamp ); |
| 322 |
} else { |
| 323 |
$this->timestamp = wfTimestampNow(); |
| 324 |
} |
| 325 |
} |
| 326 |
|
| 327 |
$this->variant = $row->event_variant; |
| 328 |
try { |
| 329 |
$this->extra = $row->event_extra ? unserialize( $row->event_extra ) : []; |
| 330 |
} catch ( Exception $e ) { |
| 331 |
|
| 332 |
LoggerFactory::getInstance( 'Echo' )->warning( |
| 333 |
'Failed to unserialize event {id}', |
| 334 |
[ |
| 335 |
'id' => $row->event_id |
| 336 |
] |
| 337 |
); |
| 338 |
return false; |
| 339 |
} |
| 340 |
$this->pageId = $row->event_page_id; |
| 341 |
$this->deleted = $row->event_deleted; |
| 342 |
|
| 343 |
if ( $row->event_agent_id ) { |
| 344 |
$this->agent = User::newFromId( (int)$row->event_agent_id ); |
| 345 |
} elseif ( $row->event_agent_ip ) { |
| 346 |
$this->agent = User::newFromName( (string)$row->event_agent_ip, false ); |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
if ( |
| 351 |
isset( $this->extra['page_title'] ) && isset( $this->extra['page_namespace'] ) |
| 352 |
&& !$row->event_page_id |
| 353 |
) { |
| 354 |
$this->title = Title::makeTitleSafe( |
| 355 |
$this->extra['page_namespace'], |
| 356 |
$this->extra['page_title'] |
| 357 |
); |
| 358 |
} |
| 359 |
if ( $row->event_page_id ) { |
| 360 |
$titleCache = Services::getInstance()->getTitleLocalCache(); |
| 361 |
$titleCache->add( (int)$row->event_page_id ); |
| 362 |
} |
| 363 |
if ( isset( $this->extra['revid'] ) && $this->extra['revid'] ) { |
| 364 |
$revisionCache = Services::getInstance()->getRevisionLocalCache(); |
| 365 |
$revisionCache->add( $this->extra['revid'] ); |
| 366 |
} |
| 367 |
|
| 368 |
return true; |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
public function loadFromID( $id, $fromPrimary = false ) { |
| 378 |
$eventMapper = new EventMapper(); |
| 379 |
$event = $eventMapper->fetchById( $id, $fromPrimary ); |
| 380 |
if ( !$event ) { |
| 381 |
return false; |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
$this->id = $event->id; |
| 386 |
$this->type = $event->type; |
| 387 |
$this->variant = $event->variant; |
| 388 |
$this->extra = $event->extra; |
| 389 |
$this->pageId = $event->pageId; |
| 390 |
$this->agent = $event->agent; |
| 391 |
$this->title = $event->title; |
| 392 |
$this->deleted = $event->deleted; |
| 393 |
|
| 394 |
if ( !$this->timestamp ) { |
| 395 |
$this->timestamp = $event->timestamp; |
| 396 |
} |
| 397 |
|
| 398 |
return true; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
public static function newFromRow( $row ) { |
| 408 |
$obj = new Event(); |
| 409 |
return $obj->loadFromRow( $row ) |
| 410 |
? $obj |
| 411 |
: false; |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
public static function newFromID( $id ) { |
| 421 |
$obj = new Event(); |
| 422 |
return $obj->loadFromID( $id ) |
| 423 |
? $obj |
| 424 |
: false; |
| 425 |
} |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
public function serializeExtra() { |
| 432 |
if ( is_array( $this->extra ) || is_object( $this->extra ) ) { |
| 433 |
$extra = serialize( $this->extra ); |
| 434 |
} elseif ( $this->extra === null ) { |
| 435 |
$extra = null; |
| 436 |
} else { |
| 437 |
$extra = serialize( [ $this->extra ] ); |
| 438 |
} |
| 439 |
|
| 440 |
return $extra; |
| 441 |
} |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
public function userCan( $field, User $user ) { |
| 455 |
$revision = $this->getRevision(); |
| 456 |
|
| 457 |
if ( $field === RevisionRecord::DELETED_USER ) { |
| 458 |
$agent = $this->getAgent(); |
| 459 |
if ( !$agent ) { |
| 460 |
|
| 461 |
return true; |
| 462 |
} |
| 463 |
|
| 464 |
if ( |
| 465 |
$revision |
| 466 |
&& $agent->getName() === $revision->getUser( RevisionRecord::RAW )->getName() |
| 467 |
) { |
| 468 |
|
| 469 |
return $revision->audienceCan( $field, RevisionRecord::FOR_THIS_USER, $user ); |
| 470 |
} else { |
| 471 |
|
| 472 |
$permManager = MediaWikiServices::getInstance()->getPermissionManager(); |
| 473 |
return $permManager->userHasAnyRight( $user, 'viewsuppressed', 'hideuser' ) |
| 474 |
|| !$agent->isHidden(); |
| 475 |
} |
| 476 |
} elseif ( $revision ) { |
| 477 |
|
| 478 |
return $revision->audienceCan( $field, RevisionRecord::FOR_THIS_USER, $user ); |
| 479 |
} else { |
| 480 |
|
| 481 |
return true; |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
public function getId() { |
| 491 |
return $this->id; |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public function getTimestamp() { |
| 498 |
return $this->timestamp; |
| 499 |
} |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
public function getType() { |
| 505 |
return $this->type; |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
public function getVariant() { |
| 512 |
return $this->variant; |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
public function getExtra() { |
| 519 |
return $this->extra; |
| 520 |
} |
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
public function getExtraParam( $key, $default = null ) { |
| 528 |
return $this->extra[$key] ?? $default; |
| 529 |
} |
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
public function getAgent() { |
| 535 |
return $this->agent; |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
public function canNotifyAgent() { |
| 547 |
global $wgEchoNotifications; |
| 548 |
$allowedInConfig = $wgEchoNotifications[$this->getType()]['canNotifyAgent'] ?? false; |
| 549 |
$allowedInExtra = $this->getExtraParam( 'notifyAgent', false ); |
| 550 |
return $allowedInConfig || $allowedInExtra; |
| 551 |
} |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
public function getTitle( $fromPrimary = false ) { |
| 558 |
if ( $this->title ) { |
| 559 |
return $this->title; |
| 560 |
} |
| 561 |
if ( $this->pageId ) { |
| 562 |
$titleCache = Services::getInstance()->getTitleLocalCache(); |
| 563 |
$title = $titleCache->get( $this->pageId ); |
| 564 |
if ( $title ) { |
| 565 |
$this->title = $title; |
| 566 |
return $this->title; |
| 567 |
} |
| 568 |
$this->title = Title::newFromID( $this->pageId, $fromPrimary ? IDBAccessObject::READ_LATEST : 0 ); |
| 569 |
if ( $this->title ) { |
| 570 |
return $this->title; |
| 571 |
} |
| 572 |
} |
| 573 |
if ( isset( $this->extra['page_title'] ) && isset( $this->extra['page_namespace'] ) ) { |
| 574 |
$this->title = Title::makeTitleSafe( |
| 575 |
$this->extra['page_namespace'], |
| 576 |
$this->extra['page_title'] |
| 577 |
); |
| 578 |
return $this->title; |
| 579 |
} |
| 580 |
return null; |
| 581 |
} |
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
public function getPageId(): ?int { |
| 587 |
return $this->pageId; |
| 588 |
} |
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
public function getRevision() { |
| 594 |
if ( $this->revision ) { |
| 595 |
return $this->revision; |
| 596 |
} |
| 597 |
|
| 598 |
if ( isset( $this->extra['revid'] ) ) { |
| 599 |
$revisionCache = Services::getInstance()->getRevisionLocalCache(); |
| 600 |
$revision = $revisionCache->get( $this->extra['revid'] ); |
| 601 |
if ( $revision ) { |
| 602 |
$this->revision = $revision; |
| 603 |
return $this->revision; |
| 604 |
} |
| 605 |
|
| 606 |
$store = MediaWikiServices::getInstance()->getRevisionStore(); |
| 607 |
$this->revision = $store->getRevisionById( $this->extra['revid'] ); |
| 608 |
return $this->revision; |
| 609 |
} |
| 610 |
|
| 611 |
return null; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
public function getCategory() { |
| 619 |
return Services::getInstance()->getAttributeManager()->getNotificationCategory( $this->type ); |
| 620 |
} |
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
public function getSection() { |
| 627 |
return Services::getInstance()->getAttributeManager()->getNotificationSection( $this->type ); |
| 628 |
} |
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
public function getUseJobQueue() { |
| 635 |
global $wgEchoNotifications; |
| 636 |
if ( isset( $wgEchoNotifications[$this->type]['immediate'] ) ) { |
| 637 |
return !(bool)$wgEchoNotifications[$this->type]['immediate']; |
| 638 |
} |
| 639 |
|
| 640 |
return true; |
| 641 |
} |
| 642 |
|
| 643 |
public function setType( $type ) { |
| 644 |
$this->type = $type; |
| 645 |
} |
| 646 |
|
| 647 |
public function setVariant( $variant ) { |
| 648 |
$this->variant = $variant; |
| 649 |
} |
| 650 |
|
| 651 |
public function setAgent( User $agent ) { |
| 652 |
$this->agent = $agent; |
| 653 |
} |
| 654 |
|
| 655 |
public function setTitle( Title $title ) { |
| 656 |
$this->title = $title; |
| 657 |
$pageId = $title->getArticleID(); |
| 658 |
if ( $pageId ) { |
| 659 |
$this->pageId = $pageId; |
| 660 |
} else { |
| 661 |
$this->extra['page_title'] = $title->getDBkey(); |
| 662 |
$this->extra['page_namespace'] = $title->getNamespace(); |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
public function setExtra( $name, $value ) { |
| 667 |
$this->extra[$name] = $value; |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
public function getLinkMessage( $rank ) { |
| 677 |
global $wgEchoNotifications; |
| 678 |
$type = $this->getType(); |
| 679 |
return $wgEchoNotifications[$type][$rank . '-link']['message'] ?? ''; |
| 680 |
} |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
public function getLinkDestination( $rank ) { |
| 689 |
global $wgEchoNotifications; |
| 690 |
$type = $this->getType(); |
| 691 |
return $wgEchoNotifications[$type][$rank . '-link']['destination'] ?? ''; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
public function getBundleHash() { |
| 698 |
return $this->bundleHash; |
| 699 |
} |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
public function setBundleHash( $hash ) { |
| 705 |
$this->bundleHash = $hash; |
| 706 |
} |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
public function isDeleted() { |
| 712 |
return $this->deleted === 1; |
| 713 |
} |
| 714 |
|
| 715 |
public function setBundledEvents( array $events ) { |
| 716 |
$this->bundledEvents = $events; |
| 717 |
} |
| 718 |
|
| 719 |
public function getBundledEvents() { |
| 720 |
return $this->bundledEvents; |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
public function canBeBundled() { |
| 727 |
return true; |
| 728 |
} |
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
public function getBundlingKey() { |
| 734 |
return $this->getBundleHash(); |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
public function setBundledElements( array $bundleables ) { |
| 741 |
$this->setBundledEvents( $bundleables ); |
| 742 |
} |
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
public function getSortingKey() { |
| 748 |
return $this->getTimestamp(); |
| 749 |
} |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
public static function selectFields() { |
| 757 |
return [ |
| 758 |
'event_id', |
| 759 |
'event_type', |
| 760 |
'event_variant', |
| 761 |
'event_agent_id', |
| 762 |
'event_agent_ip', |
| 763 |
'event_extra', |
| 764 |
'event_page_id', |
| 765 |
'event_deleted', |
| 766 |
]; |
| 767 |
} |
| 768 |
|
| 769 |
} |
| 770 |
|
| 771 |
class_alias( Event::class, 'EchoEvent' ); |