summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/class-giglogadmin-concert.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/includes/class-giglogadmin-concert.php b/includes/class-giglogadmin-concert.php
index c6223cb..a4513db 100644
--- a/includes/class-giglogadmin-concert.php
+++ b/includes/class-giglogadmin-concert.php
@@ -82,7 +82,20 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) {
* @return null|self
*/
public static function get( int $id ) : ?self {
- return self::find_concerts( array( 'id' => $id ) )[0];
+ $gigs = self::find_concerts( array( 'id' => $id ) );
+ $count = count( $gigs );
+
+ if ( $count > 1 ) {
+ error_log(
+ "Found more than one concert with the same id ({$id})."
+ . ' This should not happen!'
+ );
+ wp_die( 'Oops! Something went wrong', 500 );
+ } else if ( $count != 1 ) {
+ return null;
+ } else {
+ return array_shift( $gigs );
+ }
}
/**