I am using a module which is often updated by the developing company.
In one php file (cat_product_get.php) of this module is the here below function :
function getColSettingsAsXML()
Inside this function is the following code :
{
foreach($colSettings[$col]['options'] AS $k => $v)
{
$xml.='<option value="'.str_replace('"','\'',$k).'"><![CDATA['.$v.']]></option>';
}
}
Such code leads to the following warning : PHP Warning: Invalid argument supplied for foreach() in ../cat_product_get.php on line 317
Line 317 is the following :
foreach($colSettings[$col]['options'] AS $k => $v)
To fix the warning, I added one line as follows :
if (is_array($colSettings[$col]['options']) || is_object($colSettings[$col]['options']))
{
foreach($colSettings[$col]['options'] AS $k => $v)
{
$xml.='<option value="'.str_replace('"','\'',$k).'"><![CDATA['.$v.']]></option>';
}
}
But at each module update, I have to amend again the cat_product_get.php.
I tried to convince many times the developer to add the suited line in his code. But the developer refused to do it.
Is there a way to add somewhere an override to avoid the line addition at each module update ?
I am not a developer...
I thank you in advance for any reply.
Patrick
If the function is just a plain function, then it can't be done in PHP. You can't have duplicate function names.
If it is a function in a class (aka a method), you can extend that class and just rewrite the function, and use your class.
class Person
{
public function fixThisCrap()
{
return 'the wrong stuff';
}
// more functions
}
class MyPerson extends Person
{
public function fixThisCrap()
{
return 'the correct stuff';
}
// parent class functions will be available, no need to code
}