You are here

public function LocaleHierarchy::offsetExists in Language Hierarchy 7

File

includes/LocaleHierarchy.class.inc, line 22
Definition of LocaleHierarchy.

Class

LocaleHierarchy
Class LocaleHierarchy.

Code

public function offsetExists($offset) {

  /**
   * see https://bugs.php.net/bug.php?id=69659
   *
   * Before PHP 7.0.6, "Calling isset() or empty() on a dimension of an object that implements ArrayAccess results in
   * the offsetExists method being called. When calling isset() or empty() on a subdimension of a dimension of that
   * object, only the offsetGet method is called, not the offsetExists method. This is inconsistent, undocumented, and
   * often results in undefined index notices being raised."
   *
   * With PHP 7.0.6+, "Instead, when isset() or empty() is called on a subdimension of an object implementing
   * ArrayAccess, the offsetExists method" is "called to check if the dimension exists. If the dimension
   * does not exist, then offsetGet" is not "called."
   *
   * In other words, with PHP 7.0.6+ $cache[$offset] is never set by calls coming from t() unless we force it here.
   */
  if (!isset($this->cache[$offset])) {
    $this
      ->offsetBuild($offset);
  }
  return isset($this->cache[$offset]);
}