HTMLPurifier_Config::getBatchSerial PHP Method

getBatchSerial() public method

Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration
public getBatchSerial ( string $namespace ) : string
$namespace string Namespace to get serial for
return string
    public function getBatchSerial($namespace)
    {
        if (empty($this->serials[$namespace])) {
            $batch = $this->getBatch($namespace);
            unset($batch['DefinitionRev']);
            $this->serials[$namespace] = sha1(serialize($batch));
        }
        return $this->serials[$namespace];
    }

Usage Example

Example #1
0
 /**
  * Tests whether or not a key is old with respect to the configuration's
  * version and revision number.
  * @param string $key Key to test
  * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config to test against
  * @return bool
  */
 public function isOld($key, $config)
 {
     if (substr_count($key, ',') < 2) {
         return true;
     }
     list($version, $hash, $revision) = explode(',', $key, 3);
     $compare = version_compare($version, $config->version);
     // version mismatch, is always old
     if ($compare != 0) {
         return true;
     }
     // versions match, ids match, check revision number
     if ($hash == $config->getBatchSerial($this->type) && $revision < $config->get($this->type . '.DefinitionRev')) {
         return true;
     }
     return false;
 }