Skip to content

Commit

Permalink
Prevents an exception for DWC and focus requests that aren't tracked (#…
Browse files Browse the repository at this point in the history
…7197)

Prevents an exception for DWC and focus requests that aren't tracked
  • Loading branch information
kuzmany committed May 19, 2019
2 parents 4e1ad92 + c9ac87b commit a26ab81
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/bundles/DynamicContentBundle/Model/DynamicContentModel.php
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
7 changes: 7 additions & 0 deletions app/bundles/LeadBundle/Helper/ContactRequestHelper.php
Expand Up @@ -123,14 +123,21 @@ public function __construct(
public function getContactFromQuery(array $queryFields = [])
{
$this->trackedContact = $this->contactTracker->getContact();

unset($queryFields['page_url']); // This is set now automatically by PageModel
$this->queryFields = $queryFields;

try {
$foundContact = $this->getContactFromUrl();
$this->trackedContact = $foundContact;
$this->contactTracker->setTrackedContact($this->trackedContact);
} catch (ContactNotFoundException $exception) {
}

if (!$this->trackedContact) {
return null;
}

$this->prepareContactFromRequest();

return $this->trackedContact;
Expand Down
17 changes: 17 additions & 0 deletions plugins/MauticFocusBundle/Model/FocusModel.php
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 a26ab81

Please sign in to comment.