JoHammer has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/371505 )
Change subject: Change EchoEvent->create to return status or throw exceptions
......................................................................
Change EchoEvent->create to return status or throw exceptions
Bug: T169834
Change-Id: I405bb5c834a25a66df52697595254c50714a728b
---
M includes/model/Event.php
1 file changed, 7 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/05/371505/1
diff --git a/includes/model/Event.php b/includes/model/Event.php
index ecc0941..ab79bd1 100644
--- a/includes/model/Event.php
+++ b/includes/model/Event.php
@@ -103,10 +103,11 @@
global $wgEchoNotifications;
// Do not create event and notifications if write access is
locked
- if ( wfReadOnly()
+ if ( wfReadOnly()
|| MWEchoDbFactory::newFromDefault()->getEchoDb(
DB_MASTER )->isReadOnly()
) {
- return false;
+ $submitStatus = Status::newFatal( 'write access is
locked, no event is created' );
+ return $submitStatus;
}
$obj = new EchoEvent;
@@ -117,7 +118,7 @@
}
if ( !isset( $wgEchoNotifications[$info['type']] ) ) {
- return false;
+ throw new MWException( "echo event is not an enabled
event" );
}
$obj->id = false;
@@ -140,7 +141,7 @@
if ( strlen( $obj->serializeExtra() ) > 50000 ) {
wfDebugLog( __CLASS__, __FUNCTION__ . ': event extra
data is too huge for ' . $info['type'] );
- return false;
+ throw new MWException( "event extra data is too huge" );
}
if ( $obj->title ) {
@@ -158,7 +159,8 @@
}
if ( !Hooks::run( 'BeforeEchoEventInsert', [ $obj ] ) ) {
- return false;
+ $submitStatus = Status::newFatal( 'a handler aborted
the hook event BeforeEchoEventInsert' );
+ return $submitStatus;
}
// @Todo - Database insert logic should not be inside the model
--
To view, visit https://gerrit.wikimedia.org/r/371505
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I405bb5c834a25a66df52697595254c50714a728b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: JoHammer <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits