Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   1  <?php
   2  
   3  /**

   4   * Definition cache decorator class that cleans up the cache

   5   * whenever there is a cache miss.

   6   */
   7  class HTMLPurifier_DefinitionCache_Decorator_Cleanup extends HTMLPurifier_DefinitionCache_Decorator
   8  {
   9      /**

  10       * @type string

  11       */
  12      public $name = 'Cleanup';
  13  
  14      /**

  15       * @return HTMLPurifier_DefinitionCache_Decorator_Cleanup

  16       */
  17      public function copy()
  18      {
  19          return new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
  20      }
  21  
  22      /**

  23       * @param HTMLPurifier_Definition $def

  24       * @param HTMLPurifier_Config $config

  25       * @return mixed

  26       */
  27      public function add($def, $config)
  28      {
  29          $status = parent::add($def, $config);
  30          if (!$status) {
  31              parent::cleanup($config);
  32          }
  33          return $status;
  34      }
  35  
  36      /**

  37       * @param HTMLPurifier_Definition $def

  38       * @param HTMLPurifier_Config $config

  39       * @return mixed

  40       */
  41      public function set($def, $config)
  42      {
  43          $status = parent::set($def, $config);
  44          if (!$status) {
  45              parent::cleanup($config);
  46          }
  47          return $status;
  48      }
  49  
  50      /**

  51       * @param HTMLPurifier_Definition $def

  52       * @param HTMLPurifier_Config $config

  53       * @return mixed

  54       */
  55      public function replace($def, $config)
  56      {
  57          $status = parent::replace($def, $config);
  58          if (!$status) {
  59              parent::cleanup($config);
  60          }
  61          return $status;
  62      }
  63  
  64      /**

  65       * @param HTMLPurifier_Config $config

  66       * @return mixed

  67       */
  68      public function get($config)
  69      {
  70          $ret = parent::get($config);
  71          if (!$ret) {
  72              parent::cleanup($config);
  73          }
  74          return $ret;
  75      }
  76  }
  77  
  78  // vim: et sw=4 sts=4