Skip to content

Commit

Permalink
Avoid a PHP Notice: Undefined index: tix_attendee_id (#1430)
Browse files Browse the repository at this point in the history
As we're temporarily allowing users to edit tickets without a connected user, we're hitting the above notice on every ticket edit action.

The `user_must_confirm_ticket()` method first does an `isset()` to return early if `null` is passed in, which is the default behaviour when referring to a array item that does not exist.

This change should have no logic changes as a result, but should result in the PHP Notice ceasing to exist.
  • Loading branch information
dd32 authored Nov 25, 2024
1 parent f33a067 commit 86f6983
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function block_unauthenticated_actions() {
// Temporary: We don't want to block users from editing tickets unless they are unconfirmed.
// See: https://github.com/WordPress/wordcamp.org/issues/1393.
// See: https://github.com/WordPress/wordcamp.org/issues/1420.
if ( $this->user_is_editing_ticket() && ! $this->user_must_confirm_ticket( $_REQUEST['tix_attendee_id'] ) ) {
if ( $this->user_is_editing_ticket() && ! $this->user_must_confirm_ticket( $_REQUEST['tix_attendee_id'] ?? null ) ) {
return;
}

Expand Down Expand Up @@ -200,7 +200,7 @@ public function ticket_form_message() {
}

// Ask the attendee to confirm their registration
if ( $this->user_is_editing_ticket() && $this->user_must_confirm_ticket( $_REQUEST['tix_attendee_id'] ) ) {
if ( $this->user_is_editing_ticket() && $this->user_must_confirm_ticket( $_REQUEST['tix_attendee_id'] ?? null ) ) {
$tickets_selected = array( get_post_meta( $_REQUEST['tix_attendee_id'], 'tix_ticket_id', true ) => 1 ); // mimic $_REQUEST['tix_tickets_selected']

if ( $this->tickets_have_questions( $tickets_selected ) ) {
Expand Down

0 comments on commit 86f6983

Please sign in to comment.