- Issue created by @sah62
- Assigned to abhishek_virasat
- Issue was unassigned.
- Status changed to Needs review
5 months ago 5:03am 4 July 2024 - 🇮🇳India abhishek_virasat
@sah62, I have fixed the issue and created MR. please review it once.
- First commit to issue fork.
- Merge request !145Issue #3458872 by bluegeek9, sah62: Deprecated function: explode(): Passing... → (Merged) created by bluegeek9
- 🇺🇸United States bluegeek9
Hi @sah62,
Thank you for reporting the bug. The visitor_id is generated client-side add stored in the cookie. It is used to track unique visitors. I am guessing the Google crawler does not set cookie values.
`[$visitor_id] = is_string($_pk_id) ? explode('.', $_pk_id) : [];`
-
bluegeek9 →
committed d3ae1e2f on 8.x-2.x
Issue #3458872 by bluegeek9, sah62: Deprecated function: explode():...
-
bluegeek9 →
committed d3ae1e2f on 8.x-2.x
- Status changed to Fixed
5 months ago 12:10am 5 July 2024 - 🇺🇸United States sah62 US
Thanks for the quick replies. I can confirm that the approach described above eliminates the problem.
- 🇺🇸United States sah62 US
Sorry, but I just saw this in my watchdog log:
Warning: Undefined array key 0 in Drupal\visitors\Service\CookieService->getId() (line 40 of /var/www/mysite/web/modules/contrib/visitors/src/Service/CookieService.php)
I believe the code should be changed from this:
[$visitor_id] = is_string($_pk_id) ? explode('.', $_pk_id) : []; return $visitor_id;
to this:
$visitor_id = is_string($_pk_id) ? explode('.', $_pk_id) : []; return $visitor_id;
- Status changed to Active
4 months ago 2:56pm 10 July 2024 - 🇺🇸United States bluegeek9
What about
[$visitor_id] = is_string($_pk_id) ? explode('.', $_pk_id) : [NULL]; return $visitor_id;
I don't know if more than the visitor_id could be in the _pk_id.
- 🇺🇸United States sah62 US
Looking a little deeper: as described in VisitorsCookieInterface.php, the getId() function is supposed to return a string. $visitor_id does not have an initial value. Doing this:
[$visitor_id] =...
sets the value of an array element with an undefined index. The function then returns $visitor_id, which has no value. Maybe this is the right thing to do:
$visitor_id = is_string($_pk_id) ? $_pk_id : ""; return $visitor_id;
This ensures that the value of $visitor_id is set to a string value.
- Merge request !147Issue #3458872 by bluegeek9, sah62: Deprecated function: explode(): Passing... → (Merged) created by bluegeek9
- 🇺🇸United States bluegeek9
Hi @sah62,
Thank you for reporting the warning. I was able to reproduce the 'Undefined array key 0' message. I added unit tests.
The javascript tracking code is from the Matomo project. I do not completely understand it.
This is the value in the cookie. 'fa522cfb5f93fbee' is the unique visitor id. I do not know what '1714423797' is.
"fa522cfb5f93fbee.1714423797." - Status changed to Fixed
4 months ago 4:52pm 10 July 2024 -
bluegeek9 →
committed 5a7332a4 on 8.x-2.x
Issue #3458872 by bluegeek9, sah62: Deprecated function: explode():...
-
bluegeek9 →
committed 5a7332a4 on 8.x-2.x
Automatically closed - issue fixed for 2 weeks with no activity.