Skip to content

Commit

Permalink
Avoid strlen(null) call on undefined "idvisitor" property (#22991)
Browse files Browse the repository at this point in the history
* Avoid strlen(null) call on undefined "idvisitor" property

The "idvisitor" property can be undefined/null, this must be taken into account to avoid this error:

> strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /.../core/Tracker/Visit.php on line 583

* Use consistent check for undefined "idvisitor" property

This is more in line with other locations in this class.

Co-authored-by: Michal Kleiner <[email protected]>

---------

Co-authored-by: Michal Kleiner <[email protected]>
  • Loading branch information
mbrodala and michalkleiner authored Feb 3, 2025
1 parent b767ef2 commit 0e9af13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/Tracker/Visit.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ private function getVisitStandardLength()
*/
private function setIdVisitorForExistingVisit($valuesToUpdate)
{
if (strlen($this->visitProperties->getProperty('idvisitor')) == Tracker::LENGTH_BINARY_ID) {
$valuesToUpdate['idvisitor'] = $this->visitProperties->getProperty('idvisitor');
$idVisitor = $this->visitProperties->getProperty('idvisitor');
if (!empty($idVisitor) && Tracker::LENGTH_BINARY_ID == strlen($idVisitor)) {
$valuesToUpdate['idvisitor'] = $idVisitor;
}

$visitorId = $this->request->getVisitorId();
Expand Down

0 comments on commit 0e9af13

Please sign in to comment.