Commit 028b66fa authored by plach's avatar plach Committed by fago

Issue #1947142 by plach | ottawadeveloper: Fixed Provide protection against...

Issue #1947142 by plach | ottawadeveloper: Fixed Provide protection against label callback recursion.
parent 1eb9c487
......@@ -30,6 +30,7 @@ class Entity {
protected $entityType;
protected $entityInfo;
protected $idKey, $nameKey, $statusKey;
protected $defaultLabel = FALSE;
/**
* Creates a new entity.
......@@ -119,10 +120,18 @@ class Entity {
* @see entity_label()
*/
public function label() {
if (isset($this->entityInfo['label callback']) && $this->entityInfo['label callback'] == 'entity_class_label') {
// If the default label flag is enabled, this is being invoked recursively.
// In this case we need to use our default label callback directly. This may
// happen if a module provides a label callback implementation different
// from ours, but then invokes Entity::label() or entity_class_label() from
// there.
if ($this->defaultLabel || (isset($this->entityInfo['label callback']) && $this->entityInfo['label callback'] == 'entity_class_label')) {
return $this->defaultLabel();
}
return entity_label($this->entityType, $this);
$this->defaultLabel = TRUE;
$label = entity_label($this->entityType, $this);
$this->defaultLabel = FALSE;
return $label;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment