In the hunt for the cause of #1322682: Many conditions may result in memory crashes? I noticed that RulesState::defaultVariables looks like is being called multiple times needlessly in includes/rules.core.inc.

Was:

public function availableVariables() {
  $vars = RulesState::defaultVariables();
  return !$this->isRoot() ? $this->parent->stateVariables($this) : $vars;
}

Changed to:

public function availableVariables() {
  return !$this->isRoot() ? $this->parent->stateVariables($this) : RulesState::defaultVariables();
}

Which should mean that RulesState::defaultVariables() is only ever called when $this->isRoot is TRUE, and not every single time availableVariables() is called.

Comments

mrfelton’s picture

Component: Rules Core » Rules Engine
Status: Active » Needs review
StatusFileSize
new528 bytes
acrazyanimal’s picture

@mrfelton: Did you notice if this had an improving impact on the performance issue you noted in #1383522: Huge performance impact when using lots of 'entity has field' checks. ??

mrfelton’s picture

No (or little) impact on that other issue.

fago’s picture

Status: Needs review » Fixed

Thanks for catching this, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.