Attempt to assign property "activity_date" on null in... leadCapture_override.php on line 141

Dear Friends,

I have upgraded from Joomla 3 to 4 lately and switched to PHP 8.0. I today upgraded to SuiteCRM 7.13.3 from 7.12.6… When I was upgrading SuiteCRM there was some message during upgradation process which talked of some language file being in custom folder…but I don’t remember which file it was.

I guess, the following are not working in PHP 8.0:
ini_set(‘display_errors’, ‘0’);
ini_set(‘display_errors’, ‘1’);

There was no impact when I added any one of the above code…

The first error which I encountered was:

PHP Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, Lead given in /home4/luminisi/public_html/SuiteCRM/leadCapture_override.php:124

The following solution seems to work is:

//if (array_key_exists($k, $person) || array_key_exists($k, $person->field_defs)) {
if (property_exists($person, $k) || array_key_exists($k, $person->field_defs)) {

Now one more error is emerging in the same file:

Fatal error: Uncaught Error: Attempt to assign property "activity_date" on null in ... leadCapture_override.php on line 141

Here the actual code is this:

$campaign_log->activity_date = $timedate->now();

Surrounding code near this line is:

//create campaign log
            $camplog = new CampaignLog();
            $camplog->campaign_id = $_POST['campaign_id'];
            $camplog->related_id = $person->id;
            $camplog->related_type = $person->module_dir;
            $camplog->activity_type = $person->object_name;
            $camplog->target_type = $person->module_dir;
            $campaign_log->activity_date = $timedate->now();
            $camplog->target_id = $person->id;
            if (isset($marketing_data['id'])) {
                $camplog->marketing_id = $marketing_data['id'];
            }
            $camplog->save();

What should I do now?

Soliciting your helping hand,

With thanks,

RK

I have attempted to replace the following:
$campaign_log->activity_date = $timedate->now();

with this:

$camplog->activity_date = $timedate->now();

It seems to work for the time being… But I do NOT know what I am doing here is actually right or wrong.

Thanks to all,

RK

1 Like