Fixing a fatal error when installing extensions with Option Values
authorOmar abu hussein <opetmar91@gmail.com>
Mon, 28 Oct 2019 15:55:35 +0000 (15:55 +0000)
committerOmar abu hussein <opetmar91@gmail.com>
Mon, 28 Oct 2019 15:55:35 +0000 (15:55 +0000)
commit45a8391eaeb0a01cd78942be23b8c7280ba57ed1
tree5b2654fc0f977b1e914f7b6f4e13b9acde677bd5
parentcbaa9a31f02afda8d2e19610da823fd0c4d28a16
Fixing a fatal error when installing extensions with Option Values
defined in XML

If an Extension has an option value defined in an XML file and the
option value belongs to an option group that is already defined in Civi
But in the XML (e.g activity_type option group) then installing the
extension will result in a fatal error with the following message :

"A fatal error was triggered: One of parameters (value: ) is not of the type Integer"

The error happen because CiviCRM fails to find the option group in the
XML file so it look for it in the database, but the code that look for
it pass the option group name as a SimpleXML object (since SimpleXML
does not return scalar values and rather objects of Type SimpleXML) and
because of that the code won't be able to find the value which will
result in executing a query that expect an integer but rather a NULL
pass to it which result in the fatal error.

I fixed it by casting the option group name inside the SimpleXML object
to string.
CRM/Utils/Migrate/Import.php