You are here:  » Php error in scanSetRegexp filter


Php error in scanSetRegexp filter

Submitted by nanaz on Mon, 2021-12-13 08:42 in

Hi David,

I hope you are okay! I have a questiono:

After upgrading the server to PHP 7.4.16 I get a warning after accessing page Configure Filter in the admin. (admin/feeds_filters_configure.php):

Notice: Trying to access array offset on value of type bool in {code saved}includes/filter.php on line 406

Line 406 is this one:
widget_textBox("Field","field",TRUE,$filter_data["field"],"",3); in filter scanSetRegexp.

  /*************************************************/
  /* scanSetRegexp */
  /*************************************************/
  $filter_names["scanSetRegexp"] = "Scan and Set RegExp";
  function filter_scanSetRegexpConfigure($filter_data)
  {
    widget_textBox("Field","field",TRUE,$filter_data["field"],"",3);
    widget_textBox("RegExp","regexp",TRUE,$filter_data["regexp"],"",3);
    widget_textBox("Set","set",TRUE,$filter_data["set"],"",3);
  }
  function filter_scanSetRegexpValidate($filter_data)
  {
    if (!$filter_data["field"])
    {
      widget_errorSet("field","required field");
    }
    if (!$filter_data["regexp"])
    {
      widget_errorSet("regexp","required field");
    }
    if (!$filter_data["set"])
    {
      widget_errorSet("set","required field");
    }
  }
  function filter_scanSetRegexpExec($filter_data,$text)
  {
    global $filter_record;
    if (preg_match($filter_data["regexp"],$filter_record[$filter_data["field"]],$matches))
    {
      $text = $filter_data["set"];
      foreach($matches as $k => $match)
      {
        $text = str_replace("\$".$k,$match,$text);
      }
    }
    return $text;
  }

Hope you can help!

Kind regards, Marlies

Submitted by support on Mon, 2021-12-13 10:13

Hello Marlies,

To correct this edit admin/feeds_filters_configure.php and look for the following code at line 45:

  $filter["data"] = unserialize($filter["data"]);

...and REPLACE with:

  $filter["data"] = ($filter["data"]?unserialize($filter["data"]):array());

Cheers,
David.
--
PriceTapestry.com

Submitted by nanaz on Mon, 2021-12-13 11:12

Hi David,

Thanks for your fast reply!

Unfortunately that didn't do the trick.
There are 3 fields in the form, above the first it now says:

{code saved}

PT is (modified) 16/10A

Kind regards, Marlies

Submitted by support on Mon, 2021-12-13 11:45

Hello Marlies,

I have resolved this E_NOTICE warnings as of 20/10A for PHP 7/8 compatibility - what I would actually suggest is to add the following to the end of config.advanced.php (before the closing PHP tag)

  ini_set('display_errors','off');

(which is recommend for production servers anyway...)

Cheers,
David.
--
PriceTapestry.com