Skip to content

Commit

Permalink
Prevent a "new entity found" exception for sessions that aren't tracked
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhartless committed Jan 31, 2019
1 parent 851d760 commit 28f689e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/bundles/DynamicContentBundle/Model/DynamicContentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ public function getSlotContentForLead($slot, $lead)
*/
public function createStatEntry(DynamicContent $dynamicContent, $lead, $source = null)
{
if (empty($lead)) {
return;
}

if ($lead instanceof Lead && !$lead->getId()) {
return;
}

if (is_array($lead)) {
if (empty($lead['id'])) {
return;
}

$lead = $this->em->getReference('MauticLeadBundle:Lead', $lead['id']);
}

Expand Down
17 changes: 17 additions & 0 deletions plugins/MauticFocusBundle/Model/FocusModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Mautic\CoreBundle\Helper\Chart\LineChart;
use Mautic\CoreBundle\Helper\TemplatingHelper;
use Mautic\CoreBundle\Model\FormModel;
use Mautic\LeadBundle\Entity\Lead;
use Mautic\LeadBundle\Model\FieldModel;
use Mautic\LeadBundle\Model\LeadModel;
use Mautic\PageBundle\Model\TrackableModel;
Expand Down Expand Up @@ -330,6 +331,22 @@ public static function isLightColor($hex, $level = 200)
*/
public function addStat(Focus $focus, $type, $data = null, $lead = null)
{
if (empty($lead)) {
return;
}

if ($lead instanceof Lead && !$lead->getId()) {
return;
}

if (is_array($lead)) {
if (empty($lead['id'])) {
return;
}

$lead = $this->em->getReference('MauticLeadBundle:Lead', $lead['id']);
}

switch ($type) {
case Stat::TYPE_FORM:
/** @var \Mautic\FormBundle\Entity\Submission $data */
Expand Down

0 comments on commit 28f689e

Please sign in to comment.