Changeset 59141 for trunk/src/wp-includes/SimplePie/src/Cache.php
- Timestamp:
- 09/30/2024 10:48:16 PM (6 weeks ago)
- Location:
- trunk/src/wp-includes/SimplePie/src
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/src/Cache.php
r59140 r59141 1 1 <?php 2 2 3 /** 3 4 * SimplePie … … 6 7 * Takes the hard work out of managing a complete RSS/Atom solution. 7 8 * 8 * Copyright (c) 2004-20 16, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 10 * All rights reserved. 10 11 * … … 42 43 */ 43 44 45 namespace SimplePie; 46 47 use SimplePie\Cache\Base; 48 44 49 /** 45 50 * Used to create cache objects … … 51 56 * @package SimplePie 52 57 * @subpackage Caching 58 * @deprecated since SimplePie 1.8.0, use "SimplePie\SimplePie::set_cache()" instead 53 59 */ 54 class SimplePie_Cache60 class Cache 55 61 { 56 57 58 59 60 61 62 63 protected static $handlers = array( 64 'mysql' => 'SimplePie_Cache_MySQL',65 'memcache' => 'SimplePie_Cache_Memcache',66 'memcached' => 'SimplePie_Cache_Memcached',67 'redis' => 'SimplePie_Cache_Redis'68 );62 /** 63 * Cache handler classes 64 * 65 * These receive 3 parameters to their constructor, as documented in 66 * {@see register()} 67 * @var array 68 */ 69 protected static $handlers = [ 70 'mysql' => 'SimplePie\Cache\MySQL', 71 'memcache' => 'SimplePie\Cache\Memcache', 72 'memcached' => 'SimplePie\Cache\Memcached', 73 'redis' => 'SimplePie\Cache\Redis' 74 ]; 69 75 70 /** 71 * Don't call the constructor. Please. 72 */ 73 private function __construct() { } 76 /** 77 * Don't call the constructor. Please. 78 */ 79 private function __construct() 80 { 81 } 74 82 75 /** 76 * Create a new SimplePie_Cache object 77 * 78 * @param string $location URL location (scheme is used to determine handler) 79 * @param string $filename Unique identifier for cache object 80 * @param string $extension 'spi' or 'spc' 81 * @return SimplePie_Cache_Base Type of object depends on scheme of `$location` 82 */ 83 public static function get_handler($location, $filename, $extension) 84 { 85 $type = explode(':', $location, 2); 86 $type = $type[0]; 87 if (!empty(self::$handlers[$type])) 88 { 89 $class = self::$handlers[$type]; 90 return new $class($location, $filename, $extension); 91 } 83 /** 84 * Create a new SimplePie\Cache object 85 * 86 * @param string $location URL location (scheme is used to determine handler) 87 * @param string $filename Unique identifier for cache object 88 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension 'spi' or 'spc' 89 * @return Base Type of object depends on scheme of `$location` 90 */ 91 public static function get_handler($location, $filename, $extension) 92 { 93 $type = explode(':', $location, 2); 94 $type = $type[0]; 95 if (!empty(self::$handlers[$type])) { 96 $class = self::$handlers[$type]; 97 return new $class($location, $filename, $extension); 98 } 92 99 93 return new SimplePie_Cache_File($location, $filename, $extension);94 100 return new \SimplePie\Cache\File($location, $filename, $extension); 101 } 95 102 96 /** 97 * Create a new SimplePie_Cache object 98 * 99 * @deprecated Use {@see get_handler} instead 100 */ 101 public function create($location, $filename, $extension) 102 { 103 trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED); 104 return self::get_handler($location, $filename, $extension); 105 } 103 /** 104 * Create a new SimplePie\Cache object 105 * 106 * @deprecated since SimplePie 1.3.1, use {@see get_handler()} instead 107 */ 108 public function create($location, $filename, $extension) 109 { 110 trigger_error('Cache::create() has been replaced with Cache::get_handler() since SimplePie 1.3.1, use the registry system instead.', \E_USER_DEPRECATED); 106 111 107 /** 108 * Register a handler 109 * 110 * @param string $type DSN type to register for 111 * @param string $class Name of handler class. Must implement SimplePie_Cache_Base 112 */ 113 public static function register($type, $class) 114 { 115 self::$handlers[$type] = $class; 116 } 112 return self::get_handler($location, $filename, $extension); 113 } 117 114 118 /** 119 * Parse a URL into an array 120 * 121 * @param string $url 122 * @return array 123 */ 124 public static function parse_URL($url) 125 { 126 $params = parse_url($url); 127 $params['extras'] = array(); 128 if (isset($params['query'])) 129 { 130 parse_str($params['query'], $params['extras']); 131 } 132 return $params; 133 } 115 /** 116 * Register a handler 117 * 118 * @param string $type DSN type to register for 119 * @param class-string<Base> $class Name of handler class. Must implement Base 120 */ 121 public static function register($type, $class) 122 { 123 self::$handlers[$type] = $class; 124 } 125 126 /** 127 * Parse a URL into an array 128 * 129 * @param string $url 130 * @return array 131 */ 132 public static function parse_URL($url) 133 { 134 $params = parse_url($url); 135 $params['extras'] = []; 136 if (isset($params['query'])) { 137 parse_str($params['query'], $params['extras']); 138 } 139 return $params; 140 } 134 141 } 142 143 class_alias('SimplePie\Cache', 'SimplePie_Cache');
Note: See TracChangeset
for help on using the changeset viewer.