id = false; $obj->timestamp = wfTimestampNow(); $obj->readTimestamp = null; foreach( $validFields as $field ) { if ( isset($info[$field]) ) { $obj->$field = $info[$field]; } else { throw new MWException( "Field $field is required" ); } } if ( ! $obj->user instanceof User && ! $obj->user instanceof StubObject ) { throw new MWException( "Invalid user parameter: ".get_class($obj->user) ); } if ( !$obj->event instanceof EchoEvent ) { throw new MWException( "Invalid event parameter" ); } $obj->insert(); return $obj; } /** * Adds this new object to the database. */ protected function insert() { $dbw = wfGetDB( DB_MASTER ); $row = array( 'notification_event' => $this->event->getId(), 'notification_user' => $this->user->getId(), 'notification_timestamp' => $dbw->timestamp( $this->timestamp ), 'notification_read_timestamp' => null, ); $dbw->insert( 'echo_notification', $row, __METHOD__ ); } }