Page MenuHomePhabricator

Herald "ref change type has bit X" not working
Closed, ResolvedPublic

Description

There seems to be a bug with the "ref change type" "has bit" rules in Herald.

When I tried to make a rule to stop dangerous changes, this was the result of a herald transcript:

{F140520}

Here is my herald rule:

{F140522}

As nearly as I can tell, this is what is happening:

case self::CONDITION_HAS_BIT:
  return (($condition_value & $field_value) === $condition_value);

When we get here, $condition_value is (string) "2" , $field_value is (int) 18.

($condition_value & $field_value) which is ("2" & 18) evaluates to (int) 2;

Finally, we compare that to $condition_value, so we get (int) 2 === (string) "2"

Which on my machine evaluates false.

Easy solution is to change that line to

return (($condition_value & $field_value) === (int)$condition_value);

FYI:

Ubuntu precise64 running:

PHP 5.3.10-1ubuntu3.10 with Suhosin-Patch (cli) (built: Feb 28 2014 23:14:25)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Revisions and Commits

Event Timeline

bluehawk raised the priority of this task from to Needs Triage.
bluehawk updated the task description. (Show Details)
bluehawk added a project: Phabricator.
bluehawk added a subscriber: bluehawk.
epriestley added a subscriber: epriestley.

The suggestions look accurate to me. If you don't have hosting set up already in order to trigger this kind of rule feel free to kick this back to me, it will probably take like 50x longer to set up hosting than fix/verify this.