From 8045b78bc2032f772e35d1bf484541332336c7e0 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 17:19:22 +0200 Subject: Fix constructing concerts if only venue id passed. The previous changes required the full venue data to be included in the constructor. This patch ensures that we handle the old case, where only the venue id was passed in. We still should get the full concert object including the venue name and city back. --- includes/concert.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'includes/concert.php') diff --git a/includes/concert.php b/includes/concert.php index 8c99c42..e3c32e8 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -31,13 +31,18 @@ if ( !class_exists('GiglogAdmin_Concert') ) { if ( isset( $attrs->venue ) ) { - $venue_attrs = (object) [ - "id" => $attrs->venue, - "wpgvenue_name" => $attrs->wpgvenue_name, - "wpgvenue_city" => $attrs->wpgvenue_city, - ]; - - $this->venue = new GiglogAdmin_Venue($venue_attrs); + if (isset($attrs->wpgvenue_name) && isset($attrs->wpgvenue_city)) { + $venue_attrs = (object) [ + "id" => $attrs->venue, + "wpgvenue_name" => $attrs->wpgvenue_name, + "wpgvenue_city" => $attrs->wpgvenue_city, + ]; + + $this->venue = new GiglogAdmin_Venue($venue_attrs); + } + else { + $this->venue = GiglogAdmin_Venue::get($attrs->venue); + } } } -- cgit v1.2.3