We are seeing several errors with regard to keys not set:

1) Warning: Undefined array key "_cvar" in Drupal\visitors\Service\TrackerService->write() (line 112 of /modules/contrib/visitors/src/Service/TrackerService.php) [ addressed in issue https://www.drupal.org/project/visitors/issues/3389685 ]

2) The various errors reported here: https://www.drupal.org/project/visitors/issues/3380760

In ADDITION we are seeing these new errors:

3) Warning: Undefined array key "url" in Drupal\visitors\Service\TrackerService->write() (line 129 of \modules\contrib\visitors\src\Service\TrackerService.php)
4) Warning: Undefined array key "uid" in Drupal\visitors\Service\TrackerService->write() (line 126 of \modules\contrib\visitors\src\Service\TrackerService.php)

The underlying issue, in all cases, seems to be that $agent may not always have all values set.

Therefore, I would suggest to give reasonable default values for all $agent values, just in case if one is missing.

In our case, I added this code, just to get past this, but there are other $agent values, and these should have defaults as well. I am not sure what you may use as a "reasonable default", but all values should get one.

if ( !isset($agent['uid']))
        $agent['uid'] = \Drupal::currentUser()->id();

if ( !isset($agent['url'])){
      $current_path = \Drupal::service('path.current')->getPath();
      $agent['url'] = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);
}
CommentFileSizeAuthor
#6 visitors_3413155.patch4.26 KBabhishek_gupta1

Issue fork visitors-3413155

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hoporr created an issue. See original summary.

hoporr’s picture

Issue summary: View changes
bluegeek9’s picture

I believe this has already been fixed in dev.

abhishek_gupta1 made their first commit to this issue’s fork.

abhishek_gupta1’s picture

Status: Active » Needs review
StatusFileSize
new4.26 KB

@hoporr, I have fixed the issue and created Patch. please kindly review the Patch file

bluegeek9’s picture

Status: Needs review » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support to this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bluegeek9’s picture

This issue was resolved. A new release, 8.x-2.17, will be made soon, May 31st.

This is an excellent opportunity to beta test the dev branch, and report any issues.

Contributors (5)

bluegeek9, roshni27, abhishek_gupta1, sarwan_verma, SandeepSingh199

Changelog

Issues: 32 issues resolved.

Changes since 8.x-2.16:

Bug

Feature

Task