moodle-block_configurablereports icon indicating copy to clipboard operation
moodle-block_configurablereports copied to clipboard

PHP Notice when using user field filter and enabled debugging

Open golenkovm opened this issue 3 years ago • 0 comments

Hi team,

It seems like there is a PHP Notice displayed on the view report page when debugging is turned on and user filter is used for the report:

Notice
:  Undefined offset: 1 in /var/www/site/blocks/configurable_reports/components/filters/fuserfield/plugin.class.php on line 174

As I can see preg_split() returns an array with only one element:

root@003b7cbe0a84:/var/www/site# cat my.php
<?php
var_dump(preg_split('/:/', 'Some string'));
root@003b7cbe0a84:/var/www/site# php my.php
array(1) {
  [0]=>
  string(11) "Some string"
}

So list($field, $operator) causes PHP Notice.

SQL used in my report:

select *
from prefix_user u
where
  1 = 1 
  %%FILTER_USERS:u.firstname%%
  %%FILTER_USERS:u.lastname%%

Cheers, Misha

golenkovm avatar Feb 24 '22 02:02 golenkovm