You are here:  » Filters not working


Filters not working

Submitted by ChrisNBC on Tue, 2016-11-08 10:58 in

Hi David,

Hope all is going well.

I wondered if you might be able to help me resolve an issue with the global filters on my site. In summary I have noticed some of the filters (which I have used regularly for a long time on my other sites without issue) appear to have stopped working. For example, the filters “Drop Record RegExp” and “Drop Record” appear to no longer delete any records. Initially I thought it was something I had done but I have checked everything I can think of and the issues remains. I also noticed search and replace is not functioning. I wondered if you might be able to suggest what might be going wrong and how I may be able to resolve it?

Thanks in advance.

Bets regards
Chris

Submitted by support on Tue, 2016-11-08 11:46

Hello Chris,

It sounds like it could be a caching issue, if you are testing by way of making changes to filters, re-importing and then refreshing a page on the front end. Try using a hard refresh (CTRL+F5 in most browsers) and see if that reveals the changes, otherwise let me know and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Tue, 2016-11-08 12:41

Hi David,

Thanks for your quick response and suggestion above. I've tried the hard refresh and it made no difference. It's really odd because a number of different filters (most of which I have used for a long time now) appear to be affected. The other odd thing I noticed is the zzGlobal feed (which I use to run some final filters after all feeds have loaded) looks like it's sometimes running before some other feeds load. I haven't made any changes to the feed code except for adding the filter below which you kindly wrote for me a few weeks back...but I don't think it's that as I rolled back the code and removed the associated filters and the problem remained. I also tried running the feed import in two separate browsers but that didn't help either. Could you suggest anything else it might be?

Thanks in advance.

Best regards
Chris

  /*************************************************/
  /* scanSetRegexp */
  /*************************************************/
  $filter_names["scanSetRegExp"] = "Scan and Set RegExp";
  function filter_scanSetRegExpConfigure($filter_data)
  {
    print "Scan:<br />";
    print "<select name='scan'>";
    print "<option value='self' ".($filter_data["scan"]=="self"?"selected='selected'":"").">Self</option>";
    print "<option value='name' ".($filter_data["scan"]=="name"?"selected='selected'":"").">Name</option>";
    print "<option value='namedesc' ".($filter_data["scan"]=="namedesc"?"selected='selected'":"").">Name and Description</option>";
    print "</select>";
    widget_errorGet("scan");
    print "<br />";
    print "RegExp:<br />";
    print "<input type='text' name='regexp' value='".widget_safe($filter_data["regexp"])."' />";
    widget_errorGet("regexp");
    print "<br />";
    print "Set:<br />";
    print "<input type='text' name='set' value='".widget_safe($filter_data["set"])."' />";
    widget_errorGet("set");
  }
  function filter_scanSetRegExpValidate($filter_data)
  {
    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 $admin_importFeed;
    global $filter_record;
    switch($filter_data["scan"])
    {
      case "self":
        $scan = $text;
        break;
      case "name":
        $scan = $filter_record[$admin_importFeed["field_name"]];
        break;
      case "namedesc":
        $scan = $filter_record[$admin_importFeed["field_name"]];
        $scan .= " ".$filter_record[$admin_importFeed["field_description"]];
        break;
    }
      if (@preg_match($filter_data["regexp"],$scan,$matches))
    {
      $retval1 = $filter_data["set"];
      $retval2 = $filter_data["set"];
      foreach($matches as $k => $match)
      {
        if (!$k) continue;
        $search = "\$".$k;
        $replace = $matches[$k];
        $retval2 = str_replace($search,$replace,$retval2);
      }
      if ($retval2 != $retval1)
      {
        return $retval2;
      }
    }
    return $text;
  }

Submitted by support on Tue, 2016-11-08 13:36

Hi Chris,

You mentioned that the filters had been working fine for a long time on other sites... Is this a new installation that you have copied includes/filter.php to from a previous installation?

I am wondering if there are modifications made to includes/admin.php missing so filters are not being applied in the order that they are on your other site...

If that could be the case, and because of version difference you are not able to copy includes/admin.php from the installation where the filters are working fine, if you could email me two separate .zip files, with;

includes/admin.php
includes/filter.php

...from the working / not working installations (named accordingly to indicate which is which) and I'll check it out further for you...

Thanks,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Tue, 2016-11-08 15:37

Hi David,
Thanks for the offer to check the files. The second site is a copy of the site where the filters work except for the addition of 'category hierarchy'. I have done a quick compare of the files you mention and the version which does not work only has two additional filters in filter.php and the hierarchy mods in the admin.php file. I have done some more testing and have tried the search and replace filter on a different field and it worked. I'm wondering if the new site either has some variation in the dB table structure (It's a copy so shouldn't) or if it could be the content of the field which is causing the problem. The field I'm working on contains size information in the format xx word,xx word,xx word(where xx is a numeric size and word is a descriptive single word). It's the descriptive word I'm trying to search and replace. Do you think the content might be the issue? It's set to Varchar 255 in the table.

Best regards
Chris

Submitted by support on Tue, 2016-11-08 16:51

Hi Chris,

Database structure shouldn't affect filter operation at all - if you could forward the files from both installations (working / not working), I'll check it all over for you...

Thanks,

David.
--
PriceTapestry.com