I'm getting this warning in my Watchdog log when viewing my list of referers:

Warning: A non-numeric value encountered in Drupal\visitors\Controller\Report\Referers->_getData() (line 144 of /var/www/mysiteweb/modules/contrib/visitors/src/Controller/Report/Referers.php).

Here's the code in question:

143     $page = isset($_GET['page']) ? (int) $_GET['page'] : '';
144     $i = 0 + $page * $items_per_page;

The issue here is that $page can get set to a string value if the expression evaluates to FALSE. Here's the fix:

143     $page = isset($_GET['page']) ? (int) $_GET['page'] : 0;

Issue fork visitors-3090532

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sah62 created an issue. See original summary.

sah62’s picture

FileSize
504 bytes

Adding a patch...

fjgarlin’s picture

Status: Active » Needs review
fjgarlin’s picture

Status: Needs review » Reviewed & tested by the community

I confirm that without the patch we get the watchdog entry and with the patch we no longer get it. Thanks.

fjgarlin’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
5.22 KB

Actually, whilst navigating through the different pages I got the error again, but from other pages. Then I looked into the module's code and saw that the same snippet appears in multiple places.

I attach a patch that fixes the issue wherever it appears.

sah62’s picture

Status: Needs review » Reviewed & tested by the community

The most recent patch works fine on my site. Thanks for the more thorough review!

sah62’s picture

Re-roll for 8.x-2.7.

sah62’s picture

Version: 8.x-2.3 » 8.x-2.6

Updating the version to 8.x-2.6 because there's no option for 8.x-2.7.

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

  • bluegeek9 committed 63ef4d5 on 8.x-2.x authored by sah62
    Issue #3090532: Warning: A non-numeric value encountered
    
bluegeek9’s picture

Version: 8.x-2.6 » 8.x-2.7
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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