forked from friendica/friendica-addons
Compare commits
12 commits
fancybox
...
2024.09-rc
Author | SHA1 | Date | |
---|---|---|---|
Hypolite Petovan | fecae6564b | ||
Michael | 422e4fd48f | ||
Hypolite Petovan | 6a2c0d974e | ||
Michael | f52bb75c97 | ||
Hypolite Petovan | 8989e0dab6 | ||
Michael | 7fcbd76c6b | ||
heluecht | dc0b79bed1 | ||
a0c727ac35 | |||
heluecht | e133a693c2 | ||
Hypolite Petovan | aa5130247b | ||
Hypolite Petovan | aeefb92926 | ||
Michael | c22e0ae831 |
18
advancedcontentfilter/vendor/autoload.php
vendored
18
advancedcontentfilter/vendor/autoload.php
vendored
|
@ -2,6 +2,24 @@
|
||||||
|
|
||||||
// autoload.php @generated by Composer
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 50600) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, $err);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo $err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
$err,
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitAdvancedContentFilterAddon::getLoader();
|
return ComposerAutoloaderInitAdvancedContentFilterAddon::getLoader();
|
||||||
|
|
|
@ -37,26 +37,81 @@ namespace Composer\Autoload;
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
* @see http://www.php-fig.org/psr/psr-0/
|
* @see https://www.php-fig.org/psr/psr-0/
|
||||||
* @see http://www.php-fig.org/psr/psr-4/
|
* @see https://www.php-fig.org/psr/psr-4/
|
||||||
*/
|
*/
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
|
/** @var \Closure(string):void */
|
||||||
|
private static $includeFile;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $vendorDir;
|
||||||
|
|
||||||
// PSR-4
|
// PSR-4
|
||||||
|
/**
|
||||||
|
* @var array<string, array<string, int>>
|
||||||
|
*/
|
||||||
private $prefixLengthsPsr4 = array();
|
private $prefixLengthsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var array<string, list<string>>
|
||||||
|
*/
|
||||||
private $prefixDirsPsr4 = array();
|
private $prefixDirsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
private $fallbackDirsPsr4 = array();
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
// PSR-0
|
// PSR-0
|
||||||
|
/**
|
||||||
|
* List of PSR-0 prefixes
|
||||||
|
*
|
||||||
|
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, list<string>>>
|
||||||
|
*/
|
||||||
private $prefixesPsr0 = array();
|
private $prefixesPsr0 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
private $fallbackDirsPsr0 = array();
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
private $useIncludePath = false;
|
private $useIncludePath = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
private $classMap = array();
|
private $classMap = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
private $classMapAuthoritative = false;
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, bool>
|
||||||
|
*/
|
||||||
private $missingClasses = array();
|
private $missingClasses = array();
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
private $apcuPrefix;
|
private $apcuPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, self>
|
||||||
|
*/
|
||||||
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $vendorDir
|
||||||
|
*/
|
||||||
|
public function __construct($vendorDir = null)
|
||||||
|
{
|
||||||
|
$this->vendorDir = $vendorDir;
|
||||||
|
self::initializeIncludeClosure();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
public function getPrefixes()
|
public function getPrefixes()
|
||||||
{
|
{
|
||||||
if (!empty($this->prefixesPsr0)) {
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
@ -66,28 +121,42 @@ class ClassLoader
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
public function getPrefixesPsr4()
|
public function getPrefixesPsr4()
|
||||||
{
|
{
|
||||||
return $this->prefixDirsPsr4;
|
return $this->prefixDirsPsr4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
public function getFallbackDirs()
|
public function getFallbackDirs()
|
||||||
{
|
{
|
||||||
return $this->fallbackDirsPsr0;
|
return $this->fallbackDirsPsr0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
public function getFallbackDirsPsr4()
|
public function getFallbackDirsPsr4()
|
||||||
{
|
{
|
||||||
return $this->fallbackDirsPsr4;
|
return $this->fallbackDirsPsr4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string> Array of classname => path
|
||||||
|
*/
|
||||||
public function getClassMap()
|
public function getClassMap()
|
||||||
{
|
{
|
||||||
return $this->classMap;
|
return $this->classMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $classMap Class to filename map
|
* @param array<string, string> $classMap Class to filename map
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addClassMap(array $classMap)
|
public function addClassMap(array $classMap)
|
||||||
{
|
{
|
||||||
|
@ -102,22 +171,25 @@ class ClassLoader
|
||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param array|string $paths The PSR-0 root directories
|
* @param list<string>|string $paths The PSR-0 root directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add($prefix, $paths, $prepend = false)
|
public function add($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->fallbackDirsPsr0
|
$this->fallbackDirsPsr0
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
$this->fallbackDirsPsr0,
|
$this->fallbackDirsPsr0,
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,19 +198,19 @@ class ClassLoader
|
||||||
|
|
||||||
$first = $prefix[0];
|
$first = $prefix[0];
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,25 +219,28 @@ class ClassLoader
|
||||||
* Registers a set of PSR-4 directories for a given namespace, either
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param array|string $paths The PSR-4 base directories
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
// Register directories for the root namespace.
|
// Register directories for the root namespace.
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->fallbackDirsPsr4
|
$this->fallbackDirsPsr4
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
$this->fallbackDirsPsr4,
|
$this->fallbackDirsPsr4,
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
|
@ -175,18 +250,18 @@ class ClassLoader
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||||
} elseif ($prepend) {
|
} elseif ($prepend) {
|
||||||
// Prepend directories for an already registered namespace.
|
// Prepend directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->prefixDirsPsr4[$prefix]
|
$this->prefixDirsPsr4[$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Append directories for an already registered namespace.
|
// Append directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
$this->prefixDirsPsr4[$prefix],
|
$this->prefixDirsPsr4[$prefix],
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,8 +270,10 @@ class ClassLoader
|
||||||
* Registers a set of PSR-0 directories for a given prefix,
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
* replacing any others previously set for this prefix.
|
* replacing any others previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param array|string $paths The PSR-0 base directories
|
* @param list<string>|string $paths The PSR-0 base directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set($prefix, $paths)
|
public function set($prefix, $paths)
|
||||||
{
|
{
|
||||||
|
@ -211,10 +288,12 @@ class ClassLoader
|
||||||
* Registers a set of PSR-4 directories for a given namespace,
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
* replacing any others previously set for this namespace.
|
* replacing any others previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param array|string $paths The PSR-4 base directories
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setPsr4($prefix, $paths)
|
public function setPsr4($prefix, $paths)
|
||||||
{
|
{
|
||||||
|
@ -234,6 +313,8 @@ class ClassLoader
|
||||||
* Turns on searching the include path for class files.
|
* Turns on searching the include path for class files.
|
||||||
*
|
*
|
||||||
* @param bool $useIncludePath
|
* @param bool $useIncludePath
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUseIncludePath($useIncludePath)
|
public function setUseIncludePath($useIncludePath)
|
||||||
{
|
{
|
||||||
|
@ -256,6 +337,8 @@ class ClassLoader
|
||||||
* that have not been registered with the class map.
|
* that have not been registered with the class map.
|
||||||
*
|
*
|
||||||
* @param bool $classMapAuthoritative
|
* @param bool $classMapAuthoritative
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
{
|
{
|
||||||
|
@ -276,6 +359,8 @@ class ClassLoader
|
||||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||||
*
|
*
|
||||||
* @param string|null $apcuPrefix
|
* @param string|null $apcuPrefix
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setApcuPrefix($apcuPrefix)
|
public function setApcuPrefix($apcuPrefix)
|
||||||
{
|
{
|
||||||
|
@ -296,33 +381,55 @@ class ClassLoader
|
||||||
* Registers this instance as an autoloader.
|
* Registers this instance as an autoloader.
|
||||||
*
|
*
|
||||||
* @param bool $prepend Whether to prepend the autoloader or not
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function register($prepend = false)
|
public function register($prepend = false)
|
||||||
{
|
{
|
||||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||||
|
|
||||||
|
if (null === $this->vendorDir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||||
|
} else {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters this instance as an autoloader.
|
* Unregisters this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unregister()
|
public function unregister()
|
||||||
{
|
{
|
||||||
spl_autoload_unregister(array($this, 'loadClass'));
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
|
||||||
|
if (null !== $this->vendorDir) {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the given class or interface.
|
* Loads the given class or interface.
|
||||||
*
|
*
|
||||||
* @param string $class The name of the class
|
* @param string $class The name of the class
|
||||||
* @return bool|null True if loaded, null otherwise
|
* @return true|null True if loaded, null otherwise
|
||||||
*/
|
*/
|
||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
includeFile($file);
|
$includeFile = self::$includeFile;
|
||||||
|
$includeFile($file);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -367,6 +474,21 @@ class ClassLoader
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||||
|
*
|
||||||
|
* @return array<string, self>
|
||||||
|
*/
|
||||||
|
public static function getRegisteredLoaders()
|
||||||
|
{
|
||||||
|
return self::$registeredLoaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
* @param string $ext
|
||||||
|
* @return string|false
|
||||||
|
*/
|
||||||
private function findFileWithExtension($class, $ext)
|
private function findFileWithExtension($class, $ext)
|
||||||
{
|
{
|
||||||
// PSR-4 lookup
|
// PSR-4 lookup
|
||||||
|
@ -432,14 +554,26 @@ class ClassLoader
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope isolated include.
|
* @return void
|
||||||
*
|
*/
|
||||||
* Prevents access to $this/self from included files.
|
private static function initializeIncludeClosure()
|
||||||
*/
|
{
|
||||||
function includeFile($file)
|
if (self::$includeFile !== null) {
|
||||||
{
|
return;
|
||||||
include $file;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
self::$includeFile = \Closure::bind(static function($file) {
|
||||||
|
include $file;
|
||||||
|
}, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
359
advancedcontentfilter/vendor/composer/InstalledVersions.php
vendored
Normal file
359
advancedcontentfilter/vendor/composer/InstalledVersions.php
vendored
Normal file
|
@ -0,0 +1,359 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer;
|
||||||
|
|
||||||
|
use Composer\Autoload\ClassLoader;
|
||||||
|
use Composer\Semver\VersionParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is copied in every Composer installed project and available to all
|
||||||
|
*
|
||||||
|
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||||
|
*
|
||||||
|
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||||
|
*
|
||||||
|
* @final
|
||||||
|
*/
|
||||||
|
class InstalledVersions
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var mixed[]|null
|
||||||
|
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||||
|
*/
|
||||||
|
private static $installed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|null
|
||||||
|
*/
|
||||||
|
private static $canGetVendors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static $installedByVendor = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackages()
|
||||||
|
{
|
||||||
|
$packages = array();
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
$packages[] = array_keys($installed['versions']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 === \count($packages)) {
|
||||||
|
return $packages[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names with a specific type e.g. 'library'
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackagesByType($type)
|
||||||
|
{
|
||||||
|
$packagesByType = array();
|
||||||
|
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
foreach ($installed['versions'] as $name => $package) {
|
||||||
|
if (isset($package['type']) && $package['type'] === $type) {
|
||||||
|
$packagesByType[] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $packagesByType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package is installed
|
||||||
|
*
|
||||||
|
* This also returns true if the package name is provided or replaced by another package
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @param bool $includeDevRequirements
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (isset($installed['versions'][$packageName])) {
|
||||||
|
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package satisfies a version constraint
|
||||||
|
*
|
||||||
|
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||||
|
*
|
||||||
|
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||||
|
*
|
||||||
|
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||||
|
* @param string $packageName
|
||||||
|
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
|
{
|
||||||
|
$constraint = $parser->parseConstraints((string) $constraint);
|
||||||
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
|
return $provided->matches($constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||||
|
*
|
||||||
|
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||||
|
* whether a given version of a package is installed, and not just whether it exists
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string Version constraint usable with composer/semver
|
||||||
|
*/
|
||||||
|
public static function getVersionRanges($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ranges = array();
|
||||||
|
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' || ', $ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getPrettyVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||||
|
*/
|
||||||
|
public static function getReference($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['reference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||||
|
*/
|
||||||
|
public static function getInstallPath($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||||
|
*/
|
||||||
|
public static function getRootPackage()
|
||||||
|
{
|
||||||
|
$installed = self::getInstalled();
|
||||||
|
|
||||||
|
return $installed[0]['root'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw installed.php data for custom implementations
|
||||||
|
*
|
||||||
|
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||||
|
*/
|
||||||
|
public static function getRawData()
|
||||||
|
{
|
||||||
|
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
self::$installed = include __DIR__ . '/installed.php';
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
public static function getAllRawData()
|
||||||
|
{
|
||||||
|
return self::getInstalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets you reload the static array from another file
|
||||||
|
*
|
||||||
|
* This is only useful for complex integrations in which a project needs to use
|
||||||
|
* this class but then also needs to execute another project's autoloader in process,
|
||||||
|
* and wants to ensure both projects have access to their version of installed.php.
|
||||||
|
*
|
||||||
|
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||||
|
* the data it needs from this class, then call reload() with
|
||||||
|
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||||
|
* the project in which it runs can then also use this class safely, without
|
||||||
|
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||||
|
*
|
||||||
|
* @param array[] $data A vendor/composer/installed.php data set
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||||
|
*/
|
||||||
|
public static function reload($data)
|
||||||
|
{
|
||||||
|
self::$installed = $data;
|
||||||
|
self::$installedByVendor = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static function getInstalled()
|
||||||
|
{
|
||||||
|
if (null === self::$canGetVendors) {
|
||||||
|
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||||
|
}
|
||||||
|
|
||||||
|
$installed = array();
|
||||||
|
|
||||||
|
if (self::$canGetVendors) {
|
||||||
|
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||||
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require $vendorDir.'/composer/installed.php';
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||||
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
|
self::$installed = $installed[count($installed) - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require __DIR__ . '/installed.php';
|
||||||
|
self::$installed = $required;
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$installed !== array()) {
|
||||||
|
$installed[] = self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
// autoload_classmap.php @generated by Composer
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
$vendorDir = dirname(__DIR__);
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
||||||
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
'FastRoute\\BadRouteException' => $vendorDir . '/nikic/fast-route/src/BadRouteException.php',
|
'FastRoute\\BadRouteException' => $vendorDir . '/nikic/fast-route/src/BadRouteException.php',
|
||||||
'FastRoute\\DataGenerator' => $vendorDir . '/nikic/fast-route/src/DataGenerator.php',
|
'FastRoute\\DataGenerator' => $vendorDir . '/nikic/fast-route/src/DataGenerator.php',
|
||||||
'FastRoute\\DataGenerator\\CharCountBased' => $vendorDir . '/nikic/fast-route/src/DataGenerator/CharCountBased.php',
|
'FastRoute\\DataGenerator\\CharCountBased' => $vendorDir . '/nikic/fast-route/src/DataGenerator/CharCountBased.php',
|
||||||
|
@ -154,7 +155,6 @@ return array(
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter' => $vendorDir . '/symfony/cache/Adapter/TagAwareAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter' => $vendorDir . '/symfony/cache/Adapter/TagAwareAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface' => $vendorDir . '/symfony/cache/Adapter/TagAwareAdapterInterface.php',
|
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface' => $vendorDir . '/symfony/cache/Adapter/TagAwareAdapterInterface.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapter' => $vendorDir . '/symfony/cache/Adapter/TraceableAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapter' => $vendorDir . '/symfony/cache/Adapter/TraceableAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapterEvent' => $vendorDir . '/symfony/cache/Adapter/TraceableAdapter.php',
|
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableTagAwareAdapter' => $vendorDir . '/symfony/cache/Adapter/TraceableTagAwareAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TraceableTagAwareAdapter' => $vendorDir . '/symfony/cache/Adapter/TraceableTagAwareAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\CacheItem' => $vendorDir . '/symfony/cache/CacheItem.php',
|
'Symfony\\Component\\Cache\\CacheItem' => $vendorDir . '/symfony/cache/CacheItem.php',
|
||||||
'Symfony\\Component\\Cache\\DataCollector\\CacheDataCollector' => $vendorDir . '/symfony/cache/DataCollector/CacheDataCollector.php',
|
'Symfony\\Component\\Cache\\DataCollector\\CacheDataCollector' => $vendorDir . '/symfony/cache/DataCollector/CacheDataCollector.php',
|
||||||
|
@ -188,7 +188,6 @@ return array(
|
||||||
'Symfony\\Component\\Cache\\Simple\\Psr6Cache' => $vendorDir . '/symfony/cache/Simple/Psr6Cache.php',
|
'Symfony\\Component\\Cache\\Simple\\Psr6Cache' => $vendorDir . '/symfony/cache/Simple/Psr6Cache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\RedisCache' => $vendorDir . '/symfony/cache/Simple/RedisCache.php',
|
'Symfony\\Component\\Cache\\Simple\\RedisCache' => $vendorDir . '/symfony/cache/Simple/RedisCache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\TraceableCache' => $vendorDir . '/symfony/cache/Simple/TraceableCache.php',
|
'Symfony\\Component\\Cache\\Simple\\TraceableCache' => $vendorDir . '/symfony/cache/Simple/TraceableCache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\TraceableCacheEvent' => $vendorDir . '/symfony/cache/Simple/TraceableCache.php',
|
|
||||||
'Symfony\\Component\\Cache\\Traits\\AbstractAdapterTrait' => $vendorDir . '/symfony/cache/Traits/AbstractAdapterTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\AbstractAdapterTrait' => $vendorDir . '/symfony/cache/Traits/AbstractAdapterTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\AbstractTrait' => $vendorDir . '/symfony/cache/Traits/AbstractTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\AbstractTrait' => $vendorDir . '/symfony/cache/Traits/AbstractTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\ApcuTrait' => $vendorDir . '/symfony/cache/Traits/ApcuTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\ApcuTrait' => $vendorDir . '/symfony/cache/Traits/ApcuTrait.php',
|
||||||
|
@ -197,7 +196,6 @@ return array(
|
||||||
'Symfony\\Component\\Cache\\Traits\\DoctrineTrait' => $vendorDir . '/symfony/cache/Traits/DoctrineTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\DoctrineTrait' => $vendorDir . '/symfony/cache/Traits/DoctrineTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\FilesystemCommonTrait' => $vendorDir . '/symfony/cache/Traits/FilesystemCommonTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\FilesystemCommonTrait' => $vendorDir . '/symfony/cache/Traits/FilesystemCommonTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\FilesystemTrait' => $vendorDir . '/symfony/cache/Traits/FilesystemTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\FilesystemTrait' => $vendorDir . '/symfony/cache/Traits/FilesystemTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\LazyValue' => $vendorDir . '/symfony/cache/Traits/PhpFilesTrait.php',
|
|
||||||
'Symfony\\Component\\Cache\\Traits\\MemcachedTrait' => $vendorDir . '/symfony/cache/Traits/MemcachedTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\MemcachedTrait' => $vendorDir . '/symfony/cache/Traits/MemcachedTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\PdoTrait' => $vendorDir . '/symfony/cache/Traits/PdoTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\PdoTrait' => $vendorDir . '/symfony/cache/Traits/PdoTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\PhpArrayTrait' => $vendorDir . '/symfony/cache/Traits/PhpArrayTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\PhpArrayTrait' => $vendorDir . '/symfony/cache/Traits/PhpArrayTrait.php',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_files.php @generated by Composer
|
// autoload_files.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
$vendorDir = dirname(__DIR__);
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_namespaces.php @generated by Composer
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
$vendorDir = dirname(__DIR__);
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_psr4.php @generated by Composer
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
$vendorDir = dirname(__DIR__);
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -16,7 +16,7 @@ return array(
|
||||||
'Slim\\' => array($vendorDir . '/slim/slim/Slim'),
|
'Slim\\' => array($vendorDir . '/slim/slim/Slim'),
|
||||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
|
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
|
||||||
'Psr\\Http\\Server\\' => array($vendorDir . '/psr/http-server-handler/src', $vendorDir . '/psr/http-server-middleware/src'),
|
'Psr\\Http\\Server\\' => array($vendorDir . '/psr/http-server-handler/src', $vendorDir . '/psr/http-server-middleware/src'),
|
||||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
|
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
|
||||||
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
||||||
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
|
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
|
||||||
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
|
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
|
||||||
|
|
|
@ -22,52 +22,29 @@ class ComposerAutoloaderInitAdvancedContentFilterAddon
|
||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/platform_check.php';
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitAdvancedContentFilterAddon', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInitAdvancedContentFilterAddon', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitAdvancedContentFilterAddon', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInitAdvancedContentFilterAddon', 'loadClassLoader'));
|
||||||
|
|
||||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
require __DIR__ . '/autoload_static.php';
|
||||||
if ($useStaticLoader) {
|
call_user_func(\Composer\Autoload\ComposerStaticInitAdvancedContentFilterAddon::getInitializer($loader));
|
||||||
require_once __DIR__ . '/autoload_static.php';
|
|
||||||
|
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInitAdvancedContentFilterAddon::getInitializer($loader));
|
|
||||||
} else {
|
|
||||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
|
||||||
foreach ($map as $namespace => $path) {
|
|
||||||
$loader->set($namespace, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$map = require __DIR__ . '/autoload_psr4.php';
|
|
||||||
foreach ($map as $namespace => $path) {
|
|
||||||
$loader->setPsr4($namespace, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
|
||||||
if ($classMap) {
|
|
||||||
$loader->addClassMap($classMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
if ($useStaticLoader) {
|
$filesToLoad = \Composer\Autoload\ComposerStaticInitAdvancedContentFilterAddon::$files;
|
||||||
$includeFiles = Composer\Autoload\ComposerStaticInitAdvancedContentFilterAddon::$files;
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
} else {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
}
|
|
||||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
require $file;
|
||||||
composerRequireAdvancedContentFilterAddon($fileIdentifier, $file);
|
}
|
||||||
|
}, null, null);
|
||||||
|
foreach ($filesToLoad as $fileIdentifier => $file) {
|
||||||
|
$requireFile($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireAdvancedContentFilterAddon($fileIdentifier, $file)
|
|
||||||
{
|
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
|
||||||
require $file;
|
|
||||||
|
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ class ComposerStaticInitAdvancedContentFilterAddon
|
||||||
),
|
),
|
||||||
'Psr\\Http\\Message\\' =>
|
'Psr\\Http\\Message\\' =>
|
||||||
array (
|
array (
|
||||||
0 => __DIR__ . '/..' . '/psr/http-factory/src',
|
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||||
1 => __DIR__ . '/..' . '/psr/http-message/src',
|
1 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||||
),
|
),
|
||||||
'Psr\\Container\\' =>
|
'Psr\\Container\\' =>
|
||||||
array (
|
array (
|
||||||
|
@ -102,6 +102,7 @@ class ComposerStaticInitAdvancedContentFilterAddon
|
||||||
|
|
||||||
public static $classMap = array (
|
public static $classMap = array (
|
||||||
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
||||||
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
'FastRoute\\BadRouteException' => __DIR__ . '/..' . '/nikic/fast-route/src/BadRouteException.php',
|
'FastRoute\\BadRouteException' => __DIR__ . '/..' . '/nikic/fast-route/src/BadRouteException.php',
|
||||||
'FastRoute\\DataGenerator' => __DIR__ . '/..' . '/nikic/fast-route/src/DataGenerator.php',
|
'FastRoute\\DataGenerator' => __DIR__ . '/..' . '/nikic/fast-route/src/DataGenerator.php',
|
||||||
'FastRoute\\DataGenerator\\CharCountBased' => __DIR__ . '/..' . '/nikic/fast-route/src/DataGenerator/CharCountBased.php',
|
'FastRoute\\DataGenerator\\CharCountBased' => __DIR__ . '/..' . '/nikic/fast-route/src/DataGenerator/CharCountBased.php',
|
||||||
|
@ -249,7 +250,6 @@ class ComposerStaticInitAdvancedContentFilterAddon
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TagAwareAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TagAwareAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface' => __DIR__ . '/..' . '/symfony/cache/Adapter/TagAwareAdapterInterface.php',
|
'Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface' => __DIR__ . '/..' . '/symfony/cache/Adapter/TagAwareAdapterInterface.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TraceableAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TraceableAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableAdapterEvent' => __DIR__ . '/..' . '/symfony/cache/Adapter/TraceableAdapter.php',
|
|
||||||
'Symfony\\Component\\Cache\\Adapter\\TraceableTagAwareAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TraceableTagAwareAdapter.php',
|
'Symfony\\Component\\Cache\\Adapter\\TraceableTagAwareAdapter' => __DIR__ . '/..' . '/symfony/cache/Adapter/TraceableTagAwareAdapter.php',
|
||||||
'Symfony\\Component\\Cache\\CacheItem' => __DIR__ . '/..' . '/symfony/cache/CacheItem.php',
|
'Symfony\\Component\\Cache\\CacheItem' => __DIR__ . '/..' . '/symfony/cache/CacheItem.php',
|
||||||
'Symfony\\Component\\Cache\\DataCollector\\CacheDataCollector' => __DIR__ . '/..' . '/symfony/cache/DataCollector/CacheDataCollector.php',
|
'Symfony\\Component\\Cache\\DataCollector\\CacheDataCollector' => __DIR__ . '/..' . '/symfony/cache/DataCollector/CacheDataCollector.php',
|
||||||
|
@ -283,7 +283,6 @@ class ComposerStaticInitAdvancedContentFilterAddon
|
||||||
'Symfony\\Component\\Cache\\Simple\\Psr6Cache' => __DIR__ . '/..' . '/symfony/cache/Simple/Psr6Cache.php',
|
'Symfony\\Component\\Cache\\Simple\\Psr6Cache' => __DIR__ . '/..' . '/symfony/cache/Simple/Psr6Cache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\RedisCache' => __DIR__ . '/..' . '/symfony/cache/Simple/RedisCache.php',
|
'Symfony\\Component\\Cache\\Simple\\RedisCache' => __DIR__ . '/..' . '/symfony/cache/Simple/RedisCache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\TraceableCache' => __DIR__ . '/..' . '/symfony/cache/Simple/TraceableCache.php',
|
'Symfony\\Component\\Cache\\Simple\\TraceableCache' => __DIR__ . '/..' . '/symfony/cache/Simple/TraceableCache.php',
|
||||||
'Symfony\\Component\\Cache\\Simple\\TraceableCacheEvent' => __DIR__ . '/..' . '/symfony/cache/Simple/TraceableCache.php',
|
|
||||||
'Symfony\\Component\\Cache\\Traits\\AbstractAdapterTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/AbstractAdapterTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\AbstractAdapterTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/AbstractAdapterTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\AbstractTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/AbstractTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\AbstractTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/AbstractTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\ApcuTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/ApcuTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\ApcuTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/ApcuTrait.php',
|
||||||
|
@ -292,7 +291,6 @@ class ComposerStaticInitAdvancedContentFilterAddon
|
||||||
'Symfony\\Component\\Cache\\Traits\\DoctrineTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/DoctrineTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\DoctrineTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/DoctrineTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\FilesystemCommonTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/FilesystemCommonTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\FilesystemCommonTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/FilesystemCommonTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\FilesystemTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/FilesystemTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\FilesystemTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/FilesystemTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\LazyValue' => __DIR__ . '/..' . '/symfony/cache/Traits/PhpFilesTrait.php',
|
|
||||||
'Symfony\\Component\\Cache\\Traits\\MemcachedTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/MemcachedTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\MemcachedTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/MemcachedTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\PdoTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/PdoTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\PdoTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/PdoTrait.php',
|
||||||
'Symfony\\Component\\Cache\\Traits\\PhpArrayTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/PhpArrayTrait.php',
|
'Symfony\\Component\\Cache\\Traits\\PhpArrayTrait' => __DIR__ . '/..' . '/symfony/cache/Traits/PhpArrayTrait.php',
|
||||||
|
|
2354
advancedcontentfilter/vendor/composer/installed.json
vendored
2354
advancedcontentfilter/vendor/composer/installed.json
vendored
File diff suppressed because it is too large
Load diff
203
advancedcontentfilter/vendor/composer/installed.php
vendored
Normal file
203
advancedcontentfilter/vendor/composer/installed.php
vendored
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
<?php return array(
|
||||||
|
'root' => array(
|
||||||
|
'name' => 'friendica-addons/advancedcontentfilter',
|
||||||
|
'pretty_version' => 'dev-develop',
|
||||||
|
'version' => 'dev-develop',
|
||||||
|
'reference' => 'feb7722f723b21e76fdf20a7ce4b42fa5ffcdcb9',
|
||||||
|
'type' => 'friendica-addon',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev' => false,
|
||||||
|
),
|
||||||
|
'versions' => array(
|
||||||
|
'friendica-addons/advancedcontentfilter' => array(
|
||||||
|
'pretty_version' => 'dev-develop',
|
||||||
|
'version' => 'dev-develop',
|
||||||
|
'reference' => 'feb7722f723b21e76fdf20a7ce4b42fa5ffcdcb9',
|
||||||
|
'type' => 'friendica-addon',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'nikic/fast-route' => array(
|
||||||
|
'pretty_version' => 'v1.3.0',
|
||||||
|
'version' => '1.3.0.0',
|
||||||
|
'reference' => '181d480e08d9476e61381e04a71b34dc0432e812',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../nikic/fast-route',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/cache' => array(
|
||||||
|
'pretty_version' => '1.0.1',
|
||||||
|
'version' => '1.0.1.0',
|
||||||
|
'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/cache',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/cache-implementation' => array(
|
||||||
|
'dev_requirement' => false,
|
||||||
|
'provided' => array(
|
||||||
|
0 => '1.0|2.0',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'psr/container' => array(
|
||||||
|
'pretty_version' => '1.1.2',
|
||||||
|
'version' => '1.1.2.0',
|
||||||
|
'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/container',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/http-factory' => array(
|
||||||
|
'pretty_version' => '1.0.2',
|
||||||
|
'version' => '1.0.2.0',
|
||||||
|
'reference' => 'e616d01114759c4c489f93b099585439f795fe35',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/http-factory',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/http-message' => array(
|
||||||
|
'pretty_version' => '2.0',
|
||||||
|
'version' => '2.0.0.0',
|
||||||
|
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/http-message',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/http-server-handler' => array(
|
||||||
|
'pretty_version' => '1.0.2',
|
||||||
|
'version' => '1.0.2.0',
|
||||||
|
'reference' => '84c4fb66179be4caaf8e97bd239203245302e7d4',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/http-server-handler',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/http-server-middleware' => array(
|
||||||
|
'pretty_version' => '1.0.2',
|
||||||
|
'version' => '1.0.2.0',
|
||||||
|
'reference' => 'c1481f747daaa6a0782775cd6a8c26a1bf4a3829',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/http-server-middleware',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/log' => array(
|
||||||
|
'pretty_version' => '1.1.4',
|
||||||
|
'version' => '1.1.4.0',
|
||||||
|
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../psr/log',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'psr/simple-cache-implementation' => array(
|
||||||
|
'dev_requirement' => false,
|
||||||
|
'provided' => array(
|
||||||
|
0 => '1.0|2.0',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'slim/slim' => array(
|
||||||
|
'pretty_version' => '4.13.0',
|
||||||
|
'version' => '4.13.0.0',
|
||||||
|
'reference' => '038fd5713d5a41636fdff0e8dcceedecdd17fc17',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../slim/slim',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/cache' => array(
|
||||||
|
'pretty_version' => 'v4.4.48',
|
||||||
|
'version' => '4.4.48.0',
|
||||||
|
'reference' => '3b98ed664887ad197b8ede3da2432787212eb915',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/cache',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/cache-contracts' => array(
|
||||||
|
'pretty_version' => 'v2.5.2',
|
||||||
|
'version' => '2.5.2.0',
|
||||||
|
'reference' => '64be4a7acb83b6f2bf6de9a02cee6dad41277ebc',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/cache-contracts',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/cache-implementation' => array(
|
||||||
|
'dev_requirement' => false,
|
||||||
|
'provided' => array(
|
||||||
|
0 => '1.0|2.0',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'symfony/deprecation-contracts' => array(
|
||||||
|
'pretty_version' => 'v2.5.2',
|
||||||
|
'version' => '2.5.2.0',
|
||||||
|
'reference' => 'e8b495ea28c1d97b5e0c121748d6f9b53d075c66',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/expression-language' => array(
|
||||||
|
'pretty_version' => 'v3.4.47',
|
||||||
|
'version' => '3.4.47.0',
|
||||||
|
'reference' => 'de38e66398fca1fcb9c48e80279910e6889cb28f',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/expression-language',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/polyfill-php70' => array(
|
||||||
|
'pretty_version' => 'v1.20.0',
|
||||||
|
'version' => '1.20.0.0',
|
||||||
|
'reference' => '5f03a781d984aae42cebd18e7912fa80f02ee644',
|
||||||
|
'type' => 'metapackage',
|
||||||
|
'install_path' => null,
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/polyfill-php73' => array(
|
||||||
|
'pretty_version' => 'v1.29.0',
|
||||||
|
'version' => '1.29.0.0',
|
||||||
|
'reference' => '21bd091060673a1177ae842c0ef8fe30893114d2',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/polyfill-php73',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/polyfill-php80' => array(
|
||||||
|
'pretty_version' => 'v1.29.0',
|
||||||
|
'version' => '1.29.0.0',
|
||||||
|
'reference' => '87b68208d5c1188808dd7839ee1e6c8ec3b02f1b',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/polyfill-php80',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/service-contracts' => array(
|
||||||
|
'pretty_version' => 'v2.5.2',
|
||||||
|
'version' => '2.5.2.0',
|
||||||
|
'reference' => '4b426aac47d6427cc1a1d0f7e2ac724627f5966c',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/service-contracts',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/var-exporter' => array(
|
||||||
|
'pretty_version' => 'v5.4.35',
|
||||||
|
'version' => '5.4.35.0',
|
||||||
|
'reference' => 'abb0a151b62d6b07e816487e20040464af96cae7',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/var-exporter',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
26
advancedcontentfilter/vendor/composer/platform_check.php
vendored
Normal file
26
advancedcontentfilter/vendor/composer/platform_check.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// platform_check.php @generated by Composer
|
||||||
|
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
if (!(PHP_VERSION_ID >= 70400)) {
|
||||||
|
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issues) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
; This file is for unifying the coding style for different editors and IDEs.
|
|
||||||
; More information at http://editorconfig.org
|
|
||||||
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
indent_size = 4
|
|
||||||
indent_style = space
|
|
||||||
end_of_line = lf
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
|
@ -1,21 +0,0 @@
|
||||||
# The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 PHP Framework Interoperability Group
|
|
||||||
|
|
||||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
> of this software and associated documentation files (the "Software"), to deal
|
|
||||||
> in the Software without restriction, including without limitation the rights
|
|
||||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
> copies of the Software, and to permit persons to whom the Software is
|
|
||||||
> furnished to do so, subject to the following conditions:
|
|
||||||
>
|
|
||||||
> The above copyright notice and this permission notice shall be included in
|
|
||||||
> all copies or substantial portions of the Software.
|
|
||||||
>
|
|
||||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
> THE SOFTWARE.
|
|
|
@ -1,8 +0,0 @@
|
||||||
PHP FIG Simple Cache PSR
|
|
||||||
========================
|
|
||||||
|
|
||||||
This repository holds all interfaces related to PSR-16.
|
|
||||||
|
|
||||||
Note that this is not a cache implementation of its own. It is merely an interface that describes a cache implementation. See [the specification](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md) for more details.
|
|
||||||
|
|
||||||
You can find implementations of the specification by looking for packages providing the [psr/simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation) virtual package.
|
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"name": "psr/simple-cache",
|
|
||||||
"description": "Common interfaces for simple caching",
|
|
||||||
"keywords": ["psr", "psr-16", "cache", "simple-cache", "caching"],
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\SimpleCache\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Psr\SimpleCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface used for all types of exceptions thrown by the implementing library.
|
|
||||||
*/
|
|
||||||
interface CacheException
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,114 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Psr\SimpleCache;
|
|
||||||
|
|
||||||
interface CacheInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Fetches a value from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key The unique key of this item in the cache.
|
|
||||||
* @param mixed $default Default value to return if the key does not exist.
|
|
||||||
*
|
|
||||||
* @return mixed The value of the item from the cache, or $default in case of cache miss.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if the $key string is not a legal value.
|
|
||||||
*/
|
|
||||||
public function get($key, $default = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
|
|
||||||
*
|
|
||||||
* @param string $key The key of the item to store.
|
|
||||||
* @param mixed $value The value of the item to store, must be serializable.
|
|
||||||
* @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
|
|
||||||
* the driver supports TTL then the library may set a default value
|
|
||||||
* for it or let the driver take care of that.
|
|
||||||
*
|
|
||||||
* @return bool True on success and false on failure.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if the $key string is not a legal value.
|
|
||||||
*/
|
|
||||||
public function set($key, $value, $ttl = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an item from the cache by its unique key.
|
|
||||||
*
|
|
||||||
* @param string $key The unique cache key of the item to delete.
|
|
||||||
*
|
|
||||||
* @return bool True if the item was successfully removed. False if there was an error.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if the $key string is not a legal value.
|
|
||||||
*/
|
|
||||||
public function delete($key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wipes clean the entire cache's keys.
|
|
||||||
*
|
|
||||||
* @return bool True on success and false on failure.
|
|
||||||
*/
|
|
||||||
public function clear();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains multiple cache items by their unique keys.
|
|
||||||
*
|
|
||||||
* @param iterable $keys A list of keys that can obtained in a single operation.
|
|
||||||
* @param mixed $default Default value to return for keys that do not exist.
|
|
||||||
*
|
|
||||||
* @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if $keys is neither an array nor a Traversable,
|
|
||||||
* or if any of the $keys are not a legal value.
|
|
||||||
*/
|
|
||||||
public function getMultiple($keys, $default = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persists a set of key => value pairs in the cache, with an optional TTL.
|
|
||||||
*
|
|
||||||
* @param iterable $values A list of key => value pairs for a multiple-set operation.
|
|
||||||
* @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
|
|
||||||
* the driver supports TTL then the library may set a default value
|
|
||||||
* for it or let the driver take care of that.
|
|
||||||
*
|
|
||||||
* @return bool True on success and false on failure.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if $values is neither an array nor a Traversable,
|
|
||||||
* or if any of the $values are not a legal value.
|
|
||||||
*/
|
|
||||||
public function setMultiple($values, $ttl = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes multiple cache items in a single operation.
|
|
||||||
*
|
|
||||||
* @param iterable $keys A list of string-based keys to be deleted.
|
|
||||||
*
|
|
||||||
* @return bool True if the items were successfully removed. False if there was an error.
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if $keys is neither an array nor a Traversable,
|
|
||||||
* or if any of the $keys are not a legal value.
|
|
||||||
*/
|
|
||||||
public function deleteMultiple($keys);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether an item is present in the cache.
|
|
||||||
*
|
|
||||||
* NOTE: It is recommended that has() is only to be used for cache warming type purposes
|
|
||||||
* and not to be used within your live applications operations for get/set, as this method
|
|
||||||
* is subject to a race condition where your has() will return true and immediately after,
|
|
||||||
* another script can remove it making the state of your app out of date.
|
|
||||||
*
|
|
||||||
* @param string $key The cache item key.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* MUST be thrown if the $key string is not a legal value.
|
|
||||||
*/
|
|
||||||
public function has($key);
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Psr\SimpleCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exception interface for invalid cache arguments.
|
|
||||||
*
|
|
||||||
* When an invalid argument is passed it must throw an exception which implements
|
|
||||||
* this interface
|
|
||||||
*/
|
|
||||||
interface InvalidArgumentException extends CacheException
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
composer.lock
|
|
||||||
phpunit.xml
|
|
||||||
vendor/
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
||||||
|
|
||||||
abstract class AbstractRedisAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testExpiration' => 'Testing expiration slows down the test suite',
|
|
||||||
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $redis;
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('redis')) {
|
|
||||||
self::markTestSkipped('Extension redis required.');
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
(new \Redis())->connect(getenv('REDIS_HOST'));
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
self::markTestSkipped($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::$redis = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,175 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Cache\IntegrationTests\CachePoolTest;
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
|
||||||
use Symfony\Component\Cache\PruneableInterface;
|
|
||||||
|
|
||||||
abstract class AdapterTestCase extends CachePoolTest
|
|
||||||
{
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
if (!\array_key_exists('testDeferredSaveWithoutCommit', $this->skippedTests) && \defined('HHVM_VERSION')) {
|
|
||||||
$this->skippedTests['testDeferredSaveWithoutCommit'] = 'Destructors are called late on HHVM.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) {
|
|
||||||
$this->skippedTests['testPrune'] = 'Not a pruneable cache pool.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultLifeTime()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = $this->createCachePool(2);
|
|
||||||
|
|
||||||
$item = $cache->getItem('key.dlt');
|
|
||||||
$item->set('value');
|
|
||||||
$cache->save($item);
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
$item = $cache->getItem('key.dlt');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
$item = $cache->getItem('key.dlt');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExpiration()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
$cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2));
|
|
||||||
$cache->save($cache->getItem('k2')->set('v2')->expiresAfter(366 * 86400));
|
|
||||||
|
|
||||||
sleep(3);
|
|
||||||
$item = $cache->getItem('k1');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get(), "Item's value must be null when isHit() is false.");
|
|
||||||
|
|
||||||
$item = $cache->getItem('k2');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertSame('v2', $item->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotUnserializable()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $cache->getItem('foo');
|
|
||||||
$cache->save($item->set(new NotUnserializable()));
|
|
||||||
|
|
||||||
$item = $cache->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
foreach ($cache->getItems(['foo']) as $item) {
|
|
||||||
}
|
|
||||||
$cache->save($item->set(new NotUnserializable()));
|
|
||||||
|
|
||||||
foreach ($cache->getItems(['foo']) as $item) {
|
|
||||||
}
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrune()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!method_exists($this, 'isPruned')) {
|
|
||||||
$this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var PruneableInterface|CacheItemPoolInterface $cache */
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$doSet = function ($name, $value, \DateInterval $expiresAfter = null) use ($cache) {
|
|
||||||
$item = $cache->getItem($name);
|
|
||||||
$item->set($value);
|
|
||||||
|
|
||||||
if ($expiresAfter) {
|
|
||||||
$item->expiresAfter($expiresAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache->save($item);
|
|
||||||
};
|
|
||||||
|
|
||||||
$doSet('foo', 'foo-val', new \DateInterval('PT05S'));
|
|
||||||
$doSet('bar', 'bar-val', new \DateInterval('PT10S'));
|
|
||||||
$doSet('baz', 'baz-val', new \DateInterval('PT15S'));
|
|
||||||
$doSet('qux', 'qux-val', new \DateInterval('PT20S'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
$doSet('foo', 'foo-val');
|
|
||||||
$doSet('bar', 'bar-val', new \DateInterval('PT20S'));
|
|
||||||
$doSet('baz', 'baz-val', new \DateInterval('PT40S'));
|
|
||||||
$doSet('qux', 'qux-val', new \DateInterval('PT80S'));
|
|
||||||
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotUnserializable implements \Serializable
|
|
||||||
{
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return serialize(123);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize($ser)
|
|
||||||
{
|
|
||||||
throw new \Exception(__CLASS__);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Psr\Log\NullLogger;
|
|
||||||
use Symfony\Component\Cache\Adapter\ApcuAdapter;
|
|
||||||
|
|
||||||
class ApcuAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testExpiration' => 'Testing expiration slows down the test suite',
|
|
||||||
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
$this->markTestSkipped('APCu extension is required.');
|
|
||||||
}
|
|
||||||
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
if ('testWithCliSapi' !== $this->getName()) {
|
|
||||||
$this->markTestSkipped('apc.enable_cli=1 is required.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('Fails transiently on Windows.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ApcuAdapter(str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUnserializable()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$item->set(function () {});
|
|
||||||
|
|
||||||
$this->assertFalse($pool->save($item));
|
|
||||||
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVersion()
|
|
||||||
{
|
|
||||||
$namespace = str_replace('\\', '.', static::class);
|
|
||||||
|
|
||||||
$pool1 = new ApcuAdapter($namespace, 0, 'p1');
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertTrue($pool1->save($item->set('bar')));
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertSame('bar', $item->get());
|
|
||||||
|
|
||||||
$pool2 = new ApcuAdapter($namespace, 0, 'p2');
|
|
||||||
|
|
||||||
$item = $pool2->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get());
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNamespace()
|
|
||||||
{
|
|
||||||
$namespace = str_replace('\\', '.', static::class);
|
|
||||||
|
|
||||||
$pool1 = new ApcuAdapter($namespace.'_1', 0, 'p1');
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertTrue($pool1->save($item->set('bar')));
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertSame('bar', $item->get());
|
|
||||||
|
|
||||||
$pool2 = new ApcuAdapter($namespace.'_2', 0, 'p1');
|
|
||||||
|
|
||||||
$item = $pool2->getItem('foo');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get());
|
|
||||||
|
|
||||||
$item = $pool1->getItem('foo');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertSame('bar', $item->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testWithCliSapi()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
// disable PHPUnit error handler to mimic a production environment
|
|
||||||
$isCalled = false;
|
|
||||||
set_error_handler(function () use (&$isCalled) {
|
|
||||||
$isCalled = true;
|
|
||||||
});
|
|
||||||
$pool = new ApcuAdapter(str_replace('\\', '.', __CLASS__));
|
|
||||||
$pool->setLogger(new NullLogger());
|
|
||||||
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$item->isHit();
|
|
||||||
$pool->save($item->set('bar'));
|
|
||||||
$this->assertFalse($isCalled);
|
|
||||||
} finally {
|
|
||||||
restore_error_handler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class ArrayAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
|
|
||||||
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ArrayAdapter($defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetValuesHitAndMiss()
|
|
||||||
{
|
|
||||||
/** @var ArrayAdapter $cache */
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
// Hit
|
|
||||||
$item = $cache->getItem('foo');
|
|
||||||
$item->set('4711');
|
|
||||||
$cache->save($item);
|
|
||||||
|
|
||||||
$fooItem = $cache->getItem('foo');
|
|
||||||
$this->assertTrue($fooItem->isHit());
|
|
||||||
$this->assertEquals('4711', $fooItem->get());
|
|
||||||
|
|
||||||
// Miss (should be present as NULL in $values)
|
|
||||||
$cache->getItem('bar');
|
|
||||||
|
|
||||||
$values = $cache->getValues();
|
|
||||||
|
|
||||||
$this->assertCount(2, $values);
|
|
||||||
$this->assertArrayHasKey('foo', $values);
|
|
||||||
$this->assertSame(serialize('4711'), $values['foo']);
|
|
||||||
$this->assertArrayHasKey('bar', $values);
|
|
||||||
$this->assertNull($values['bar']);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,233 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
|
||||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\ChainAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\PruneableInterface;
|
|
||||||
use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class ChainAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ChainAdapter([new ArrayAdapter($defaultLifetime), new ExternalAdapter($defaultLifetime), new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEmptyAdaptersException()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('At least one adapter must be specified.');
|
|
||||||
new ChainAdapter([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidAdapterException()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('The class "stdClass" does not implement');
|
|
||||||
new ChainAdapter([new \stdClass()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrune()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = new ChainAdapter([
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
$this->getNonPruneableMock(),
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
]);
|
|
||||||
$this->assertTrue($cache->prune());
|
|
||||||
|
|
||||||
$cache = new ChainAdapter([
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
$this->getFailingPruneableMock(),
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
]);
|
|
||||||
$this->assertFalse($cache->prune());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMultipleCachesExpirationWhenCommonTtlIsNotSet()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$adapter1 = new ArrayAdapter(4);
|
|
||||||
$adapter2 = new ArrayAdapter(2);
|
|
||||||
|
|
||||||
$cache = new ChainAdapter([$adapter1, $adapter2]);
|
|
||||||
|
|
||||||
$cache->save($cache->getItem('key')->set('value'));
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
$adapter2->save($adapter2->getItem('key1')->set('value1'));
|
|
||||||
|
|
||||||
$item = $cache->getItem('key1');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value1', $item->get());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key1');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value1', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key1');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key1');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMultipleCachesExpirationWhenCommonTtlIsSet()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$adapter1 = new ArrayAdapter(4);
|
|
||||||
$adapter2 = new ArrayAdapter(2);
|
|
||||||
|
|
||||||
$cache = new ChainAdapter([$adapter1, $adapter2], 6);
|
|
||||||
|
|
||||||
$cache->save($cache->getItem('key')->set('value'));
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
$adapter2->save($adapter2->getItem('key1')->set('value1'));
|
|
||||||
|
|
||||||
$item = $cache->getItem('key1');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value1', $item->get());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key1');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value1', $item->get());
|
|
||||||
|
|
||||||
$item = $adapter2->getItem('key1');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key1');
|
|
||||||
$this->assertTrue($item->isHit());
|
|
||||||
$this->assertEquals('value1', $item->get());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$item = $adapter1->getItem('key1');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(true);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getFailingPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(false);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|AdapterInterface
|
|
||||||
*/
|
|
||||||
private function getNonPruneableMock()
|
|
||||||
{
|
|
||||||
return $this
|
|
||||||
->getMockBuilder(AdapterInterface::class)
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PruneableCacheInterface extends PruneableInterface, AdapterInterface
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
|
|
||||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class DoctrineAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.',
|
|
||||||
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.',
|
|
||||||
'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new DoctrineAdapter(new ArrayCache($defaultLifetime), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class FilesystemAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new FilesystemAdapter('', $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function rmdir($dir)
|
|
||||||
{
|
|
||||||
if (!file_exists($dir)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!$dir || 0 !== strpos(\dirname($dir), sys_get_temp_dir())) {
|
|
||||||
throw new \Exception(__METHOD__."() operates only on subdirs of system's temp dir");
|
|
||||||
}
|
|
||||||
$children = new \RecursiveIteratorIterator(
|
|
||||||
new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
|
|
||||||
\RecursiveIteratorIterator::CHILD_FIRST
|
|
||||||
);
|
|
||||||
foreach ($children as $child) {
|
|
||||||
if ($child->isDir()) {
|
|
||||||
rmdir($child);
|
|
||||||
} else {
|
|
||||||
unlink($child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rmdir($dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isPruned(CacheItemPoolInterface $cache, $name)
|
|
||||||
{
|
|
||||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
|
||||||
$getFileMethod->setAccessible(true);
|
|
||||||
|
|
||||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|
||||||
|
|
||||||
class MaxIdLengthAdapterTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testLongKey()
|
|
||||||
{
|
|
||||||
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
|
|
||||||
->setConstructorArgs([str_repeat('-', 10)])
|
|
||||||
->setMethods(['doHave', 'doFetch', 'doDelete', 'doSave', 'doClear'])
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$cache->expects($this->exactly(2))
|
|
||||||
->method('doHave')
|
|
||||||
->withConsecutive(
|
|
||||||
[$this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')],
|
|
||||||
[$this->equalTo('----------:---------------------------------------')]
|
|
||||||
);
|
|
||||||
|
|
||||||
$cache->hasItem(str_repeat('-', 40));
|
|
||||||
$cache->hasItem(str_repeat('-', 39));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLongKeyVersioning()
|
|
||||||
{
|
|
||||||
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
|
|
||||||
->setConstructorArgs([str_repeat('-', 26)])
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$cache
|
|
||||||
->method('doFetch')
|
|
||||||
->willReturn(['2:']);
|
|
||||||
|
|
||||||
$reflectionClass = new \ReflectionClass(AbstractAdapter::class);
|
|
||||||
|
|
||||||
$reflectionMethod = $reflectionClass->getMethod('getId');
|
|
||||||
$reflectionMethod->setAccessible(true);
|
|
||||||
|
|
||||||
// No versioning enabled
|
|
||||||
$this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
|
|
||||||
|
|
||||||
$reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue($cache, true);
|
|
||||||
|
|
||||||
// Versioning enabled
|
|
||||||
$this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
|
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTooLongNamespace()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
|
|
||||||
$this->getMockBuilder(MaxIdLengthAdapter::class)
|
|
||||||
->setConstructorArgs([str_repeat('-', 40)])
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class MaxIdLengthAdapter extends AbstractAdapter
|
|
||||||
{
|
|
||||||
protected $maxIdLength = 50;
|
|
||||||
|
|
||||||
public function __construct($ns)
|
|
||||||
{
|
|
||||||
parent::__construct($ns);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,204 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
|
||||||
|
|
||||||
class MemcachedAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $client;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!MemcachedAdapter::isSupported()) {
|
|
||||||
self::markTestSkipped('Extension memcached >=2.2.0 required.');
|
|
||||||
}
|
|
||||||
self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]);
|
|
||||||
self::$client->get('foo');
|
|
||||||
$code = self::$client->getResultCode();
|
|
||||||
|
|
||||||
if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) {
|
|
||||||
self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client;
|
|
||||||
|
|
||||||
return new MemcachedAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOptions()
|
|
||||||
{
|
|
||||||
$client = MemcachedAdapter::createConnection([], [
|
|
||||||
'libketama_compatible' => false,
|
|
||||||
'distribution' => 'modula',
|
|
||||||
'compression' => true,
|
|
||||||
'serializer' => 'php',
|
|
||||||
'hash' => 'md5',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER));
|
|
||||||
$this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH));
|
|
||||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
|
||||||
$this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
|
||||||
$this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideBadOptions
|
|
||||||
*/
|
|
||||||
public function testBadOptions($name, $value)
|
|
||||||
{
|
|
||||||
if (\PHP_VERSION_ID < 80000) {
|
|
||||||
$this->expectException('ErrorException');
|
|
||||||
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
|
|
||||||
} else {
|
|
||||||
$this->expectException('Error');
|
|
||||||
$this->expectExceptionMessage('Undefined constant Memcached::');
|
|
||||||
}
|
|
||||||
|
|
||||||
MemcachedAdapter::createConnection([], [$name => $value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideBadOptions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['foo', 'bar'],
|
|
||||||
['hash', 'zyx'],
|
|
||||||
['serializer', 'zyx'],
|
|
||||||
['distribution', 'zyx'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultOptions()
|
|
||||||
{
|
|
||||||
$this->assertTrue(MemcachedAdapter::isSupported());
|
|
||||||
|
|
||||||
$client = MemcachedAdapter::createConnection([]);
|
|
||||||
|
|
||||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
|
||||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL));
|
|
||||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_TCP_NODELAY));
|
|
||||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOptionSerializer()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\CacheException');
|
|
||||||
$this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
|
|
||||||
if (!\Memcached::HAVE_JSON) {
|
|
||||||
$this->markTestSkipped('Memcached::HAVE_JSON required');
|
|
||||||
}
|
|
||||||
|
|
||||||
new MemcachedAdapter(MemcachedAdapter::createConnection([], ['serializer' => 'json']));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideServersSetting
|
|
||||||
*/
|
|
||||||
public function testServersSetting($dsn, $host, $port)
|
|
||||||
{
|
|
||||||
$client1 = MemcachedAdapter::createConnection($dsn);
|
|
||||||
$client2 = MemcachedAdapter::createConnection([$dsn]);
|
|
||||||
$client3 = MemcachedAdapter::createConnection([[$host, $port]]);
|
|
||||||
$expect = [
|
|
||||||
'host' => $host,
|
|
||||||
'port' => $port,
|
|
||||||
];
|
|
||||||
|
|
||||||
$f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; };
|
|
||||||
$this->assertSame([$expect], array_map($f, $client1->getServerList()));
|
|
||||||
$this->assertSame([$expect], array_map($f, $client2->getServerList()));
|
|
||||||
$this->assertSame([$expect], array_map($f, $client3->getServerList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideServersSetting()
|
|
||||||
{
|
|
||||||
yield [
|
|
||||||
'memcached://127.0.0.1/50',
|
|
||||||
'127.0.0.1',
|
|
||||||
11211,
|
|
||||||
];
|
|
||||||
yield [
|
|
||||||
'memcached://localhost:11222?weight=25',
|
|
||||||
'localhost',
|
|
||||||
11222,
|
|
||||||
];
|
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
yield [
|
|
||||||
'memcached://user:password@127.0.0.1?weight=50',
|
|
||||||
'127.0.0.1',
|
|
||||||
11211,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
yield [
|
|
||||||
'memcached:///var/run/memcached.sock?weight=25',
|
|
||||||
'/var/run/memcached.sock',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
yield [
|
|
||||||
'memcached:///var/local/run/memcached.socket?weight=25',
|
|
||||||
'/var/local/run/memcached.socket',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
yield [
|
|
||||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
|
||||||
'/var/local/run/memcached.socket',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideDsnWithOptions
|
|
||||||
*/
|
|
||||||
public function testDsnWithOptions($dsn, array $options, array $expectedOptions)
|
|
||||||
{
|
|
||||||
$client = MemcachedAdapter::createConnection($dsn, $options);
|
|
||||||
|
|
||||||
foreach ($expectedOptions as $option => $expect) {
|
|
||||||
$this->assertSame($expect, $client->getOption($option));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideDsnWithOptions()
|
|
||||||
{
|
|
||||||
if (!class_exists('\Memcached')) {
|
|
||||||
self::markTestSkipped('Extension memcached required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'memcached://localhost:11222?retry_timeout=10',
|
|
||||||
[\Memcached::OPT_RETRY_TIMEOUT => 8],
|
|
||||||
[\Memcached::OPT_RETRY_TIMEOUT => 10],
|
|
||||||
];
|
|
||||||
yield [
|
|
||||||
'memcached://localhost:11222?socket_recv_size=1&socket_send_size=2',
|
|
||||||
[\Memcached::OPT_RETRY_TIMEOUT => 8],
|
|
||||||
[\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testClear()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->clear());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class NamespacedProxyAdapterTest extends ProxyAdapterTest
|
|
||||||
{
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ProxyAdapter(new ArrayAdapter($defaultLifetime), 'foo', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,128 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\NullAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class NullAdapterTest extends TestCase
|
|
||||||
{
|
|
||||||
public function createCachePool()
|
|
||||||
{
|
|
||||||
return new NullAdapter();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItem()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $adapter->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasItem()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->createCachePool()->hasItem('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItems()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$keys = ['foo', 'bar', 'baz', 'biz'];
|
|
||||||
|
|
||||||
/** @var CacheItemInterface[] $items */
|
|
||||||
$items = $adapter->getItems($keys);
|
|
||||||
$count = 0;
|
|
||||||
|
|
||||||
foreach ($items as $key => $item) {
|
|
||||||
$itemKey = $item->getKey();
|
|
||||||
|
|
||||||
$this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items');
|
|
||||||
$this->assertContains($key, $keys, 'Cache key can not change.');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
// Remove $key for $keys
|
|
||||||
foreach ($keys as $k => $v) {
|
|
||||||
if ($v === $key) {
|
|
||||||
unset($keys[$k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++$count;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(4, $count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIsHit()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $adapter->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testClear()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->clear());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteItem()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->deleteItem('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteItems()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->deleteItems(['key', 'foo', 'bar']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSave()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $adapter->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
|
|
||||||
|
|
||||||
$this->assertFalse($adapter->save($item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeferredSave()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $adapter->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
|
|
||||||
|
|
||||||
$this->assertFalse($adapter->saveDeferred($item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCommit()
|
|
||||||
{
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $adapter->getItem('key');
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
|
|
||||||
|
|
||||||
$this->assertFalse($adapter->saveDeferred($item));
|
|
||||||
$this->assertFalse($this->createCachePool()->commit());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\PdoAdapter;
|
|
||||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PdoAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
use PdoPruneableTrait;
|
|
||||||
|
|
||||||
protected static $dbFile;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('pdo_sqlite')) {
|
|
||||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
|
||||||
|
|
||||||
$pool = new PdoAdapter('sqlite:'.self::$dbFile);
|
|
||||||
$pool->createTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCleanupExpiredItems()
|
|
||||||
{
|
|
||||||
$pdo = new \PDO('sqlite:'.self::$dbFile);
|
|
||||||
|
|
||||||
$getCacheItemCount = function () use ($pdo) {
|
|
||||||
return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN);
|
|
||||||
};
|
|
||||||
|
|
||||||
$this->assertSame(0, $getCacheItemCount());
|
|
||||||
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$item = $cache->getItem('some_nice_key');
|
|
||||||
$item->expiresAfter(1);
|
|
||||||
$item->set(1);
|
|
||||||
|
|
||||||
$cache->save($item);
|
|
||||||
$this->assertSame(1, $getCacheItemCount());
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
$newItem = $cache->getItem($item->getKey());
|
|
||||||
$this->assertFalse($newItem->isHit());
|
|
||||||
$this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\DriverManager;
|
|
||||||
use Symfony\Component\Cache\Adapter\PdoAdapter;
|
|
||||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PdoDbalAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
use PdoPruneableTrait;
|
|
||||||
|
|
||||||
protected static $dbFile;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('pdo_sqlite')) {
|
|
||||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
|
||||||
|
|
||||||
$pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
|
|
||||||
$pool->createTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\NullAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpArrayAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testBasicUsage' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testBasicUsageWithLongKey' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testClear' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testClearWithDeferredItems' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testDeleteItem' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testSaveExpired' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testSaveWithoutExpire' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testDeferredSave' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testDeferredSaveWithoutCommit' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testDeleteItems' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testDeleteDeferredItem' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testCommit' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testSaveDeferredWhenChangingValues' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testSaveDeferredOverwrite' => 'PhpArrayAdapter is read-only.',
|
|
||||||
'testIsHitDeferred' => 'PhpArrayAdapter is read-only.',
|
|
||||||
|
|
||||||
'testExpiresAt' => 'PhpArrayAdapter does not support expiration.',
|
|
||||||
'testExpiresAtWithNull' => 'PhpArrayAdapter does not support expiration.',
|
|
||||||
'testExpiresAfterWithNull' => 'PhpArrayAdapter does not support expiration.',
|
|
||||||
'testDeferredExpired' => 'PhpArrayAdapter does not support expiration.',
|
|
||||||
'testExpiration' => 'PhpArrayAdapter does not support expiration.',
|
|
||||||
|
|
||||||
'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
|
|
||||||
'testDefaultLifeTime' => 'PhpArrayAdapter does not allow configuring a default lifetime.',
|
|
||||||
'testPrune' => 'PhpArrayAdapter just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $file;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->createCachePool()->clear();
|
|
||||||
|
|
||||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool()
|
|
||||||
{
|
|
||||||
return new PhpArrayAdapterWrapper(self::$file, new NullAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStore()
|
|
||||||
{
|
|
||||||
$arrayWithRefs = [];
|
|
||||||
$arrayWithRefs[0] = 123;
|
|
||||||
$arrayWithRefs[1] = &$arrayWithRefs[0];
|
|
||||||
|
|
||||||
$object = (object) [
|
|
||||||
'foo' => 'bar',
|
|
||||||
'foo2' => 'bar2',
|
|
||||||
];
|
|
||||||
|
|
||||||
$expected = [
|
|
||||||
'null' => null,
|
|
||||||
'serializedString' => serialize($object),
|
|
||||||
'arrayWithRefs' => $arrayWithRefs,
|
|
||||||
'object' => $object,
|
|
||||||
'arrayWithObject' => ['bar' => $object],
|
|
||||||
];
|
|
||||||
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
$adapter->warmUp($expected);
|
|
||||||
|
|
||||||
foreach ($expected as $key => $value) {
|
|
||||||
$this->assertSame(serialize($value), serialize($adapter->getItem($key)->get()), 'Warm up should create a PHP file that OPCache can load in memory');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStoredFile()
|
|
||||||
{
|
|
||||||
$expected = [
|
|
||||||
'integer' => 42,
|
|
||||||
'float' => 42.42,
|
|
||||||
'boolean' => true,
|
|
||||||
'array_simple' => ['foo', 'bar'],
|
|
||||||
'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'],
|
|
||||||
];
|
|
||||||
|
|
||||||
$adapter = $this->createCachePool();
|
|
||||||
$adapter->warmUp($expected);
|
|
||||||
|
|
||||||
$values = eval(substr(file_get_contents(self::$file), 6));
|
|
||||||
|
|
||||||
$this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PhpArrayAdapterWrapper extends PhpArrayAdapter
|
|
||||||
{
|
|
||||||
public function save(CacheItemInterface $item)
|
|
||||||
{
|
|
||||||
\call_user_func(\Closure::bind(function () use ($item) {
|
|
||||||
$this->values[$item->getKey()] = $item->get();
|
|
||||||
$this->warmUp($this->values);
|
|
||||||
$this->values = eval(substr(file_get_contents($this->file), 6));
|
|
||||||
}, $this, PhpArrayAdapter::class));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpArrayAdapterWithFallbackTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
|
|
||||||
'testPrune' => 'PhpArrayAdapter just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $file;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->createCachePool()->clear();
|
|
||||||
|
|
||||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PhpArrayAdapter(self::$file, new FilesystemAdapter('php-array-fallback', $defaultLifetime));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpFilesAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool()
|
|
||||||
{
|
|
||||||
if (!PhpFilesAdapter::isSupported()) {
|
|
||||||
$this->markTestSkipped('OPcache extension is not enabled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PhpFilesAdapter('sf-cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isPruned(CacheItemPoolInterface $cache, $name)
|
|
||||||
{
|
|
||||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
|
||||||
$getFileMethod->setAccessible(true);
|
|
||||||
|
|
||||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Predis\Connection\StreamConnection;
|
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
||||||
|
|
||||||
class PredisAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setUpBeforeClass();
|
|
||||||
self::$redis = new \Predis\Client(['host' => getenv('REDIS_HOST')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateConnection()
|
|
||||||
{
|
|
||||||
$redisHost = getenv('REDIS_HOST');
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', ['class' => \Predis\Client::class, 'timeout' => 3]);
|
|
||||||
$this->assertInstanceOf(\Predis\Client::class, $redis);
|
|
||||||
|
|
||||||
$connection = $redis->getConnection();
|
|
||||||
$this->assertInstanceOf(StreamConnection::class, $connection);
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'scheme' => 'tcp',
|
|
||||||
'host' => $redisHost,
|
|
||||||
'path' => '',
|
|
||||||
'dbindex' => '1',
|
|
||||||
'port' => 6379,
|
|
||||||
'class' => 'Predis\Client',
|
|
||||||
'timeout' => 3,
|
|
||||||
'persistent' => 0,
|
|
||||||
'persistent_id' => null,
|
|
||||||
'read_timeout' => 0,
|
|
||||||
'retry_interval' => 0,
|
|
||||||
'lazy' => false,
|
|
||||||
'database' => '1',
|
|
||||||
'password' => null,
|
|
||||||
];
|
|
||||||
$this->assertSame($params, $connection->getParameters()->toArray());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
class PredisClusterAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setUpBeforeClass();
|
|
||||||
self::$redis = new \Predis\Client([['host' => getenv('REDIS_HOST')]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::$redis = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
|
|
||||||
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
|
|
||||||
}
|
|
||||||
self::$redis = new \Predis\Client(explode(' ', $hosts), ['cluster' => 'redis']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::$redis = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
|
||||||
use Symfony\Component\Cache\CacheItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class ProxyAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
|
|
||||||
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
|
|
||||||
'testPrune' => 'ProxyAdapter just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testProxyfiedItem()
|
|
||||||
{
|
|
||||||
$this->expectException('Exception');
|
|
||||||
$this->expectExceptionMessage('OK bar');
|
|
||||||
$item = new CacheItem();
|
|
||||||
$pool = new ProxyAdapter(new TestingArrayAdapter($item));
|
|
||||||
|
|
||||||
$proxyItem = $pool->getItem('foo');
|
|
||||||
|
|
||||||
$this->assertNotSame($item, $proxyItem);
|
|
||||||
$pool->save($proxyItem->set('bar'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestingArrayAdapter extends ArrayAdapter
|
|
||||||
{
|
|
||||||
private $item;
|
|
||||||
|
|
||||||
public function __construct(CacheItemInterface $item)
|
|
||||||
{
|
|
||||||
$this->item = $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getItem($key)
|
|
||||||
{
|
|
||||||
return $this->item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(CacheItemInterface $item)
|
|
||||||
{
|
|
||||||
if ($item === $this->item) {
|
|
||||||
throw new \Exception('OK '.$item->get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
||||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
|
||||||
|
|
||||||
class RedisAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setUpBeforeClass();
|
|
||||||
self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
$adapter = parent::createCachePool($defaultLifetime);
|
|
||||||
$this->assertInstanceOf(RedisProxy::class, self::$redis);
|
|
||||||
|
|
||||||
return $adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateConnection()
|
|
||||||
{
|
|
||||||
$redisHost = getenv('REDIS_HOST');
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost);
|
|
||||||
$this->assertInstanceOf(\Redis::class, $redis);
|
|
||||||
$this->assertTrue($redis->isConnected());
|
|
||||||
$this->assertSame(0, $redis->getDbNum());
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2');
|
|
||||||
$this->assertSame(2, $redis->getDbNum());
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost, ['timeout' => 3]);
|
|
||||||
$this->assertEquals(3, $redis->getTimeout());
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4');
|
|
||||||
$this->assertEquals(4, $redis->getTimeout());
|
|
||||||
|
|
||||||
$redis = RedisAdapter::createConnection('redis://'.$redisHost, ['read_timeout' => 5]);
|
|
||||||
$this->assertEquals(5, $redis->getReadTimeout());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideFailedCreateConnection
|
|
||||||
*/
|
|
||||||
public function testFailedCreateConnection($dsn)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Redis connection ');
|
|
||||||
RedisAdapter::createConnection($dsn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideFailedCreateConnection()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['redis://localhost:1234'],
|
|
||||||
['redis://foo@localhost'],
|
|
||||||
['redis://localhost/123'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideInvalidCreateConnection
|
|
||||||
*/
|
|
||||||
public function testInvalidCreateConnection($dsn)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Invalid Redis DSN');
|
|
||||||
RedisAdapter::createConnection($dsn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideInvalidCreateConnection()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['foo://localhost'],
|
|
||||||
['redis://'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
class RedisArrayAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setupBeforeClass();
|
|
||||||
if (!class_exists('RedisArray')) {
|
|
||||||
self::markTestSkipped('The RedisArray class is required.');
|
|
||||||
}
|
|
||||||
self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!class_exists('RedisCluster')) {
|
|
||||||
self::markTestSkipped('The RedisCluster class is required.');
|
|
||||||
}
|
|
||||||
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
|
|
||||||
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$redis = new \RedisCluster(null, explode(' ', $hosts));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
|
|
||||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class SimpleCacheAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testPrune' => 'SimpleCache just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testValidCacheKeyWithNamespace()
|
|
||||||
{
|
|
||||||
$cache = new SimpleCacheAdapter(new ArrayCache(), 'some_namespace', 0);
|
|
||||||
$item = $cache->getItem('my_key');
|
|
||||||
$item->set('someValue');
|
|
||||||
$cache->save($item);
|
|
||||||
|
|
||||||
$this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,338 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class TagAwareAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new TagAwareAdapter(new FilesystemAdapter('', $defaultLifetime));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidTag()
|
|
||||||
{
|
|
||||||
$this->expectException('Psr\Cache\InvalidArgumentException');
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$item->tag(':');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidateTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$i0 = $pool->getItem('i0');
|
|
||||||
$i1 = $pool->getItem('i1');
|
|
||||||
$i2 = $pool->getItem('i2');
|
|
||||||
$i3 = $pool->getItem('i3');
|
|
||||||
$foo = $pool->getItem('foo');
|
|
||||||
|
|
||||||
$pool->save($i0->tag('bar'));
|
|
||||||
$pool->save($i1->tag('foo'));
|
|
||||||
$pool->save($i2->tag('foo')->tag('bar'));
|
|
||||||
$pool->save($i3->tag('foo')->tag('baz'));
|
|
||||||
$pool->save($foo);
|
|
||||||
|
|
||||||
$pool->invalidateTags(['bar']);
|
|
||||||
|
|
||||||
$this->assertFalse($pool->getItem('i0')->isHit());
|
|
||||||
$this->assertTrue($pool->getItem('i1')->isHit());
|
|
||||||
$this->assertFalse($pool->getItem('i2')->isHit());
|
|
||||||
$this->assertTrue($pool->getItem('i3')->isHit());
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
$pool->invalidateTags(['foo']);
|
|
||||||
|
|
||||||
$this->assertFalse($pool->getItem('i1')->isHit());
|
|
||||||
$this->assertFalse($pool->getItem('i3')->isHit());
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
$anotherPoolInstance = $this->createCachePool();
|
|
||||||
|
|
||||||
$this->assertFalse($anotherPoolInstance->getItem('i1')->isHit());
|
|
||||||
$this->assertFalse($anotherPoolInstance->getItem('i3')->isHit());
|
|
||||||
$this->assertTrue($anotherPoolInstance->getItem('foo')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidateCommits()
|
|
||||||
{
|
|
||||||
$pool1 = $this->createCachePool();
|
|
||||||
|
|
||||||
$foo = $pool1->getItem('foo');
|
|
||||||
$foo->tag('tag');
|
|
||||||
|
|
||||||
$pool1->saveDeferred($foo->set('foo'));
|
|
||||||
$pool1->invalidateTags(['tag']);
|
|
||||||
|
|
||||||
$pool2 = $this->createCachePool();
|
|
||||||
$foo = $pool2->getItem('foo');
|
|
||||||
|
|
||||||
$this->assertTrue($foo->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagsAreCleanedOnSave()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$i = $pool->getItem('k');
|
|
||||||
$pool->save($i->tag('foo'));
|
|
||||||
|
|
||||||
$i = $pool->getItem('k');
|
|
||||||
$pool->save($i->tag('bar'));
|
|
||||||
|
|
||||||
$pool->invalidateTags(['foo']);
|
|
||||||
$this->assertTrue($pool->getItem('k')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagsAreCleanedOnDelete()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$i = $pool->getItem('k');
|
|
||||||
$pool->save($i->tag('foo'));
|
|
||||||
$pool->deleteItem('k');
|
|
||||||
|
|
||||||
$pool->save($pool->getItem('k'));
|
|
||||||
$pool->invalidateTags(['foo']);
|
|
||||||
|
|
||||||
$this->assertTrue($pool->getItem('k')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagItemExpiry()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool(10);
|
|
||||||
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$item->tag(['baz']);
|
|
||||||
$item->expiresAfter(100);
|
|
||||||
|
|
||||||
$pool->save($item);
|
|
||||||
$pool->invalidateTags(['baz']);
|
|
||||||
$this->assertFalse($pool->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
sleep(20);
|
|
||||||
|
|
||||||
$this->assertFalse($pool->getItem('foo')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetPreviousTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$i = $pool->getItem('k');
|
|
||||||
$pool->save($i->tag('foo'));
|
|
||||||
|
|
||||||
$i = $pool->getItem('k');
|
|
||||||
$this->assertSame(['foo' => 'foo'], $i->getPreviousTags());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrune()
|
|
||||||
{
|
|
||||||
$cache = new TagAwareAdapter($this->getPruneableMock());
|
|
||||||
$this->assertTrue($cache->prune());
|
|
||||||
|
|
||||||
$cache = new TagAwareAdapter($this->getNonPruneableMock());
|
|
||||||
$this->assertFalse($cache->prune());
|
|
||||||
|
|
||||||
$cache = new TagAwareAdapter($this->getFailingPruneableMock());
|
|
||||||
$this->assertFalse($cache->prune());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testKnownTagVersionsTtl()
|
|
||||||
{
|
|
||||||
$itemsPool = new FilesystemAdapter('', 10);
|
|
||||||
$tagsPool = $this
|
|
||||||
->getMockBuilder(AdapterInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pool = new TagAwareAdapter($itemsPool, $tagsPool, 10);
|
|
||||||
|
|
||||||
$item = $pool->getItem('foo');
|
|
||||||
$item->tag(['baz']);
|
|
||||||
$item->expiresAfter(100);
|
|
||||||
|
|
||||||
$tag = $this->getMockBuilder(CacheItemInterface::class)->getMock();
|
|
||||||
$tag->expects(self::exactly(2))->method('get')->willReturn(10);
|
|
||||||
|
|
||||||
$tagsPool->expects(self::exactly(2))->method('getItems')->willReturn([
|
|
||||||
'baz'.TagAwareAdapter::TAGS_PREFIX => $tag,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$pool->save($item);
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
sleep(20);
|
|
||||||
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
sleep(5);
|
|
||||||
|
|
||||||
$this->assertTrue($pool->getItem('foo')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagEntryIsCreatedForItemWithoutTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$itemKey = 'foo';
|
|
||||||
$item = $pool->getItem($itemKey);
|
|
||||||
$pool->save($item);
|
|
||||||
|
|
||||||
$adapter = new FilesystemAdapter();
|
|
||||||
$this->assertTrue($adapter->hasItem(TagAwareAdapter::TAGS_PREFIX.$itemKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$itemKey = 'foo';
|
|
||||||
$item = $pool->getItem($itemKey);
|
|
||||||
$pool->save($item);
|
|
||||||
|
|
||||||
$anotherPool = $this->createCachePool();
|
|
||||||
|
|
||||||
$adapter = new FilesystemAdapter();
|
|
||||||
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair
|
|
||||||
|
|
||||||
$this->assertFalse($anotherPool->hasItem($itemKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$itemKey = 'foo';
|
|
||||||
$item = $pool->getItem($itemKey);
|
|
||||||
$pool->save($item);
|
|
||||||
|
|
||||||
$anotherPool = $this->createCachePool();
|
|
||||||
|
|
||||||
$adapter = new FilesystemAdapter();
|
|
||||||
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair
|
|
||||||
|
|
||||||
$item = $anotherPool->getItem($itemKey);
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$itemKey = 'foo';
|
|
||||||
$item = $pool->getItem($itemKey);
|
|
||||||
$pool->save($item);
|
|
||||||
|
|
||||||
$anotherPool = $this->createCachePool();
|
|
||||||
|
|
||||||
$adapter = new FilesystemAdapter();
|
|
||||||
$adapter->deleteItem($itemKey); //simulate losing item but keeping tags
|
|
||||||
|
|
||||||
$this->assertFalse($anotherPool->hasItem($itemKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidateTagsWithArrayAdapter()
|
|
||||||
{
|
|
||||||
$adapter = new TagAwareAdapter(new ArrayAdapter());
|
|
||||||
|
|
||||||
$item = $adapter->getItem('foo');
|
|
||||||
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
|
|
||||||
$item->tag('bar');
|
|
||||||
$item->expiresAfter(100);
|
|
||||||
$adapter->save($item);
|
|
||||||
|
|
||||||
$this->assertTrue($adapter->getItem('foo')->isHit());
|
|
||||||
|
|
||||||
$adapter->invalidateTags(['bar']);
|
|
||||||
|
|
||||||
$this->assertFalse($adapter->getItem('foo')->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
|
|
||||||
$itemKey = 'foo';
|
|
||||||
$item = $pool->getItem($itemKey);
|
|
||||||
$pool->save($item);
|
|
||||||
|
|
||||||
$anotherPool = $this->createCachePool();
|
|
||||||
|
|
||||||
$adapter = new FilesystemAdapter();
|
|
||||||
$adapter->deleteItem($itemKey); //simulate losing item but keeping tags
|
|
||||||
|
|
||||||
$item = $anotherPool->getItem($itemKey);
|
|
||||||
$this->assertFalse($item->isHit());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(true);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getFailingPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(false);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|AdapterInterface
|
|
||||||
*/
|
|
||||||
private function getNonPruneableMock()
|
|
||||||
{
|
|
||||||
return $this
|
|
||||||
->getMockBuilder(AdapterInterface::class)
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
|
||||||
use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
|
|
||||||
|
|
||||||
class TagAwareAndProxyAdapterIntegrationTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider dataProvider
|
|
||||||
*/
|
|
||||||
public function testIntegrationUsingProxiedAdapter(CacheItemPoolInterface $proxiedAdapter)
|
|
||||||
{
|
|
||||||
$cache = new TagAwareAdapter(new ProxyAdapter($proxiedAdapter));
|
|
||||||
|
|
||||||
$item = $cache->getItem('foo');
|
|
||||||
$item->tag(['tag1', 'tag2']);
|
|
||||||
$item->set('bar');
|
|
||||||
$cache->save($item);
|
|
||||||
|
|
||||||
$this->assertSame('bar', $cache->getItem('foo')->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataProvider()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[new ArrayAdapter()],
|
|
||||||
// also testing with a non-AdapterInterface implementation
|
|
||||||
// because the ProxyAdapter behaves slightly different for those
|
|
||||||
[new ExternalAdapter()],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,191 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\TraceableAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class TraceableAdapterTest extends AdapterTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testPrune' => 'TraceableAdapter just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new TraceableAdapter(new FilesystemAdapter('', $defaultLifetime));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItemMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$pool->getItem('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('getItem', $call->name);
|
|
||||||
$this->assertSame(['k' => false], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(1, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItemHitTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$item = $pool->getItem('k')->set('foo');
|
|
||||||
$pool->save($item);
|
|
||||||
$pool->getItem('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(3, $calls);
|
|
||||||
|
|
||||||
$call = $calls[2];
|
|
||||||
$this->assertSame(1, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItemsMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$arg = ['k0', 'k1'];
|
|
||||||
$items = $pool->getItems($arg);
|
|
||||||
foreach ($items as $item) {
|
|
||||||
}
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('getItems', $call->name);
|
|
||||||
$this->assertSame(['k0' => false, 'k1' => false], $call->result);
|
|
||||||
$this->assertSame(2, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasItemMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$pool->hasItem('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('hasItem', $call->name);
|
|
||||||
$this->assertSame(['k' => false], $call->result);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasItemHitTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$item = $pool->getItem('k')->set('foo');
|
|
||||||
$pool->save($item);
|
|
||||||
$pool->hasItem('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(3, $calls);
|
|
||||||
|
|
||||||
$call = $calls[2];
|
|
||||||
$this->assertSame('hasItem', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteItemTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$pool->deleteItem('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('deleteItem', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteItemsTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$arg = ['k0', 'k1'];
|
|
||||||
$pool->deleteItems($arg);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('deleteItems', $call->name);
|
|
||||||
$this->assertSame(['keys' => $arg, 'result' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSaveTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$item = $pool->getItem('k')->set('foo');
|
|
||||||
$pool->save($item);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(2, $calls);
|
|
||||||
|
|
||||||
$call = $calls[1];
|
|
||||||
$this->assertSame('save', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSaveDeferredTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$item = $pool->getItem('k')->set('foo');
|
|
||||||
$pool->saveDeferred($item);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(2, $calls);
|
|
||||||
|
|
||||||
$call = $calls[1];
|
|
||||||
$this->assertSame('saveDeferred', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCommitTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createCachePool();
|
|
||||||
$pool->commit();
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('commit', $call->name);
|
|
||||||
$this->assertTrue($call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
|
||||||
use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class TraceableTagAwareAdapterTest extends TraceableAdapterTest
|
|
||||||
{
|
|
||||||
public function testInvalidateTags()
|
|
||||||
{
|
|
||||||
$pool = new TraceableTagAwareAdapter(new TagAwareAdapter(new FilesystemAdapter()));
|
|
||||||
$pool->invalidateTags(['foo']);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('invalidateTags', $call->name);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Cache\CacheItem;
|
|
||||||
|
|
||||||
class CacheItemTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testValidKey()
|
|
||||||
{
|
|
||||||
$this->assertSame('foo', CacheItem::validateKey('foo'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideInvalidKey
|
|
||||||
*/
|
|
||||||
public function testInvalidKey($key)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Cache key');
|
|
||||||
CacheItem::validateKey($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideInvalidKey()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[''],
|
|
||||||
['{'],
|
|
||||||
['}'],
|
|
||||||
['('],
|
|
||||||
[')'],
|
|
||||||
['/'],
|
|
||||||
['\\'],
|
|
||||||
['@'],
|
|
||||||
[':'],
|
|
||||||
[true],
|
|
||||||
[null],
|
|
||||||
[1],
|
|
||||||
[1.1],
|
|
||||||
[[[]]],
|
|
||||||
[new \Exception('foo')],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTag()
|
|
||||||
{
|
|
||||||
$item = new CacheItem();
|
|
||||||
|
|
||||||
$this->assertSame($item, $item->tag('foo'));
|
|
||||||
$this->assertSame($item, $item->tag(['bar', 'baz']));
|
|
||||||
|
|
||||||
\call_user_func(\Closure::bind(function () use ($item) {
|
|
||||||
$this->assertSame(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'], $item->tags);
|
|
||||||
}, $this, CacheItem::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideInvalidKey
|
|
||||||
*/
|
|
||||||
public function testInvalidTag($tag)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Cache tag');
|
|
||||||
$item = new CacheItem();
|
|
||||||
$item->tag($tag);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests;
|
|
||||||
|
|
||||||
use Doctrine\Common\Cache\CacheProvider;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
use Symfony\Component\Cache\DoctrineProvider;
|
|
||||||
|
|
||||||
class DoctrineProviderTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testProvider()
|
|
||||||
{
|
|
||||||
$pool = new ArrayAdapter();
|
|
||||||
$cache = new DoctrineProvider($pool);
|
|
||||||
|
|
||||||
$this->assertInstanceOf(CacheProvider::class, $cache);
|
|
||||||
|
|
||||||
$key = '{}()/\@:';
|
|
||||||
|
|
||||||
$this->assertTrue($cache->delete($key));
|
|
||||||
$this->assertFalse($cache->contains($key));
|
|
||||||
|
|
||||||
$this->assertTrue($cache->save($key, 'bar'));
|
|
||||||
$this->assertTrue($cache->contains($key));
|
|
||||||
$this->assertSame('bar', $cache->fetch($key));
|
|
||||||
|
|
||||||
$this->assertTrue($cache->delete($key));
|
|
||||||
$this->assertFalse($cache->fetch($key));
|
|
||||||
$this->assertTrue($cache->save($key, 'bar'));
|
|
||||||
|
|
||||||
$cache->flushAll();
|
|
||||||
$this->assertFalse($cache->fetch($key));
|
|
||||||
$this->assertFalse($cache->contains($key));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Fixtures;
|
|
||||||
|
|
||||||
use Doctrine\Common\Cache\CacheProvider;
|
|
||||||
|
|
||||||
class ArrayCache extends CacheProvider
|
|
||||||
{
|
|
||||||
private $data = [];
|
|
||||||
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->doContains($id) ? $this->data[$id][0] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
if (!isset($this->data[$id])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$expiry = $this->data[$id][1];
|
|
||||||
|
|
||||||
return !$expiry || time() < $expiry || !$this->doDelete($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
$this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
unset($this->data[$id]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$this->data = [];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Fixtures;
|
|
||||||
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
|
||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapter not implementing the {@see \Symfony\Component\Cache\Adapter\AdapterInterface}.
|
|
||||||
*
|
|
||||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
||||||
*/
|
|
||||||
class ExternalAdapter implements CacheItemPoolInterface
|
|
||||||
{
|
|
||||||
private $cache;
|
|
||||||
|
|
||||||
public function __construct($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
$this->cache = new ArrayAdapter($defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getItem($key)
|
|
||||||
{
|
|
||||||
return $this->cache->getItem($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getItems(array $keys = [])
|
|
||||||
{
|
|
||||||
return $this->cache->getItems($keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasItem($key)
|
|
||||||
{
|
|
||||||
return $this->cache->hasItem($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function clear()
|
|
||||||
{
|
|
||||||
return $this->cache->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteItem($key)
|
|
||||||
{
|
|
||||||
return $this->cache->deleteItem($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteItems(array $keys)
|
|
||||||
{
|
|
||||||
return $this->cache->deleteItems($keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(CacheItemInterface $item)
|
|
||||||
{
|
|
||||||
return $this->cache->save($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveDeferred(CacheItemInterface $item)
|
|
||||||
{
|
|
||||||
return $this->cache->saveDeferred($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function commit()
|
|
||||||
{
|
|
||||||
return $this->cache->commit();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\RedisCache;
|
|
||||||
|
|
||||||
abstract class AbstractRedisCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $redis;
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('redis')) {
|
|
||||||
self::markTestSkipped('Extension redis required.');
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
(new \Redis())->connect(getenv('REDIS_HOST'));
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
self::markTestSkipped($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::$redis = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\ApcuCache;
|
|
||||||
|
|
||||||
class ApcuCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
|
|
||||||
$this->markTestSkipped('APCu extension is required.');
|
|
||||||
}
|
|
||||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('Fails transiently on Windows.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ApcuCache(str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class ArrayCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ArrayCache($defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Cache\IntegrationTests\SimpleCacheTest;
|
|
||||||
use Psr\SimpleCache\CacheInterface;
|
|
||||||
use Symfony\Component\Cache\PruneableInterface;
|
|
||||||
|
|
||||||
abstract class CacheTestCase extends SimpleCacheTest
|
|
||||||
{
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) {
|
|
||||||
$this->skippedTests['testPrune'] = 'Not a pruneable cache pool.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function validKeys()
|
|
||||||
{
|
|
||||||
if (\defined('HHVM_VERSION')) {
|
|
||||||
return parent::validKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge(parent::validKeys(), [["a\0b"]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultLifeTime()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = $this->createSimpleCache(2);
|
|
||||||
$cache->clear();
|
|
||||||
|
|
||||||
$cache->set('key.dlt', 'value');
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
$this->assertSame('value', $cache->get('key.dlt'));
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
$this->assertNull($cache->get('key.dlt'));
|
|
||||||
|
|
||||||
$cache->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotUnserializable()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = $this->createSimpleCache();
|
|
||||||
$cache->clear();
|
|
||||||
|
|
||||||
$cache->set('foo', new NotUnserializable());
|
|
||||||
|
|
||||||
$this->assertNull($cache->get('foo'));
|
|
||||||
|
|
||||||
$cache->setMultiple(['foo' => new NotUnserializable()]);
|
|
||||||
|
|
||||||
foreach ($cache->getMultiple(['foo']) as $value) {
|
|
||||||
}
|
|
||||||
$this->assertNull($value);
|
|
||||||
|
|
||||||
$cache->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrune()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!method_exists($this, 'isPruned')) {
|
|
||||||
$this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var PruneableInterface|CacheInterface $cache */
|
|
||||||
$cache = $this->createSimpleCache();
|
|
||||||
$cache->clear();
|
|
||||||
|
|
||||||
$cache->set('foo', 'foo-val', new \DateInterval('PT05S'));
|
|
||||||
$cache->set('bar', 'bar-val', new \DateInterval('PT10S'));
|
|
||||||
$cache->set('baz', 'baz-val', new \DateInterval('PT15S'));
|
|
||||||
$cache->set('qux', 'qux-val', new \DateInterval('PT20S'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
$cache->set('foo', 'foo-val');
|
|
||||||
$cache->set('bar', 'bar-val', new \DateInterval('PT20S'));
|
|
||||||
$cache->set('baz', 'baz-val', new \DateInterval('PT40S'));
|
|
||||||
$cache->set('qux', 'qux-val', new \DateInterval('PT80S'));
|
|
||||||
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
sleep(30);
|
|
||||||
$cache->prune();
|
|
||||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
|
||||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
|
||||||
|
|
||||||
$cache->clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotUnserializable implements \Serializable
|
|
||||||
{
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return serialize(123);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize($ser)
|
|
||||||
{
|
|
||||||
throw new \Exception(__CLASS__);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,113 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
|
||||||
use Psr\SimpleCache\CacheInterface;
|
|
||||||
use Symfony\Component\Cache\PruneableInterface;
|
|
||||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
|
||||||
use Symfony\Component\Cache\Simple\ChainCache;
|
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class ChainCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEmptyCachesException()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('At least one cache must be specified.');
|
|
||||||
new ChainCache([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidCacheException()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('The class "stdClass" does not implement');
|
|
||||||
new ChainCache([new \stdClass()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrune()
|
|
||||||
{
|
|
||||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
|
||||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = new ChainCache([
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
$this->getNonPruneableMock(),
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
]);
|
|
||||||
$this->assertTrue($cache->prune());
|
|
||||||
|
|
||||||
$cache = new ChainCache([
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
$this->getFailingPruneableMock(),
|
|
||||||
$this->getPruneableMock(),
|
|
||||||
]);
|
|
||||||
$this->assertFalse($cache->prune());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(true);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|PruneableCacheInterface
|
|
||||||
*/
|
|
||||||
private function getFailingPruneableMock()
|
|
||||||
{
|
|
||||||
$pruneable = $this
|
|
||||||
->getMockBuilder(PruneableCacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
|
||||||
->expects($this->atLeastOnce())
|
|
||||||
->method('prune')
|
|
||||||
->willReturn(false);
|
|
||||||
|
|
||||||
return $pruneable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MockObject|CacheInterface
|
|
||||||
*/
|
|
||||||
private function getNonPruneableMock()
|
|
||||||
{
|
|
||||||
return $this
|
|
||||||
->getMockBuilder(CacheInterface::class)
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PruneableCacheInterface extends PruneableInterface, CacheInterface
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\DoctrineCache;
|
|
||||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class DoctrineCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize',
|
|
||||||
'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Psr\SimpleCache\CacheInterface;
|
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class FilesystemCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new FilesystemCache('', $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isPruned(CacheInterface $cache, $name)
|
|
||||||
{
|
|
||||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
|
||||||
$getFileMethod->setAccessible(true);
|
|
||||||
|
|
||||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,178 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|
||||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
|
||||||
|
|
||||||
class MemcachedCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
|
||||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $client;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!MemcachedCache::isSupported()) {
|
|
||||||
self::markTestSkipped('Extension memcached >=2.2.0 required.');
|
|
||||||
}
|
|
||||||
self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'));
|
|
||||||
self::$client->get('foo');
|
|
||||||
$code = self::$client->getResultCode();
|
|
||||||
|
|
||||||
if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) {
|
|
||||||
self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client;
|
|
||||||
|
|
||||||
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreatePersistentConnectionShouldNotDupServerList()
|
|
||||||
{
|
|
||||||
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']);
|
|
||||||
$this->assertCount(1, $instance->getServerList());
|
|
||||||
|
|
||||||
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']);
|
|
||||||
$this->assertCount(1, $instance->getServerList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOptions()
|
|
||||||
{
|
|
||||||
$client = MemcachedCache::createConnection([], [
|
|
||||||
'libketama_compatible' => false,
|
|
||||||
'distribution' => 'modula',
|
|
||||||
'compression' => true,
|
|
||||||
'serializer' => 'php',
|
|
||||||
'hash' => 'md5',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER));
|
|
||||||
$this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH));
|
|
||||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
|
||||||
$this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
|
||||||
$this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideBadOptions
|
|
||||||
*/
|
|
||||||
public function testBadOptions($name, $value)
|
|
||||||
{
|
|
||||||
if (\PHP_VERSION_ID < 80000) {
|
|
||||||
$this->expectException('ErrorException');
|
|
||||||
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
|
|
||||||
} else {
|
|
||||||
$this->expectException('Error');
|
|
||||||
$this->expectExceptionMessage('Undefined constant Memcached::');
|
|
||||||
}
|
|
||||||
|
|
||||||
MemcachedCache::createConnection([], [$name => $value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideBadOptions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['foo', 'bar'],
|
|
||||||
['hash', 'zyx'],
|
|
||||||
['serializer', 'zyx'],
|
|
||||||
['distribution', 'zyx'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultOptions()
|
|
||||||
{
|
|
||||||
$this->assertTrue(MemcachedCache::isSupported());
|
|
||||||
|
|
||||||
$client = MemcachedCache::createConnection([]);
|
|
||||||
|
|
||||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
|
||||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL));
|
|
||||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOptionSerializer()
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\CacheException');
|
|
||||||
$this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
|
|
||||||
if (!\Memcached::HAVE_JSON) {
|
|
||||||
$this->markTestSkipped('Memcached::HAVE_JSON required');
|
|
||||||
}
|
|
||||||
|
|
||||||
new MemcachedCache(MemcachedCache::createConnection([], ['serializer' => 'json']));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideServersSetting
|
|
||||||
*/
|
|
||||||
public function testServersSetting($dsn, $host, $port)
|
|
||||||
{
|
|
||||||
$client1 = MemcachedCache::createConnection($dsn);
|
|
||||||
$client2 = MemcachedCache::createConnection([$dsn]);
|
|
||||||
$client3 = MemcachedCache::createConnection([[$host, $port]]);
|
|
||||||
$expect = [
|
|
||||||
'host' => $host,
|
|
||||||
'port' => $port,
|
|
||||||
];
|
|
||||||
|
|
||||||
$f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; };
|
|
||||||
$this->assertSame([$expect], array_map($f, $client1->getServerList()));
|
|
||||||
$this->assertSame([$expect], array_map($f, $client2->getServerList()));
|
|
||||||
$this->assertSame([$expect], array_map($f, $client3->getServerList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideServersSetting()
|
|
||||||
{
|
|
||||||
yield [
|
|
||||||
'memcached://127.0.0.1/50',
|
|
||||||
'127.0.0.1',
|
|
||||||
11211,
|
|
||||||
];
|
|
||||||
yield [
|
|
||||||
'memcached://localhost:11222?weight=25',
|
|
||||||
'localhost',
|
|
||||||
11222,
|
|
||||||
];
|
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
yield [
|
|
||||||
'memcached://user:password@127.0.0.1?weight=50',
|
|
||||||
'127.0.0.1',
|
|
||||||
11211,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
yield [
|
|
||||||
'memcached:///var/run/memcached.sock?weight=25',
|
|
||||||
'/var/run/memcached.sock',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
yield [
|
|
||||||
'memcached:///var/local/run/memcached.socket?weight=25',
|
|
||||||
'/var/local/run/memcached.socket',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
yield [
|
|
||||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
|
||||||
'/var/local/run/memcached.socket',
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|
||||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
|
||||||
|
|
||||||
class MemcachedCacheTextModeTest extends MemcachedCacheTest
|
|
||||||
{
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]);
|
|
||||||
|
|
||||||
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Cache\Simple\NullCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class NullCacheTest extends TestCase
|
|
||||||
{
|
|
||||||
public function createCachePool()
|
|
||||||
{
|
|
||||||
return new NullCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetItem()
|
|
||||||
{
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$this->assertNull($cache->get('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHas()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->createCachePool()->has('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMultiple()
|
|
||||||
{
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$keys = ['foo', 'bar', 'baz', 'biz'];
|
|
||||||
|
|
||||||
$default = new \stdClass();
|
|
||||||
$items = $cache->getMultiple($keys, $default);
|
|
||||||
$count = 0;
|
|
||||||
|
|
||||||
foreach ($items as $key => $item) {
|
|
||||||
$this->assertContains($key, $keys, 'Cache key can not change.');
|
|
||||||
$this->assertSame($default, $item);
|
|
||||||
|
|
||||||
// Remove $key for $keys
|
|
||||||
foreach ($keys as $k => $v) {
|
|
||||||
if ($v === $key) {
|
|
||||||
unset($keys[$k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++$count;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(4, $count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testClear()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->clear());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDelete()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->delete('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteMultiple()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->createCachePool()->deleteMultiple(['key', 'foo', 'bar']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSet()
|
|
||||||
{
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$this->assertFalse($cache->set('key', 'val'));
|
|
||||||
$this->assertNull($cache->get('key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetMultiple()
|
|
||||||
{
|
|
||||||
$cache = $this->createCachePool();
|
|
||||||
|
|
||||||
$this->assertFalse($cache->setMultiple(['key' => 'val']));
|
|
||||||
$this->assertNull($cache->get('key'));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\PdoCache;
|
|
||||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PdoCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
use PdoPruneableTrait;
|
|
||||||
|
|
||||||
protected static $dbFile;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('pdo_sqlite')) {
|
|
||||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
|
||||||
|
|
||||||
$pool = new PdoCache('sqlite:'.self::$dbFile);
|
|
||||||
$pool->createTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\DriverManager;
|
|
||||||
use Symfony\Component\Cache\Simple\PdoCache;
|
|
||||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PdoDbalCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
use PdoPruneableTrait;
|
|
||||||
|
|
||||||
protected static $dbFile;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!\extension_loaded('pdo_sqlite')) {
|
|
||||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
|
||||||
|
|
||||||
$pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
|
|
||||||
$pool->createTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\NullCache;
|
|
||||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
|
||||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpArrayCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes',
|
|
||||||
|
|
||||||
'testDelete' => 'PhpArrayCache does no writes',
|
|
||||||
'testDeleteMultiple' => 'PhpArrayCache does no writes',
|
|
||||||
'testDeleteMultipleGenerator' => 'PhpArrayCache does no writes',
|
|
||||||
|
|
||||||
'testSetTtl' => 'PhpArrayCache does no expiration',
|
|
||||||
'testSetMultipleTtl' => 'PhpArrayCache does no expiration',
|
|
||||||
'testSetExpiredTtl' => 'PhpArrayCache does no expiration',
|
|
||||||
'testSetMultipleExpiredTtl' => 'PhpArrayCache does no expiration',
|
|
||||||
|
|
||||||
'testGetInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testDeleteInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetInvalidTtl' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation',
|
|
||||||
'testHasInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetValidData' => 'PhpArrayCache does no validation',
|
|
||||||
|
|
||||||
'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.',
|
|
||||||
'testPrune' => 'PhpArrayCache just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $file;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->createSimpleCache()->clear();
|
|
||||||
|
|
||||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createSimpleCache()
|
|
||||||
{
|
|
||||||
return new PhpArrayCacheWrapper(self::$file, new NullCache());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStore()
|
|
||||||
{
|
|
||||||
$arrayWithRefs = [];
|
|
||||||
$arrayWithRefs[0] = 123;
|
|
||||||
$arrayWithRefs[1] = &$arrayWithRefs[0];
|
|
||||||
|
|
||||||
$object = (object) [
|
|
||||||
'foo' => 'bar',
|
|
||||||
'foo2' => 'bar2',
|
|
||||||
];
|
|
||||||
|
|
||||||
$expected = [
|
|
||||||
'null' => null,
|
|
||||||
'serializedString' => serialize($object),
|
|
||||||
'arrayWithRefs' => $arrayWithRefs,
|
|
||||||
'object' => $object,
|
|
||||||
'arrayWithObject' => ['bar' => $object],
|
|
||||||
];
|
|
||||||
|
|
||||||
$cache = new PhpArrayCache(self::$file, new NullCache());
|
|
||||||
$cache->warmUp($expected);
|
|
||||||
|
|
||||||
foreach ($expected as $key => $value) {
|
|
||||||
$this->assertSame(serialize($value), serialize($cache->get($key)), 'Warm up should create a PHP file that OPCache can load in memory');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStoredFile()
|
|
||||||
{
|
|
||||||
$expected = [
|
|
||||||
'integer' => 42,
|
|
||||||
'float' => 42.42,
|
|
||||||
'boolean' => true,
|
|
||||||
'array_simple' => ['foo', 'bar'],
|
|
||||||
'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'],
|
|
||||||
];
|
|
||||||
|
|
||||||
$cache = new PhpArrayCache(self::$file, new NullCache());
|
|
||||||
$cache->warmUp($expected);
|
|
||||||
|
|
||||||
$values = eval(substr(file_get_contents(self::$file), 6));
|
|
||||||
|
|
||||||
$this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PhpArrayCacheWrapper extends PhpArrayCache
|
|
||||||
{
|
|
||||||
public function set($key, $value, $ttl = null)
|
|
||||||
{
|
|
||||||
\call_user_func(\Closure::bind(function () use ($key, $value) {
|
|
||||||
$this->values[$key] = $value;
|
|
||||||
$this->warmUp($this->values);
|
|
||||||
$this->values = eval(substr(file_get_contents($this->file), 6));
|
|
||||||
}, $this, PhpArrayCache::class));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setMultiple($values, $ttl = null)
|
|
||||||
{
|
|
||||||
if (!\is_array($values) && !$values instanceof \Traversable) {
|
|
||||||
return parent::setMultiple($values, $ttl);
|
|
||||||
}
|
|
||||||
\call_user_func(\Closure::bind(function () use ($values) {
|
|
||||||
foreach ($values as $key => $value) {
|
|
||||||
$this->values[$key] = $value;
|
|
||||||
}
|
|
||||||
$this->warmUp($this->values);
|
|
||||||
$this->values = eval(substr(file_get_contents($this->file), 6));
|
|
||||||
}, $this, PhpArrayCache::class));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
|
||||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
|
||||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpArrayCacheWithFallbackTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testGetInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testDeleteInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
//'testSetValidData' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetInvalidTtl' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation',
|
|
||||||
'testHasInvalidKeys' => 'PhpArrayCache does no validation',
|
|
||||||
'testPrune' => 'PhpArrayCache just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $file;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->createSimpleCache()->clear();
|
|
||||||
|
|
||||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
|
||||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Psr\SimpleCache\CacheInterface;
|
|
||||||
use Symfony\Component\Cache\Simple\PhpFilesCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class PhpFilesCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createSimpleCache()
|
|
||||||
{
|
|
||||||
if (!PhpFilesCache::isSupported()) {
|
|
||||||
$this->markTestSkipped('OPcache extension is not enabled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PhpFilesCache('sf-cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isPruned(CacheInterface $cache, $name)
|
|
||||||
{
|
|
||||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
|
||||||
$getFileMethod->setAccessible(true);
|
|
||||||
|
|
||||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
||||||
use Symfony\Component\Cache\Simple\Psr6Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class Psr6CacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testPrune' => 'Psr6Cache just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new Psr6Cache(new FilesystemAdapter('', $defaultLifetime));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
class RedisArrayCacheTest extends AbstractRedisCacheTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setupBeforeClass();
|
|
||||||
if (!class_exists('RedisArray')) {
|
|
||||||
self::markTestSkipped('The RedisArray class is required.');
|
|
||||||
}
|
|
||||||
self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\RedisCache;
|
|
||||||
|
|
||||||
class RedisCacheTest extends AbstractRedisCacheTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
parent::setupBeforeClass();
|
|
||||||
self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateConnection()
|
|
||||||
{
|
|
||||||
$redisHost = getenv('REDIS_HOST');
|
|
||||||
|
|
||||||
$redis = RedisCache::createConnection('redis://'.$redisHost);
|
|
||||||
$this->assertInstanceOf(\Redis::class, $redis);
|
|
||||||
$this->assertTrue($redis->isConnected());
|
|
||||||
$this->assertSame(0, $redis->getDbNum());
|
|
||||||
|
|
||||||
$redis = RedisCache::createConnection('redis://'.$redisHost.'/2');
|
|
||||||
$this->assertSame(2, $redis->getDbNum());
|
|
||||||
|
|
||||||
$redis = RedisCache::createConnection('redis://'.$redisHost, ['timeout' => 3]);
|
|
||||||
$this->assertEquals(3, $redis->getTimeout());
|
|
||||||
|
|
||||||
$redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4');
|
|
||||||
$this->assertEquals(4, $redis->getTimeout());
|
|
||||||
|
|
||||||
$redis = RedisCache::createConnection('redis://'.$redisHost, ['read_timeout' => 5]);
|
|
||||||
$this->assertEquals(5, $redis->getReadTimeout());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideFailedCreateConnection
|
|
||||||
*/
|
|
||||||
public function testFailedCreateConnection($dsn)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Redis connection ');
|
|
||||||
RedisCache::createConnection($dsn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideFailedCreateConnection()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['redis://localhost:1234'],
|
|
||||||
['redis://foo@localhost'],
|
|
||||||
['redis://localhost/123'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideInvalidCreateConnection
|
|
||||||
*/
|
|
||||||
public function testInvalidCreateConnection($dsn)
|
|
||||||
{
|
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
|
||||||
$this->expectExceptionMessage('Invalid Redis DSN');
|
|
||||||
RedisCache::createConnection($dsn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideInvalidCreateConnection()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['foo://localhost'],
|
|
||||||
['redis://'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
class RedisClusterCacheTest extends AbstractRedisCacheTest
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (!class_exists('RedisCluster')) {
|
|
||||||
self::markTestSkipped('The RedisCluster class is required.');
|
|
||||||
}
|
|
||||||
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
|
|
||||||
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$redis = new \RedisCluster(null, explode(' ', $hosts));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,171 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Simple;
|
|
||||||
|
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
|
||||||
use Symfony\Component\Cache\Simple\TraceableCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group time-sensitive
|
|
||||||
*/
|
|
||||||
class TraceableCacheTest extends CacheTestCase
|
|
||||||
{
|
|
||||||
protected $skippedTests = [
|
|
||||||
'testPrune' => 'TraceableCache just proxies',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function createSimpleCache($defaultLifetime = 0)
|
|
||||||
{
|
|
||||||
return new TraceableCache(new FilesystemCache('', $defaultLifetime));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->get('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('get', $call->name);
|
|
||||||
$this->assertSame(['k' => false], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(1, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetHitTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->set('k', 'foo');
|
|
||||||
$pool->get('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(2, $calls);
|
|
||||||
|
|
||||||
$call = $calls[1];
|
|
||||||
$this->assertSame(1, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMultipleMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->set('k1', 123);
|
|
||||||
$values = $pool->getMultiple(['k0', 'k1']);
|
|
||||||
foreach ($values as $value) {
|
|
||||||
}
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(2, $calls);
|
|
||||||
|
|
||||||
$call = $calls[1];
|
|
||||||
$this->assertSame('getMultiple', $call->name);
|
|
||||||
$this->assertSame(['k1' => true, 'k0' => false], $call->result);
|
|
||||||
$this->assertSame(1, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasMissTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->has('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('has', $call->name);
|
|
||||||
$this->assertSame(['k' => false], $call->result);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasHitTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->set('k', 'foo');
|
|
||||||
$pool->has('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(2, $calls);
|
|
||||||
|
|
||||||
$call = $calls[1];
|
|
||||||
$this->assertSame('has', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->delete('k');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('delete', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteMultipleTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$arg = ['k0', 'k1'];
|
|
||||||
$pool->deleteMultiple($arg);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('deleteMultiple', $call->name);
|
|
||||||
$this->assertSame(['keys' => $arg, 'result' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTraceSetTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->set('k', 'foo');
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('set', $call->name);
|
|
||||||
$this->assertSame(['k' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetMultipleTrace()
|
|
||||||
{
|
|
||||||
$pool = $this->createSimpleCache();
|
|
||||||
$pool->setMultiple(['k' => 'foo']);
|
|
||||||
$calls = $pool->getCalls();
|
|
||||||
$this->assertCount(1, $calls);
|
|
||||||
|
|
||||||
$call = $calls[0];
|
|
||||||
$this->assertSame('setMultiple', $call->name);
|
|
||||||
$this->assertSame(['keys' => ['k'], 'result' => true], $call->result);
|
|
||||||
$this->assertSame(0, $call->hits);
|
|
||||||
$this->assertSame(0, $call->misses);
|
|
||||||
$this->assertNotEmpty($call->start);
|
|
||||||
$this->assertNotEmpty($call->end);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Traits;
|
|
||||||
|
|
||||||
trait PdoPruneableTrait
|
|
||||||
{
|
|
||||||
protected function isPruned($cache, $name)
|
|
||||||
{
|
|
||||||
$o = new \ReflectionObject($cache);
|
|
||||||
|
|
||||||
if (!$o->hasMethod('getConnection')) {
|
|
||||||
self::fail('Cache does not have "getConnection()" method.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$getPdoConn = $o->getMethod('getConnection');
|
|
||||||
$getPdoConn->setAccessible(true);
|
|
||||||
|
|
||||||
/** @var \Doctrine\DBAL\Statement|\PDOStatement $select */
|
|
||||||
$select = $getPdoConn->invoke($cache)->prepare('SELECT 1 FROM cache_items WHERE item_id LIKE :id');
|
|
||||||
$select->bindValue(':id', sprintf('%%%s', $name));
|
|
||||||
$result = $select->execute();
|
|
||||||
|
|
||||||
return 1 !== (int) (\is_object($result) ? $result->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
|
||||||
backupGlobals="false"
|
|
||||||
colors="true"
|
|
||||||
bootstrap="vendor/autoload.php"
|
|
||||||
failOnRisky="true"
|
|
||||||
failOnWarning="true"
|
|
||||||
>
|
|
||||||
<php>
|
|
||||||
<ini name="error_reporting" value="-1" />
|
|
||||||
<env name="REDIS_HOST" value="localhost" />
|
|
||||||
<env name="MEMCACHED_HOST" value="localhost" />
|
|
||||||
</php>
|
|
||||||
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Symfony Cache Component Test Suite">
|
|
||||||
<directory>./Tests/</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
|
|
||||||
<filter>
|
|
||||||
<whitelist>
|
|
||||||
<directory>./</directory>
|
|
||||||
<exclude>
|
|
||||||
<directory>./Tests</directory>
|
|
||||||
<directory>./vendor</directory>
|
|
||||||
</exclude>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
|
|
||||||
<listeners>
|
|
||||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
|
|
||||||
<arguments>
|
|
||||||
<array>
|
|
||||||
<element key="time-sensitive">
|
|
||||||
<array>
|
|
||||||
<element key="0"><string>Cache\IntegrationTests</string></element>
|
|
||||||
<element key="1"><string>Doctrine\Common\Cache</string></element>
|
|
||||||
<element key="2"><string>Symfony\Component\Cache</string></element>
|
|
||||||
<element key="3"><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
|
|
||||||
<element key="4"><string>Symfony\Component\Cache\Traits</string></element>
|
|
||||||
</array>
|
|
||||||
</element>
|
|
||||||
</array>
|
|
||||||
</arguments>
|
|
||||||
</listener>
|
|
||||||
</listeners>
|
|
||||||
</phpunit>
|
|
|
@ -1,106 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Polyfill\Apcu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apcu for Zend Server Data Cache.
|
|
||||||
*
|
|
||||||
* @author Kate Gray <opensource@codebykate.com>
|
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Apcu
|
|
||||||
{
|
|
||||||
public static function apcu_add($key, $var = null, $ttl = 0)
|
|
||||||
{
|
|
||||||
if (!\is_array($key)) {
|
|
||||||
return apc_add($key, $var, $ttl);
|
|
||||||
}
|
|
||||||
|
|
||||||
$errors = [];
|
|
||||||
foreach ($key as $k => $v) {
|
|
||||||
if (!apc_add($k, $v, $ttl)) {
|
|
||||||
$errors[$k] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function apcu_store($key, $var = null, $ttl = 0)
|
|
||||||
{
|
|
||||||
if (!\is_array($key)) {
|
|
||||||
return apc_store($key, $var, $ttl);
|
|
||||||
}
|
|
||||||
|
|
||||||
$errors = [];
|
|
||||||
foreach ($key as $k => $v) {
|
|
||||||
if (!apc_store($k, $v, $ttl)) {
|
|
||||||
$errors[$k] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function apcu_exists($keys)
|
|
||||||
{
|
|
||||||
if (!\is_array($keys)) {
|
|
||||||
return apc_exists($keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
$existing = [];
|
|
||||||
foreach ($keys as $k) {
|
|
||||||
if (apc_exists($k)) {
|
|
||||||
$existing[$k] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $existing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function apcu_fetch($key, &$success = null)
|
|
||||||
{
|
|
||||||
if (!\is_array($key)) {
|
|
||||||
return apc_fetch($key, $success);
|
|
||||||
}
|
|
||||||
|
|
||||||
$succeeded = true;
|
|
||||||
$values = [];
|
|
||||||
foreach ($key as $k) {
|
|
||||||
$v = apc_fetch($k, $success);
|
|
||||||
if ($success) {
|
|
||||||
$values[$k] = $v;
|
|
||||||
} else {
|
|
||||||
$succeeded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$success = $succeeded;
|
|
||||||
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function apcu_delete($key)
|
|
||||||
{
|
|
||||||
if (!\is_array($key)) {
|
|
||||||
return apc_delete($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$success = true;
|
|
||||||
foreach ($key as $k) {
|
|
||||||
$success = apc_delete($k) && $success;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2015-present Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
|
@ -1,12 +0,0 @@
|
||||||
Symfony Polyfill / APCu
|
|
||||||
========================
|
|
||||||
|
|
||||||
This component provides `apcu_*` functions and the `APCuIterator` class to users of the legacy APC extension.
|
|
||||||
|
|
||||||
More information can be found in the
|
|
||||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
This library is released under the [MIT license](LICENSE).
|
|
|
@ -1,83 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Apcu as p;
|
|
||||||
|
|
||||||
if (!extension_loaded('apc') && !extension_loaded('apcu')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 80000) {
|
|
||||||
return require __DIR__.'/bootstrap80.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_loaded('Zend Data Cache')) {
|
|
||||||
if (!function_exists('apcu_add')) {
|
|
||||||
function apcu_add($key, $value = null, $ttl = 0) { return p\Apcu::apcu_add($key, $value, $ttl); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_delete')) {
|
|
||||||
function apcu_delete($key) { return p\Apcu::apcu_delete($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_exists')) {
|
|
||||||
function apcu_exists($key) { return p\Apcu::apcu_exists($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_fetch')) {
|
|
||||||
function apcu_fetch($key, &$success = null) { return p\Apcu::apcu_fetch($key, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_store')) {
|
|
||||||
function apcu_store($key, $value = null, $ttl = 0) { return p\Apcu::apcu_store($key, $value, $ttl); }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!function_exists('apcu_add')) {
|
|
||||||
function apcu_add($key, $value = null, $ttl = 0) { return apc_add($key, $value, $ttl); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_delete')) {
|
|
||||||
function apcu_delete($key) { return apc_delete($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_exists')) {
|
|
||||||
function apcu_exists($key) { return apc_exists($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_fetch')) {
|
|
||||||
function apcu_fetch($key, &$success = null) { return apc_fetch($key, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_store')) {
|
|
||||||
function apcu_store($key, $value = null, $ttl = 0) { return apc_store($key, $value, $ttl); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('apcu_cache_info')) {
|
|
||||||
function apcu_cache_info($limited = false) { return apc_cache_info('user', $limited); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_cas')) {
|
|
||||||
function apcu_cas($key, $old, $new) { return apc_cas($key, $old, $new); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_clear_cache')) {
|
|
||||||
function apcu_clear_cache() { return apc_clear_cache('user'); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_dec')) {
|
|
||||||
function apcu_dec($key, $step = 1, &$success = false) { return apc_dec($key, $step, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_inc')) {
|
|
||||||
function apcu_inc($key, $step = 1, &$success = false) { return apc_inc($key, $step, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_sma_info')) {
|
|
||||||
function apcu_sma_info($limited = false) { return apc_sma_info($limited); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!class_exists('APCuIterator', false) && class_exists('APCIterator', false)) {
|
|
||||||
class APCuIterator extends APCIterator
|
|
||||||
{
|
|
||||||
public function __construct($search = null, $format = \APC_ITER_ALL, $chunk_size = 100, $list = \APC_LIST_ACTIVE)
|
|
||||||
{
|
|
||||||
parent::__construct('user', $search, $format, $chunk_size, $list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Apcu as p;
|
|
||||||
|
|
||||||
if (extension_loaded('Zend Data Cache')) {
|
|
||||||
if (!function_exists('apcu_add')) {
|
|
||||||
function apcu_add($key, mixed $value, ?int $ttl = 0): array|bool { return p\Apcu::apcu_add($key, $value, (int) $ttl); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_delete')) {
|
|
||||||
function apcu_delete($key): array|bool { return p\Apcu::apcu_delete($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_exists')) {
|
|
||||||
function apcu_exists($key): array|bool { return p\Apcu::apcu_exists($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_fetch')) {
|
|
||||||
function apcu_fetch($key, &$success = null): mixed { return p\Apcu::apcu_fetch($key, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_store')) {
|
|
||||||
function apcu_store($key, mixed $value, ?int $ttl = 0): array|bool { return p\Apcu::apcu_store($key, $value, (int) $ttl); }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!function_exists('apcu_add')) {
|
|
||||||
function apcu_add($key, mixed $value, ?int $ttl = 0): array|bool { return apc_add($key, $value, (int) $ttl); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_delete')) {
|
|
||||||
function apcu_delete($key): array|bool { return apc_delete($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_exists')) {
|
|
||||||
function apcu_exists($key): array|bool { return apc_exists($key); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_fetch')) {
|
|
||||||
function apcu_fetch($key, &$success = null) { return apc_fetch($key, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_store')) {
|
|
||||||
function apcu_store($key, mixed $value, ?int $ttl = 0): array|bool { return apc_store($key, $value, (int) $ttl); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('apcu_cache_info')) {
|
|
||||||
function apcu_cache_info($limited = false) { return apc_cache_info('user', $limited); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_cas')) {
|
|
||||||
function apcu_cas($key, $old, $new) { return apc_cas($key, $old, $new); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_clear_cache')) {
|
|
||||||
function apcu_clear_cache() { return apc_clear_cache('user'); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_dec')) {
|
|
||||||
function apcu_dec($key, $step = 1, &$success = false) { return apc_dec($key, $step, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_inc')) {
|
|
||||||
function apcu_inc($key, $step = 1, &$success = false) { return apc_inc($key, $step, $success); }
|
|
||||||
}
|
|
||||||
if (!function_exists('apcu_sma_info')) {
|
|
||||||
function apcu_sma_info($limited = false) { return apc_sma_info($limited); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!class_exists('APCuIterator', false) && class_exists('APCIterator', false)) {
|
|
||||||
class APCuIterator extends APCIterator
|
|
||||||
{
|
|
||||||
public function __construct($search = null, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE)
|
|
||||||
{
|
|
||||||
parent::__construct('user', $search, $format, $chunk_size, $list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-apcu",
|
|
||||||
"type": "library",
|
|
||||||
"description": "Symfony polyfill backporting apcu_* functions to lower PHP versions",
|
|
||||||
"keywords": ["polyfill", "shim", "compatibility", "portable", "apcu"],
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": { "Symfony\\Polyfill\\Apcu\\": "" },
|
|
||||||
"files": [ "bootstrap.php" ]
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.28-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -461,7 +461,7 @@ function blockbot_is_social_media(array $parts): bool
|
||||||
|
|
||||||
$agents = [
|
$agents = [
|
||||||
'facebookexternalhit', 'twitterbot', 'mastodon', 'facebookexternalua',
|
'facebookexternalhit', 'twitterbot', 'mastodon', 'facebookexternalua',
|
||||||
'friendica', 'diasporafederation', 'buzzrelay', 'activityrelay',
|
'friendica', 'diasporafederation', 'buzzrelay', 'activityrelay', 'drupal',
|
||||||
'aoderelay', 'ap-relay', 'peertube', 'misskey', 'pleroma', 'foundkey', 'akkoma',
|
'aoderelay', 'ap-relay', 'peertube', 'misskey', 'pleroma', 'foundkey', 'akkoma',
|
||||||
'lemmy', 'calckey', 'mobilizon', 'zot', 'camo-rs', 'gotosocial', 'pixelfed',
|
'lemmy', 'calckey', 'mobilizon', 'zot', 'camo-rs', 'gotosocial', 'pixelfed',
|
||||||
'pixelfedbot', 'app.wafrn.net', 'go-camo', 'http://a.gup.pe', 'iceshrimp',
|
'pixelfedbot', 'app.wafrn.net', 'go-camo', 'http://a.gup.pe', 'iceshrimp',
|
||||||
|
|
|
@ -587,13 +587,13 @@ function bluesky_hook_fork(array &$b)
|
||||||
|
|
||||||
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
|
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
|
||||||
// Don't post if it isn't a reply to a bluesky post
|
// Don't post if it isn't a reply to a bluesky post
|
||||||
if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
|
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
|
||||||
Logger::notice('No bluesky parent found', ['item' => $post['id']]);
|
Logger::notice('No bluesky parent found', ['item' => $post['id']]);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} elseif (!strstr($post['postopts'] ?? '', 'bluesky') || ($post['parent'] != $post['id']) || $post['private']) {
|
} elseif (!strstr($post['postopts'] ?? '', 'bluesky') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
||||||
DI::logger()->info('Activities are never exported when we don\'t import the bluesky timeline', ['uid' => $post['uid']]);
|
DI::logger()->info('Post will not be exported', ['uid' => $post['uid'], 'postopts' => $post['postopts'], 'gravity' => $post['gravity'], 'private' => $post['private']]);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -601,15 +601,11 @@ function bluesky_hook_fork(array &$b)
|
||||||
|
|
||||||
function bluesky_post_local(array &$b)
|
function bluesky_post_local(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +663,7 @@ function bluesky_send(array &$b)
|
||||||
bluesky_create_activity($b, $parent);
|
bluesky_create_activity($b, $parent);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} elseif ($b['private'] || !strstr($b['postopts'], 'bluesky')) {
|
} elseif (($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'bluesky')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1036,7 @@ function bluesky_complete_post(stdClass $post, int $uid, int $post_reason, int $
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($complete) {
|
if ($complete) {
|
||||||
$uri = bluesky_fetch_missing_post($post->uri, $uid, $uid, $post_reason, $causer, 0, $last_poll, '', true);
|
$uri = bluesky_fetch_missing_post(bluesky_get_uri($post), $uid, $uid, $post_reason, $causer, 0, $last_poll, '', true);
|
||||||
$uri_id = bluesky_fetch_uri_id($uri, $uid);
|
$uri_id = bluesky_fetch_uri_id($uri, $uid);
|
||||||
} else {
|
} else {
|
||||||
$uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll);
|
$uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll);
|
||||||
|
@ -1064,7 +1060,6 @@ function bluesky_process_reason(stdClass $reason, string $uri, int $uid)
|
||||||
'wall' => false,
|
'wall' => false,
|
||||||
'uri' => $reason->by->did . '/app.bsky.feed.repost/' . $reason->indexedAt,
|
'uri' => $reason->by->did . '/app.bsky.feed.repost/' . $reason->indexedAt,
|
||||||
'private' => Item::UNLISTED,
|
'private' => Item::UNLISTED,
|
||||||
'verb' => Activity::POST,
|
|
||||||
'contact-id' => $contact['id'],
|
'contact-id' => $contact['id'],
|
||||||
'author-name' => $contact['name'],
|
'author-name' => $contact['name'],
|
||||||
'author-link' => $contact['url'],
|
'author-link' => $contact['url'],
|
||||||
|
@ -1481,7 +1476,20 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
|
||||||
|
|
||||||
case 'app.bsky.embed.record#view':
|
case 'app.bsky.embed.record#view':
|
||||||
$original_uri = $uri = bluesky_get_uri($embed->record);
|
$original_uri = $uri = bluesky_get_uri($embed->record);
|
||||||
$uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
|
$type = '$type';
|
||||||
|
if (!empty($embed->record->record->$type)) {
|
||||||
|
$embed_type = $embed->record->record->$type;
|
||||||
|
if ($embed_type == 'app.bsky.graph.starterpack') {
|
||||||
|
bluesky_add_starterpack($item, $embed->record);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$fetched_uri = bluesky_fetch_post($uri, $item['uid']);
|
||||||
|
if (!$fetched_uri) {
|
||||||
|
$uri = bluesky_fetch_missing_post($uri, 0, $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
|
||||||
|
} else {
|
||||||
|
$uri = $fetched_uri;
|
||||||
|
}
|
||||||
if ($uri) {
|
if ($uri) {
|
||||||
$shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]);
|
$shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]);
|
||||||
$uri_id = $shared['uri-id'] ?? 0;
|
$uri_id = $shared['uri-id'] ?? 0;
|
||||||
|
@ -1515,6 +1523,30 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bluesky_add_starterpack(array $item, stdClass $record)
|
||||||
|
{
|
||||||
|
Logger::debug('Received starterpack', ['uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'uri' => $record->uri]);
|
||||||
|
if (!preg_match('#^at://(.+)/app.bsky.graph.starterpack/(.+)#', $record->uri, $matches)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$media = [
|
||||||
|
'uri-id' => $item['uri-id'],
|
||||||
|
'type' => Post\Media::HTML,
|
||||||
|
'url' => 'https://bsky.app/starter-pack/' . $matches[1] . '/' . $matches[2],
|
||||||
|
'name' => $record->record->name,
|
||||||
|
'description' => $record->record->description,
|
||||||
|
];
|
||||||
|
|
||||||
|
Post\Media::insert($media);
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'name' => $record->record->name,
|
||||||
|
'description' => $record->record->description,
|
||||||
|
];
|
||||||
|
Post\Media::update($fields, ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||||
|
}
|
||||||
|
|
||||||
function bluesky_get_uri(stdClass $post): string
|
function bluesky_get_uri(stdClass $post): string
|
||||||
{
|
{
|
||||||
if (empty($post->cid)) {
|
if (empty($post->cid)) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
|
||||||
function diaspora_install()
|
function diaspora_install()
|
||||||
|
@ -120,15 +121,15 @@ function diaspora_settings(array &$data)
|
||||||
function diaspora_settings_post(array &$b)
|
function diaspora_settings_post(array &$b)
|
||||||
{
|
{
|
||||||
if (!empty($_POST['diaspora-submit'])) {
|
if (!empty($_POST['diaspora-submit'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post' , intval($_POST['enabled']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'post', intval($_POST['enabled']));
|
||||||
if (intval($_POST['enabled'])) {
|
if (intval($_POST['enabled'])) {
|
||||||
if (isset($_POST['handle'])) {
|
if (isset($_POST['handle'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'handle' , trim($_POST['handle']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'handle', trim($_POST['handle']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'password' , trim($_POST['password']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'password', trim($_POST['password']));
|
||||||
}
|
}
|
||||||
if (!empty($_POST['aspect'])) {
|
if (!empty($_POST['aspect'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'aspect' , trim($_POST['aspect']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'aspect', trim($_POST['aspect']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post_by_default', intval($_POST['post_by_default']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default', intval($_POST['post_by_default']));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'diaspora', 'password');
|
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'diaspora', 'password');
|
||||||
|
@ -144,8 +145,10 @@ function diaspora_hook_fork(array &$b)
|
||||||
|
|
||||||
$post = $b['data'];
|
$post = $b['data'];
|
||||||
|
|
||||||
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
|
if (
|
||||||
!strstr($post['postopts'] ?? '', 'diaspora') || ($post['parent'] != $post['id'])) {
|
$post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
|
||||||
|
!strstr($post['postopts'] ?? '', 'diaspora') || ($post['gravity'] != Item::GRAVITY_PARENT)
|
||||||
|
) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -153,23 +156,19 @@ function diaspora_hook_fork(array &$b)
|
||||||
|
|
||||||
function diaspora_post_local(array &$b)
|
function diaspora_post_local(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$diaspora_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post'));
|
$diaspora_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post'));
|
||||||
|
|
||||||
$diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0);
|
$diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default'))) {
|
||||||
$diaspora_enable = 1;
|
$diaspora_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,11 +189,11 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
Logger::notice('diaspora_send: invoked');
|
Logger::notice('diaspora_send: invoked');
|
||||||
|
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($b['postopts'],'diaspora')) {
|
if (!strstr($b['postopts'], 'diaspora')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,9 +213,9 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
Logger::info('diaspora_send: prepare posting');
|
Logger::info('diaspora_send: prepare posting');
|
||||||
|
|
||||||
$handle = DI::pConfig()->get($b['uid'],'diaspora','handle');
|
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
|
||||||
$password = DI::pConfig()->get($b['uid'],'diaspora','password');
|
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
|
||||||
$aspect = DI::pConfig()->get($b['uid'],'diaspora','aspect');
|
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
|
||||||
|
|
||||||
if ($handle && $password) {
|
if ($handle && $password) {
|
||||||
Logger::info('diaspora_send: all values seem to be okay');
|
Logger::info('diaspora_send: all values seem to be okay');
|
||||||
|
@ -230,7 +229,7 @@ function diaspora_send(array &$b)
|
||||||
// Removal of tags and mentions
|
// Removal of tags and mentions
|
||||||
// #-tags
|
// #-tags
|
||||||
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
||||||
// @-mentions
|
// @-mentions
|
||||||
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
||||||
|
|
||||||
// remove multiple newlines
|
// remove multiple newlines
|
||||||
|
@ -244,7 +243,7 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
// Adding the title
|
// Adding the title
|
||||||
if (strlen($title)) {
|
if (strlen($title)) {
|
||||||
$body = "## ".html_entity_decode($title)."\n\n".$body;
|
$body = "## " . html_entity_decode($title) . "\n\n" . $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once "addon/diaspora/diasphp.php";
|
require_once "addon/diaspora/diasphp.php";
|
||||||
|
@ -252,9 +251,9 @@ function diaspora_send(array &$b)
|
||||||
try {
|
try {
|
||||||
Logger::info('diaspora_send: prepare');
|
Logger::info('diaspora_send: prepare');
|
||||||
$conn = new Diaspora_Connection($handle, $password);
|
$conn = new Diaspora_Connection($handle, $password);
|
||||||
Logger::info('diaspora_send: try to log in '.$handle);
|
Logger::info('diaspora_send: try to log in ' . $handle);
|
||||||
$conn->logIn();
|
$conn->logIn();
|
||||||
Logger::info('diaspora_send: try to send '.$body);
|
Logger::info('diaspora_send: try to send ' . $body);
|
||||||
|
|
||||||
$conn->provider = $hostname;
|
$conn->provider = $hostname;
|
||||||
$conn->postStatusMessage($body, $aspect);
|
$conn->postStatusMessage($body, $aspect);
|
||||||
|
@ -263,7 +262,7 @@ function diaspora_send(array &$b)
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
||||||
|
|
||||||
Logger::info('diaspora_send: requeueing '.$b['uid']);
|
Logger::info('diaspora_send: requeueing ' . $b['uid']);
|
||||||
|
|
||||||
Worker::defer();
|
Worker::defer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -88,24 +89,20 @@ function dwpost_settings_post(array &$b)
|
||||||
|
|
||||||
function dwpost_post_local(array &$b)
|
function dwpost_post_local(array &$b)
|
||||||
{
|
{
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post'));
|
$dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post'));
|
||||||
|
|
||||||
$dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0);
|
$dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default'))) {
|
||||||
$dw_enable = 1;
|
$dw_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +119,7 @@ function dwpost_post_local(array &$b)
|
||||||
|
|
||||||
function dwpost_send(array &$b)
|
function dwpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +142,8 @@ function dwpost_send(array &$b)
|
||||||
$user = User::getById($b['uid']);
|
$user = User::getById($b['uid']);
|
||||||
$tz = $user['timezone'] ?: 'UTC';
|
$tz = $user['timezone'] ?: 'UTC';
|
||||||
|
|
||||||
$dw_username = DI::pConfig()->get($b['uid'],'dwpost','dw_username');
|
$dw_username = DI::pConfig()->get($b['uid'], 'dwpost', 'dw_username');
|
||||||
$dw_password = DI::pConfig()->get($b['uid'],'dwpost','dw_password');
|
$dw_password = DI::pConfig()->get($b['uid'], 'dwpost', 'dw_password');
|
||||||
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
|
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
|
||||||
|
|
||||||
if ($dw_username && $dw_password && $dw_blog) {
|
if ($dw_username && $dw_password && $dw_blog) {
|
||||||
|
@ -156,11 +153,11 @@ function dwpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date,0,4));
|
$year = intval(substr($date, 0, 4));
|
||||||
$mon = intval(substr($date,5,2));
|
$mon = intval(substr($date, 5, 2));
|
||||||
$day = intval(substr($date,8,2));
|
$day = intval(substr($date, 8, 2));
|
||||||
$hour = intval(substr($date,11,2));
|
$hour = intval(substr($date, 11, 2));
|
||||||
$min = intval(substr($date,14,2));
|
$min = intval(substr($date, 14, 2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
2
fancybox/.gitignore
vendored
Normal file
2
fancybox/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/dist/
|
||||||
|
/test/
|
27
fancybox/CHANGELOG.md
Normal file
27
fancybox/CHANGELOG.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
### Version 1.05
|
||||||
|
|
||||||
|
* Added ALT and TITLE of original IMG to fancybox popup.
|
||||||
|
|
||||||
|
### Version 1.04
|
||||||
|
|
||||||
|
* Update supporting upcoming imnagegrid in posts
|
||||||
|
|
||||||
|
### Version 1.03
|
||||||
|
|
||||||
|
* imgages in body-attach with title / alt attribute get them removed while adding fancy attributes
|
||||||
|
* Added fancybox to image inlined in posts. Un-hooked the old lightbox from frio and vier and excahnged that with fancybox hooks.
|
||||||
|
* Excluded images in "type-link" divs from being "fancied" as they have no images but pages linked to.
|
||||||
|
|
||||||
|
### Version 1.02
|
||||||
|
|
||||||
|
* [MrPetovan](https://github.com/MrPetovan) optimized my noob regular expression code.
|
||||||
|
|
||||||
|
### Version 1.01
|
||||||
|
|
||||||
|
* One gallery for each post
|
||||||
|
* All media attached to a post are added to the posts gallery.
|
||||||
|
* Loop scrolling: You can step from last media to first and vice versa.
|
||||||
|
### Version 1.00
|
||||||
|
|
||||||
|
* First test version released.
|
||||||
|
* One fancybox per page displaying first media of each post.
|
19
fancybox/README.md
Normal file
19
fancybox/README.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Post image gallery using fancybox
|
||||||
|
|
||||||
|
Addon author: [Grischa Brockhaus](https://brockha.us)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This addon loads all media attachments of a post into a "fancybox" instead of linking directly to the media.
|
||||||
|
|
||||||
|
Each post gets its own attachment library, when there are more than one media attached you can scroll through them.
|
||||||
|
|
||||||
|
## Licenses
|
||||||
|
|
||||||
|
### Fancybox Library
|
||||||
|
|
||||||
|
This AddOn is using the jQuery library [fancybox](https://github.com/fancyapps/fancybox).
|
||||||
|
|
||||||
|
The fancyBox libryry is licensed under the GPLv3 license for all open source applications. A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
|
||||||
|
|
||||||
|
[Read more about fancyBox license](https://github.com/fancyapps/fancybox).
|
62
fancybox/asset/fancybox/README.md
Normal file
62
fancybox/asset/fancybox/README.md
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
# fancyBox 3.5.7
|
||||||
|
|
||||||
|
jQuery lightbox script for displaying images, videos and more.
|
||||||
|
Touch enabled, responsive and fully customizable.
|
||||||
|
|
||||||
|
See the [project page](http://fancyapps.com/fancybox/3/) for documentation and a demonstration.
|
||||||
|
|
||||||
|
Follow [@thefancyapps](//twitter.com/thefancyapps) for updates.
|
||||||
|
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
1\. Add latest jQuery and fancyBox files
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||||
|
|
||||||
|
<link href="/path/to/jquery.fancybox.min.css" rel="stylesheet">
|
||||||
|
<script src="/path/to/jquery.fancybox.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
2\. Create links
|
||||||
|
|
||||||
|
```html
|
||||||
|
<a data-fancybox="gallery" href="big_1.jpg">
|
||||||
|
<img src="small_1.jpg">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a data-fancybox="gallery" href="big_2.jpg">
|
||||||
|
<img src="small_2.jpg">
|
||||||
|
</a>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
3\. Enjoy!
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
fancyBox is licensed under the [GPLv3](http://choosealicense.com/licenses/gpl-3.0) license for all open source applications.
|
||||||
|
A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
|
||||||
|
|
||||||
|
[Read more about fancyBox license](http://fancyapps.com/fancybox/3/#license).
|
||||||
|
|
||||||
|
## Bugs and feature requests
|
||||||
|
|
||||||
|
If you find a bug, please report it [here on Github](https://github.com/fancyapps/fancybox/issues).
|
||||||
|
|
||||||
|
Guidelines for bug reports:
|
||||||
|
|
||||||
|
1. Use the GitHub issue search — check if the issue has already been reported.
|
||||||
|
2. Check if the issue has been fixed — try to reproduce it using the latest master or development branch in the repository.
|
||||||
|
3. Isolate the problem — create a reduced test case and a live example. You can use CodePen to fork any demo found on documentation to use it as a template.
|
||||||
|
|
||||||
|
A good bug report shouldn't leave others needing to chase you up for more information.
|
||||||
|
Please try to be as detailed as possible in your report.
|
||||||
|
|
||||||
|
|
||||||
|
Feature requests are welcome. Please look for existing ones and use GitHub's "reactions" feature to vote.
|
||||||
|
|
||||||
|
Please do not use the issue tracker for personal support requests - use Stack Overflow ([fancybox-3](http://stackoverflow.com/questions/tagged/fancybox-3) tag) instead.
|
13
fancybox/asset/fancybox/fancybox.config.js
Normal file
13
fancybox/asset/fancybox/fancybox.config.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
$.fancybox.defaults.loop = "true";
|
||||||
|
// this disables the colorbox hook found in frio/js/modal.js:34
|
||||||
|
$("body").off("click", ".wall-item-body a img");
|
||||||
|
|
||||||
|
// Adds ALT/TITLE text to fancybox
|
||||||
|
$('a[data-fancybox').fancybox({
|
||||||
|
afterLoad : function(instance, current) {
|
||||||
|
current.$image.attr('alt', current.opts.$orig.find('img').attr('alt') );
|
||||||
|
current.$image.attr('title', current.opts.$orig.find('img').attr('title') );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
895
fancybox/asset/fancybox/jquery.fancybox.css
vendored
Normal file
895
fancybox/asset/fancybox/jquery.fancybox.css
vendored
Normal file
|
@ -0,0 +1,895 @@
|
||||||
|
body.compensate-for-scrollbar {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-active {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-hidden {
|
||||||
|
left: -9999px;
|
||||||
|
margin: 0;
|
||||||
|
position: absolute !important;
|
||||||
|
top: -9999px;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-container {
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
outline: none;
|
||||||
|
position: fixed;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
top: 0;
|
||||||
|
-ms-touch-action: manipulation;
|
||||||
|
touch-action: manipulation;
|
||||||
|
transform: translateZ(0);
|
||||||
|
width: 100%;
|
||||||
|
z-index: 99992;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-container * {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-outer,
|
||||||
|
.fancybox-inner,
|
||||||
|
.fancybox-bg,
|
||||||
|
.fancybox-stage {
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-outer {
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-bg {
|
||||||
|
background: rgb(30, 30, 30);
|
||||||
|
opacity: 0;
|
||||||
|
transition-duration: inherit;
|
||||||
|
transition-property: opacity;
|
||||||
|
transition-timing-function: cubic-bezier(.47, 0, .74, .71);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-open .fancybox-bg {
|
||||||
|
opacity: .9;
|
||||||
|
transition-timing-function: cubic-bezier(.22, .61, .36, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-infobar,
|
||||||
|
.fancybox-toolbar,
|
||||||
|
.fancybox-caption,
|
||||||
|
.fancybox-navigation .fancybox-button {
|
||||||
|
direction: ltr;
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
transition: opacity .25s ease, visibility 0s ease .25s;
|
||||||
|
visibility: hidden;
|
||||||
|
z-index: 99997;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-show-infobar .fancybox-infobar,
|
||||||
|
.fancybox-show-toolbar .fancybox-toolbar,
|
||||||
|
.fancybox-show-caption .fancybox-caption,
|
||||||
|
.fancybox-show-nav .fancybox-navigation .fancybox-button {
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity .25s ease 0s, visibility 0s ease 0s;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-infobar {
|
||||||
|
color: #ccc;
|
||||||
|
font-size: 13px;
|
||||||
|
-webkit-font-smoothing: subpixel-antialiased;
|
||||||
|
height: 44px;
|
||||||
|
left: 0;
|
||||||
|
line-height: 44px;
|
||||||
|
min-width: 44px;
|
||||||
|
mix-blend-mode: difference;
|
||||||
|
padding: 0 10px;
|
||||||
|
pointer-events: none;
|
||||||
|
top: 0;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-toolbar {
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-stage {
|
||||||
|
direction: ltr;
|
||||||
|
overflow: visible;
|
||||||
|
transform: translateZ(0);
|
||||||
|
z-index: 99994;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-open .fancybox-stage {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide {
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
/* Using without prefix would break IE11 */
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
outline: none;
|
||||||
|
overflow: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
padding: 44px;
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
top: 0;
|
||||||
|
transition-property: transform, opacity;
|
||||||
|
white-space: normal;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 99994;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide::before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0;
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-sliding .fancybox-slide,
|
||||||
|
.fancybox-slide--previous,
|
||||||
|
.fancybox-slide--current,
|
||||||
|
.fancybox-slide--next {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image {
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 44px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image::before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--html {
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-content {
|
||||||
|
background: #fff;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
padding: 44px;
|
||||||
|
position: relative;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image .fancybox-content {
|
||||||
|
animation-timing-function: cubic-bezier(.5, 0, .14, 1);
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
background: transparent;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 100% 100%;
|
||||||
|
left: 0;
|
||||||
|
max-width: none;
|
||||||
|
overflow: visible;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
-ms-transform-origin: top left;
|
||||||
|
transform-origin: top left;
|
||||||
|
transition-property: transform, opacity;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
z-index: 99995;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-can-zoomOut .fancybox-content {
|
||||||
|
cursor: zoom-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-can-zoomIn .fancybox-content {
|
||||||
|
cursor: zoom-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-can-swipe .fancybox-content,
|
||||||
|
.fancybox-can-pan .fancybox-content {
|
||||||
|
cursor: -webkit-grab;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-grabbing .fancybox-content {
|
||||||
|
cursor: -webkit-grabbing;
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-container [data-selectable='true'] {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-image,
|
||||||
|
.fancybox-spaceball {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
max-height: none;
|
||||||
|
max-width: none;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-spaceball {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--video .fancybox-content,
|
||||||
|
.fancybox-slide--map .fancybox-content,
|
||||||
|
.fancybox-slide--pdf .fancybox-content,
|
||||||
|
.fancybox-slide--iframe .fancybox-content {
|
||||||
|
height: 100%;
|
||||||
|
overflow: visible;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--video .fancybox-content {
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--map .fancybox-content {
|
||||||
|
background: #e5e3df;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--iframe .fancybox-content {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-video,
|
||||||
|
.fancybox-iframe {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix iOS */
|
||||||
|
.fancybox-iframe {
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-error {
|
||||||
|
background: #fff;
|
||||||
|
cursor: default;
|
||||||
|
max-width: 400px;
|
||||||
|
padding: 40px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-error p {
|
||||||
|
color: #444;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 20px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buttons */
|
||||||
|
|
||||||
|
.fancybox-button {
|
||||||
|
background: rgba(30, 30, 30, .6);
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
height: 44px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px;
|
||||||
|
position: relative;
|
||||||
|
transition: color .2s;
|
||||||
|
vertical-align: top;
|
||||||
|
visibility: inherit;
|
||||||
|
width: 44px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button,
|
||||||
|
.fancybox-button:visited,
|
||||||
|
.fancybox-button:link {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button.fancybox-focus {
|
||||||
|
outline: 1px dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button[disabled],
|
||||||
|
.fancybox-button[disabled]:hover {
|
||||||
|
color: #888;
|
||||||
|
cursor: default;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix IE11 */
|
||||||
|
.fancybox-button div {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button svg {
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
overflow: visible;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button svg path {
|
||||||
|
fill: currentColor;
|
||||||
|
stroke-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button--play svg:nth-child(2),
|
||||||
|
.fancybox-button--fsenter svg:nth-child(2) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-button--pause svg:nth-child(1),
|
||||||
|
.fancybox-button--fsexit svg:nth-child(1) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-progress {
|
||||||
|
background: #ff5268;
|
||||||
|
height: 2px;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
-ms-transform: scaleX(0);
|
||||||
|
transform: scaleX(0);
|
||||||
|
-ms-transform-origin: 0;
|
||||||
|
transform-origin: 0;
|
||||||
|
transition-property: transform;
|
||||||
|
transition-timing-function: linear;
|
||||||
|
z-index: 99998;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close button on the top right corner of html content */
|
||||||
|
|
||||||
|
.fancybox-close-small {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
color: #ccc;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: .8;
|
||||||
|
padding: 8px;
|
||||||
|
position: absolute;
|
||||||
|
right: -12px;
|
||||||
|
top: -44px;
|
||||||
|
z-index: 401;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-close-small:hover {
|
||||||
|
color: #fff;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--html .fancybox-close-small {
|
||||||
|
color: currentColor;
|
||||||
|
padding: 10px;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image.fancybox-is-scaling .fancybox-content {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-is-scaling .fancybox-close-small,
|
||||||
|
.fancybox-is-zoomable.fancybox-can-pan .fancybox-close-small {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Navigation arrows */
|
||||||
|
|
||||||
|
.fancybox-navigation .fancybox-button {
|
||||||
|
background-clip: content-box;
|
||||||
|
height: 100px;
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: calc(50% - 50px);
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-navigation .fancybox-button div {
|
||||||
|
padding: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-navigation .fancybox-button--arrow_left {
|
||||||
|
left: 0;
|
||||||
|
left: env(safe-area-inset-left);
|
||||||
|
padding: 31px 26px 31px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-navigation .fancybox-button--arrow_right {
|
||||||
|
padding: 31px 6px 31px 26px;
|
||||||
|
right: 0;
|
||||||
|
right: env(safe-area-inset-right);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Caption */
|
||||||
|
|
||||||
|
.fancybox-caption {
|
||||||
|
background: linear-gradient(to top,
|
||||||
|
rgba(0, 0, 0, .85) 0%,
|
||||||
|
rgba(0, 0, 0, .3) 50%,
|
||||||
|
rgba(0, 0, 0, .15) 65%,
|
||||||
|
rgba(0, 0, 0, .075) 75.5%,
|
||||||
|
rgba(0, 0, 0, .037) 82.85%,
|
||||||
|
rgba(0, 0, 0, .019) 88%,
|
||||||
|
rgba(0, 0, 0, 0) 100%);
|
||||||
|
bottom: 0;
|
||||||
|
color: #eee;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
left: 0;
|
||||||
|
line-height: 1.5;
|
||||||
|
padding: 75px 44px 25px 44px;
|
||||||
|
pointer-events: none;
|
||||||
|
right: 0;
|
||||||
|
text-align: center;
|
||||||
|
z-index: 99996;
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports (padding: max(0px)) {
|
||||||
|
.fancybox-caption {
|
||||||
|
padding: 75px max(44px, env(safe-area-inset-right)) max(25px, env(safe-area-inset-bottom)) max(44px, env(safe-area-inset-left));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-caption--separate {
|
||||||
|
margin-top: -50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-caption__body {
|
||||||
|
max-height: 50vh;
|
||||||
|
overflow: auto;
|
||||||
|
pointer-events: all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-caption a,
|
||||||
|
.fancybox-caption a:link,
|
||||||
|
.fancybox-caption a:visited {
|
||||||
|
color: #ccc;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-caption a:hover {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading indicator */
|
||||||
|
|
||||||
|
.fancybox-loading {
|
||||||
|
animation: fancybox-rotate 1s linear infinite;
|
||||||
|
background: transparent;
|
||||||
|
border: 4px solid #888;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
height: 50px;
|
||||||
|
left: 50%;
|
||||||
|
margin: -25px 0 0 -25px;
|
||||||
|
opacity: .7;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
width: 50px;
|
||||||
|
z-index: 99999;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fancybox-rotate {
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transition effects */
|
||||||
|
|
||||||
|
.fancybox-animated {
|
||||||
|
transition-timing-function: cubic-bezier(0, 0, .25, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: slide */
|
||||||
|
|
||||||
|
.fancybox-fx-slide.fancybox-slide--previous {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate3d(-100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-slide.fancybox-slide--next {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate3d(100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-slide.fancybox-slide--current {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate3d(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: fade */
|
||||||
|
|
||||||
|
.fancybox-fx-fade.fancybox-slide--previous,
|
||||||
|
.fancybox-fx-fade.fancybox-slide--next {
|
||||||
|
opacity: 0;
|
||||||
|
transition-timing-function: cubic-bezier(.19, 1, .22, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-fade.fancybox-slide--current {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: zoom-in-out */
|
||||||
|
|
||||||
|
.fancybox-fx-zoom-in-out.fancybox-slide--previous {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale3d(1.5, 1.5, 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-zoom-in-out.fancybox-slide--next {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale3d(.5, .5, .5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-zoom-in-out.fancybox-slide--current {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale3d(1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: rotate */
|
||||||
|
|
||||||
|
.fancybox-fx-rotate.fancybox-slide--previous {
|
||||||
|
opacity: 0;
|
||||||
|
-ms-transform: rotate(-360deg);
|
||||||
|
transform: rotate(-360deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-rotate.fancybox-slide--next {
|
||||||
|
opacity: 0;
|
||||||
|
-ms-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-rotate.fancybox-slide--current {
|
||||||
|
opacity: 1;
|
||||||
|
-ms-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: circular */
|
||||||
|
|
||||||
|
.fancybox-fx-circular.fancybox-slide--previous {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale3d(0, 0, 0) translate3d(-100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-circular.fancybox-slide--next {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale3d(0, 0, 0) translate3d(100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-circular.fancybox-slide--current {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transitionEffect: tube */
|
||||||
|
|
||||||
|
.fancybox-fx-tube.fancybox-slide--previous {
|
||||||
|
transform: translate3d(-100%, 0, 0) scale(.1) skew(-10deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-tube.fancybox-slide--next {
|
||||||
|
transform: translate3d(100%, 0, 0) scale(.1) skew(10deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-fx-tube.fancybox-slide--current {
|
||||||
|
transform: translate3d(0, 0, 0) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styling for Small-Screen Devices */
|
||||||
|
@media all and (max-height: 576px) {
|
||||||
|
.fancybox-slide {
|
||||||
|
padding-left: 6px;
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image {
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-close-small {
|
||||||
|
right: -6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-slide--image .fancybox-close-small {
|
||||||
|
background: #4e4e4e;
|
||||||
|
color: #f2f4f6;
|
||||||
|
height: 36px;
|
||||||
|
opacity: 1;
|
||||||
|
padding: 6px;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-caption {
|
||||||
|
padding-left: 12px;
|
||||||
|
padding-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports (padding: max(0px)) {
|
||||||
|
.fancybox-caption {
|
||||||
|
padding-left: max(12px, env(safe-area-inset-left));
|
||||||
|
padding-right: max(12px, env(safe-area-inset-right));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Share */
|
||||||
|
|
||||||
|
.fancybox-share {
|
||||||
|
background: #f4f4f4;
|
||||||
|
border-radius: 3px;
|
||||||
|
max-width: 90%;
|
||||||
|
padding: 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share h1 {
|
||||||
|
color: #222;
|
||||||
|
font-size: 35px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share p {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button {
|
||||||
|
border: 0;
|
||||||
|
border-radius: 3px;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 40px;
|
||||||
|
margin: 0 5px 10px 5px;
|
||||||
|
min-width: 130px;
|
||||||
|
padding: 0 15px;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all .2s;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button:visited,
|
||||||
|
.fancybox-share__button:link {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--fb {
|
||||||
|
background: #3b5998;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--fb:hover {
|
||||||
|
background: #344e86;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--pt {
|
||||||
|
background: #bd081d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--pt:hover {
|
||||||
|
background: #aa0719;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--tw {
|
||||||
|
background: #1da1f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button--tw:hover {
|
||||||
|
background: #0d95e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button svg {
|
||||||
|
height: 25px;
|
||||||
|
margin-right: 7px;
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__button svg path {
|
||||||
|
fill: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-share__input {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px solid #d7d7d7;
|
||||||
|
border-radius: 0;
|
||||||
|
color: #5d5b5b;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 10px 0 0 0;
|
||||||
|
outline: none;
|
||||||
|
padding: 10px 15px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
/* Thumbs */
|
||||||
|
|
||||||
|
.fancybox-thumbs {
|
||||||
|
background: #ddd;
|
||||||
|
bottom: 0;
|
||||||
|
display: none;
|
||||||
|
margin: 0;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
-ms-overflow-style: -ms-autohiding-scrollbar;
|
||||||
|
padding: 2px 2px 4px 2px;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||||
|
top: 0;
|
||||||
|
width: 212px;
|
||||||
|
z-index: 99995;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs-x {
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-show-thumbs .fancybox-thumbs {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-show-thumbs .fancybox-inner {
|
||||||
|
right: 212px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list {
|
||||||
|
font-size: 0;
|
||||||
|
height: 100%;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
position: relative;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs-x .fancybox-thumbs__list {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar {
|
||||||
|
width: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar-track {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar-thumb {
|
||||||
|
background: #2a2a2a;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list a {
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
background-color: rgba(0, 0, 0, .1);
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
cursor: pointer;
|
||||||
|
float: left;
|
||||||
|
height: 75px;
|
||||||
|
margin: 2px;
|
||||||
|
max-height: calc(100% - 8px);
|
||||||
|
max-width: calc(50% - 4px);
|
||||||
|
outline: none;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
|
position: relative;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list a::before {
|
||||||
|
border: 6px solid #ff5268;
|
||||||
|
bottom: 0;
|
||||||
|
content: '';
|
||||||
|
left: 0;
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
transition: all .2s cubic-bezier(.25, .46, .45, .94);
|
||||||
|
z-index: 99991;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list a:focus::before {
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list a.fancybox-thumbs-active::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styling for Small-Screen Devices */
|
||||||
|
@media all and (max-width: 576px) {
|
||||||
|
.fancybox-thumbs {
|
||||||
|
width: 110px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-show-thumbs .fancybox-inner {
|
||||||
|
right: 110px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancybox-thumbs__list a {
|
||||||
|
max-width: calc(100% - 10px);
|
||||||
|
}
|
||||||
|
}
|
5632
fancybox/asset/fancybox/jquery.fancybox.js
vendored
Normal file
5632
fancybox/asset/fancybox/jquery.fancybox.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
fancybox/asset/fancybox/jquery.fancybox.min.css
vendored
Normal file
1
fancybox/asset/fancybox/jquery.fancybox.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
13
fancybox/asset/fancybox/jquery.fancybox.min.js
vendored
Normal file
13
fancybox/asset/fancybox/jquery.fancybox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
fancybox/createrelease
Executable file
15
fancybox/createrelease
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
MODULE=fancybox
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# old releases not needed anymore
|
||||||
|
mkdir -p $MODULE/dist
|
||||||
|
rm $MODULE/dist/*
|
||||||
|
|
||||||
|
# create release for actual version
|
||||||
|
zip -r9 $MODULE/dist/release.zip $MODULE/* -x $MODULE/dist/\* -x $MODULE/test/\* $MODULE/createrelease
|
||||||
|
|
||||||
|
echo dist/release.zip created.
|
||||||
|
|
||||||
|
cd $MODULE
|
||||||
|
|
61
fancybox/fancybox.php
Normal file
61
fancybox/fancybox.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Name: Fancybox
|
||||||
|
* Description: Open media attachments of posts into a fancybox overlay.
|
||||||
|
* Version: 1.05
|
||||||
|
* Author: Grischa Brockhaus <grischa@brockha.us>
|
||||||
|
* Status: Unsupported
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Hook;
|
||||||
|
use Friendica\DI;
|
||||||
|
|
||||||
|
function fancybox_install()
|
||||||
|
{
|
||||||
|
Hook::register('head', __FILE__, 'fancybox_head');
|
||||||
|
Hook::register('footer', __FILE__, 'fancybox_footer');
|
||||||
|
Hook::register('prepare_body_final', __FILE__, 'fancybox_render');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fancybox_head(string &$b)
|
||||||
|
{
|
||||||
|
DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fancybox_footer(string &$str)
|
||||||
|
{
|
||||||
|
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
|
||||||
|
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fancybox_render(array &$b){
|
||||||
|
$gallery = 'gallery-' . $b['item']['uri-id'] ?? random_int(1000000, 10000000);
|
||||||
|
|
||||||
|
// performWithEscapedBlocks escapes block defined with 2nd par pattern that won't be processed.
|
||||||
|
// We don't want to touch images in class="type-link":
|
||||||
|
$b['html'] = \Friendica\Util\Strings::performWithEscapedBlocks(
|
||||||
|
$b['html'],
|
||||||
|
'#<div class="type-link">.*?</div>#s',
|
||||||
|
function ($text) use ($gallery) {
|
||||||
|
// This processes images inlined in posts
|
||||||
|
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
|
||||||
|
//if (!in_array(DI::app()->getCurrentTheme(),['vier','frio']))
|
||||||
|
$text = preg_replace(
|
||||||
|
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
||||||
|
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',
|
||||||
|
$text);
|
||||||
|
|
||||||
|
// Local content images attached:
|
||||||
|
$text = preg_replace_callback(
|
||||||
|
'#<div class="(body-attach|imagegrid-column)">.*?</div>#s',
|
||||||
|
function ($matches) use ($gallery) {
|
||||||
|
return str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $matches[0]);
|
||||||
|
},
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -85,17 +86,12 @@ function ijpost_settings_post(array &$b)
|
||||||
|
|
||||||
function ijpost_post_local(array &$b)
|
function ijpost_post_local(array &$b)
|
||||||
{
|
{
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
|
||||||
|
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +116,7 @@ function ijpost_post_local(array &$b)
|
||||||
|
|
||||||
function ijpost_send(array &$b)
|
function ijpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,11 +146,11 @@ function ijpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date,0,4));
|
$year = intval(substr($date, 0, 4));
|
||||||
$mon = intval(substr($date,5,2));
|
$mon = intval(substr($date, 5, 2));
|
||||||
$day = intval(substr($date,8,2));
|
$day = intval(substr($date, 8, 2));
|
||||||
$hour = intval(substr($date,11,2));
|
$hour = intval(substr($date, 11, 2));
|
||||||
$min = intval(substr($date,14,2));
|
$min = intval(substr($date, 14, 2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
|
||||||
function libertree_install()
|
function libertree_install()
|
||||||
|
@ -74,13 +75,11 @@ function libertree_settings(array &$data)
|
||||||
function libertree_settings_post(array &$b)
|
function libertree_settings_post(array &$b)
|
||||||
{
|
{
|
||||||
if (!empty($_POST['libertree-submit'])) {
|
if (!empty($_POST['libertree-submit'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post',intval($_POST['libertree']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post', intval($_POST['libertree']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post_by_default',intval($_POST['libertree_bydefault']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default', intval($_POST['libertree_bydefault']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_api_token',trim($_POST['libertree_api_token']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token', trim($_POST['libertree_api_token']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_url',trim($_POST['libertree_url']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url', trim($_POST['libertree_url']));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function libertree_hook_fork(array &$b)
|
function libertree_hook_fork(array &$b)
|
||||||
|
@ -91,8 +90,10 @@ function libertree_hook_fork(array &$b)
|
||||||
|
|
||||||
$post = $b['data'];
|
$post = $b['data'];
|
||||||
|
|
||||||
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
|
if (
|
||||||
!strstr($post['postopts'], 'libertree') || ($post['parent'] != $post['id'])) {
|
$post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
|
||||||
|
!strstr($post['postopts'], 'libertree') || ($post['gravity'] != Item::GRAVITY_PARENT)
|
||||||
|
) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -100,26 +101,20 @@ function libertree_hook_fork(array &$b)
|
||||||
|
|
||||||
function libertree_post_local(array &$b)
|
function libertree_post_local(array &$b)
|
||||||
{
|
{
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
|
||||||
|
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post'));
|
$ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post'));
|
||||||
|
|
||||||
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
|
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'))) {
|
||||||
$ltree_enable = 1;
|
$ltree_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +133,11 @@ function libertree_send(array &$b)
|
||||||
{
|
{
|
||||||
Logger::notice('libertree_send: invoked');
|
Logger::notice('libertree_send: invoked');
|
||||||
|
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! strstr($b['postopts'],'libertree')) {
|
if (! strstr($b['postopts'], 'libertree')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,15 +154,15 @@ function libertree_send(array &$b)
|
||||||
|
|
||||||
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
||||||
|
|
||||||
$ltree_api_token = DI::pConfig()->get($b['uid'],'libertree','libertree_api_token');
|
$ltree_api_token = DI::pConfig()->get($b['uid'], 'libertree', 'libertree_api_token');
|
||||||
$ltree_url = DI::pConfig()->get($b['uid'],'libertree','libertree_url');
|
$ltree_url = DI::pConfig()->get($b['uid'], 'libertree', 'libertree_url');
|
||||||
$ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token";
|
$ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token";
|
||||||
$ltree_source = DI::baseUrl()->getHost();
|
$ltree_source = DI::baseUrl()->getHost();
|
||||||
|
|
||||||
if ($b['app'] != "")
|
if ($b['app'] != "")
|
||||||
$ltree_source .= " (".$b['app'].")";
|
$ltree_source .= " (" . $b['app'] . ")";
|
||||||
|
|
||||||
if($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) {
|
if ($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) {
|
||||||
$title = $b['title'];
|
$title = $b['title'];
|
||||||
$body = $b['body'];
|
$body = $b['body'];
|
||||||
// Insert a newline before and after a quote
|
// Insert a newline before and after a quote
|
||||||
|
@ -177,7 +172,7 @@ function libertree_send(array &$b)
|
||||||
// Removal of tags and mentions
|
// Removal of tags and mentions
|
||||||
// #-tags
|
// #-tags
|
||||||
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
||||||
// @-mentions
|
// @-mentions
|
||||||
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
||||||
|
|
||||||
// remove multiple newlines
|
// remove multiple newlines
|
||||||
|
@ -198,7 +193,7 @@ function libertree_send(array &$b)
|
||||||
$params = [
|
$params = [
|
||||||
'text' => $body,
|
'text' => $body,
|
||||||
'source' => $ltree_source
|
'source' => $ltree_source
|
||||||
// 'token' => $ltree_api_token
|
// 'token' => $ltree_api_token
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -35,7 +36,7 @@ function ljpost_jot_nets(array &$jotnets_fields)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post')) {
|
||||||
$jotnets_fields[] = [
|
$jotnets_fields[] = [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'field' => [
|
'field' => [
|
||||||
|
@ -57,7 +58,7 @@ function ljpost_settings(array &$data)
|
||||||
$ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username');
|
$ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username');
|
||||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default');
|
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default');
|
||||||
|
|
||||||
$t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||||
$html = Renderer::replaceMacros($t, [
|
$html = Renderer::replaceMacros($t, [
|
||||||
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
||||||
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
||||||
|
@ -86,20 +87,16 @@ function ljpost_settings_post(array &$b)
|
||||||
|
|
||||||
function ljpost_post_local(array &$b)
|
function ljpost_post_local(array &$b)
|
||||||
{
|
{
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post'));
|
$lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post'));
|
||||||
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
|
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) {
|
||||||
|
@ -118,11 +115,11 @@ function ljpost_post_local(array &$b)
|
||||||
|
|
||||||
function ljpost_send(array &$b)
|
function ljpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($b['postopts'],'ljpost')) {
|
if (!strstr($b['postopts'], 'ljpost')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +136,13 @@ function ljpost_send(array &$b)
|
||||||
$user = User::getById($b['uid']);
|
$user = User::getById($b['uid']);
|
||||||
$tz = $user['timezone'] ?: 'UTC';
|
$tz = $user['timezone'] ?: 'UTC';
|
||||||
|
|
||||||
$lj_username = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_username'));
|
$lj_username = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_username'));
|
||||||
$lj_password = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_password'));
|
$lj_password = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_password'));
|
||||||
$lj_journal = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_journal'));
|
$lj_journal = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_journal'));
|
||||||
// if(! $lj_journal)
|
// if(! $lj_journal)
|
||||||
// $lj_journal = $lj_username;
|
// $lj_journal = $lj_username;
|
||||||
|
|
||||||
$lj_blog = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_blog'));
|
$lj_blog = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_blog'));
|
||||||
if (!strlen($lj_blog)) {
|
if (!strlen($lj_blog)) {
|
||||||
$lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
|
$lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
|
||||||
}
|
}
|
||||||
|
@ -157,11 +154,11 @@ function ljpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date,0,4));
|
$year = intval(substr($date, 0, 4));
|
||||||
$mon = intval(substr($date,5,2));
|
$mon = intval(substr($date, 5, 2));
|
||||||
$day = intval(substr($date,8,2));
|
$day = intval(substr($date, 8, 2));
|
||||||
$hour = intval(substr($date,11,2));
|
$hour = intval(substr($date, 11, 2));
|
||||||
$min = intval(substr($date,14,2));
|
$min = intval(substr($date, 14, 2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -18,6 +18,7 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use phpnut\phpnutException;
|
use phpnut\phpnutException;
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ function pnut_connect()
|
||||||
$o = DI::l10n()->t('Error fetching token. Please try again.', ['code' => $e->getCode(), 'message' => $e->getMessage()]);
|
$o = DI::l10n()->t('Error fetching token. Please try again.', ['code' => $e->getCode(), 'message' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page").'</a>';
|
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ function pnut_settings(array &$data)
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirectUri = DI::baseUrl() . '/pnut/connect';
|
$redirectUri = DI::baseUrl() . '/pnut/connect';
|
||||||
$scope = ['write_post','files'];
|
$scope = ['write_post', 'files'];
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post') ?? false;
|
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post') ?? false;
|
||||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default') ?? false;
|
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default') ?? false;
|
||||||
|
@ -221,7 +222,7 @@ function pnut_hook_fork(array &$b)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['parent'] != $post['id']) || $post['private']) {
|
if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -229,15 +230,11 @@ function pnut_hook_fork(array &$b)
|
||||||
|
|
||||||
function pnut_post_local(array &$b)
|
function pnut_post_local(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['private'] || $b['parent']) {
|
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +262,7 @@ function pnut_post_hook(array &$b)
|
||||||
/**
|
/**
|
||||||
* Post to pnut.io
|
* Post to pnut.io
|
||||||
*/
|
*/
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -345,14 +345,14 @@ function pumpio_hook_fork(array &$b)
|
||||||
|
|
||||||
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
|
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
|
||||||
// Don't fork if it isn't a reply to a pump.io post
|
// Don't fork if it isn't a reply to a pump.io post
|
||||||
if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
|
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
|
||||||
Logger::notice('No pump.io parent found for item ' . $post['id']);
|
Logger::notice('No pump.io parent found for item ' . $post['id']);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Comments are never exported when we don't import the pumpio timeline
|
// Comments are never exported when we don't import the pumpio timeline
|
||||||
if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['private']) {
|
if (!strstr($post['postopts'], 'pumpio') || ($post['gravity'] != Item::GRAVITY_PARENT)|| ($post['private'] == Item::PRIVATE)) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ function pumpio_send(array &$b)
|
||||||
|
|
||||||
Logger::notice('pumpio_send: receiver ', $receiver);
|
Logger::notice('pumpio_send: receiver ', $receiver);
|
||||||
|
|
||||||
if (!count($receiver) && ($b['private'] || !strstr($b['postopts'], 'pumpio'))) {
|
if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1319,7 +1319,7 @@ function pumpio_getreceiver(array $b)
|
||||||
{
|
{
|
||||||
$receiver = [];
|
$receiver = [];
|
||||||
|
|
||||||
if (!$b['private']) {
|
if ($b['private'] != Item::PRIVATE) {
|
||||||
if (!strstr($b['postopts'], 'pumpio')) {
|
if (!strstr($b['postopts'], 'pumpio')) {
|
||||||
return $receiver;
|
return $receiver;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue