Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/event/event-date.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
abstract class Event_Date extends DateTimeImmutable {
protected $event_timezone;
public function __construct( string $date, DateTimeZone $timezone = null ) {
public function __construct( string $date, ?DateTimeZone $timezone = null ) {
if ( ! $timezone ) {
$timezone = new DateTimeZone( 'UTC' );
}
Expand Down
12 changes: 6 additions & 6 deletions includes/event/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
use Wporg\TranslationEvents\Translation_Events;

class InvalidTimeZone extends Exception {
public function __construct( Throwable $previous = null ) {
public function __construct( ?Throwable $previous = null ) {
parent::__construct( 'Event time zone is invalid', 0, $previous );
}
}

class InvalidStart extends Exception {
public function __construct( Throwable $previous = null ) {
public function __construct( ?Throwable $previous = null ) {
parent::__construct( 'Event start is invalid', 0, $previous );
}
}

class InvalidEnd extends Exception {
public function __construct( Throwable $previous = null ) {
public function __construct( ?Throwable $previous = null ) {
parent::__construct( 'Event end is invalid', 0, $previous );
}
}

class InvalidStatus extends Exception {
public function __construct( Throwable $previous = null ) {
public function __construct( ?Throwable $previous = null ) {
parent::__construct( 'Event status is invalid', 0, $previous );
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public function __construct(
string $status,
string $title,
string $description,
DateTimeImmutable $updated_at = null,
?DateTimeImmutable $updated_at = null,
string $attendance_mode = 'onsite'
) {
$this->author_id = $author_id;
Expand Down Expand Up @@ -184,7 +184,7 @@ public function set_description( string $description ): void {
$this->description = $description;
}

public function set_updated_at( DateTimeImmutable $updated_at = null ): void {
public function set_updated_at( ?DateTimeImmutable $updated_at = null ): void {
$this->updated_at = $updated_at ?? Translation_Events::now();
}

Expand Down
5 changes: 2 additions & 3 deletions includes/routes/user/attend-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ public function handle( int $event_id ): void {
$this->die_with_error( esc_html__( 'You are not authorized to change the attendance mode of this attendee', 'gp-translation-events' ), 403 );
}
}
$user = wp_get_current_user();
if ( ! $user ) {
$user_id = get_current_user_id();
if ( ! $user_id ) {
$this->die_with_error( esc_html__( 'Only logged-in users can attend events', 'gp-translation-events' ), 403 );
}
$user_id = $user->ID;

$event = $this->event_repository->get_event( $event_id );
if ( ! $event ) {
Expand Down