@@ -619,13 +619,15 @@ protected function &getRelation(string $name)
619619 }
620620
621621 $ relation = $ this ->relations [$ name ];
622- if (is_array ($ relation ) === true ) {
622+ if (is_array ($ relation ) === true && isset ( $ relation [ 0 ]) ) {
623623 // ActiveRecordData::BELONGS_TO etc
624624 $ relation_type_or_object_name = $ relation [0 ];
625625 $ relation_class = $ relation [1 ] ?? '' ;
626626 $ relation_local_key = $ relation [2 ] ?? '' ;
627627 $ relation_array_callbacks = $ relation [3 ] ?? [];
628628 $ relation_back_reference = $ relation [4 ] ?? '' ;
629+ } else {
630+ return $ relation ;
629631 }
630632
631633 if ($ relation instanceof self || $ relation_type_or_object_name instanceof self) {
@@ -643,7 +645,8 @@ protected function &getRelation(string $name)
643645 if ((!$ relation instanceof self) && self ::HAS_ONE === $ relation_type_or_object_name ) {
644646 $ obj ->eq ($ relation_local_key , $ this ->{$ this ->primaryKey })->find () && $ relation_back_reference && $ obj ->__set ($ relation_back_reference , $ this );
645647 } elseif (self ::HAS_MANY === $ relation_type_or_object_name ) {
646- $ this ->relations [$ name ] = $ obj ->eq ($ relation_local_key , $ this ->{$ this ->primaryKey })->findAll ();
648+ $ results = $ obj ->eq ($ relation_local_key , $ this ->{$ this ->primaryKey })->findAll ();
649+ $ this ->relations [$ name ] = $ results ?: [];
647650 if ($ relation_back_reference ) {
648651 foreach ($ this ->relations [$ name ] as $ o ) {
649652 $ o ->__set ($ relation_back_reference , $ this );
0 commit comments