Forum

Thread tagged as: Problem, Error, Discussion

Perch_content_custom: Null is not null?

I have a dataselect with allowempty="true". This results in the value of this field being NULL.

However, when passing that into a perch_content_custom filter...

$thing = perch_content_custom('MyRegion', array(
  'skip-template' => 'true',
  'filter' => 'my-field',
  'match' => 'eq',
  'value' => NULL
));

...rather than finding no match and returning nothing, it always returns the first item of that region.

If value is '' or false, it returns nothing as expected.

I can get round this for now with something like if ($thing[0]['my-field'] == NULL) { $thing[0]['my-field'] = false; } but wondered if there was a more fundamental issue here?

Keir Moffatt

Keir Moffatt 0 points

  • 6 years ago

I should add, I am not actually passing NULL, but a variable which is set to NULL - just simplified the above example for easier debugging.

Actually I can fix if by wrapping perch_content_custom in if ($thing[0]['my-field']) - no point even querying Perch if it is NULL.

Still, odd that NULL would return first result...

Drew McLellan

Drew McLellan 2638 points
Perch Support

I shall take a look.

Nice one - no urgency whatsoever, just a curiosity.