[Bug] $entity_model::isColumnNullable() broken for models that extend abstract class that uses CrudTrait #3063
Labels
Minor Bug
A bug that happens only in a very niche or specific use case.
Possible Bug
A bug that was reported but not confirmed yet.
Bug report
What I did
Upgraded to v4.1 following instructions in documentation.
What I expected to happen
I expected my CrudControllers for my model classes that extend a common abstract model class to continue working as they did for v3.6 and v4.0.
What happened
Use of the select2 field (and similar/related fields) causes a
Cannot instantiate abstract class
exception. Whennew self
is called inHasRelationshipFields::getConnectionWithExtraTypeMappings()
, "self" references the abstract class rather than actual CRUD model.What I've already tried to fix it
I've bypassed my abstract class to extend Eloquent and use CrudTrait directly. Doing this for all of my crud models would allow the app to function, but it would also add a lot of boilerplate to each model.
The exception traces to the select2 field's use of
isColumnNullable()
, which was a CrudTrait method in previous versions. Any other field that usesisColumnNullable()
is definitely affected by this. (see: https://github.com/Laravel-Backpack/CRUD/blob/4.0.61/src/app/Models/Traits/CrudTrait.php#L54)That path ultimately leads to
HasRelationshipFields::getConnectionWithExtraTypeMappings()
which appears to needlessly re-instantiate after having been called on an instance. Basically, shouldn't this line -- https://github.com/Laravel-Backpack/CRUD/blob/4.1.15/src/app/Models/Traits/HasRelationshipFields.php#L25 -- just use$this->getConnectionName()
?Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
LARAVEL VERSION:
v7.21.0@3ccdb116524de408fdc00715b6f06a1031ddace9
BACKPACK VERSION:
4.1.15@6c751de946a9c8511dd32eb7bfa3ca6a568849f5
The text was updated successfully, but these errors were encountered: