Skip to content

Commit fd6221c

Browse files
committed
Fixed infinite loop with extensions + added help in Exception
1 parent 8ad5ce0 commit fd6221c

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

lib/Phpfastcache/CacheManager.php

-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ public static function getDriverList(bool $fqcnAsKey = false): array
313313

314314
if (self::getDefaultNamespacePath() === self::getNamespacePath()) {
315315
if ($driverList === null) {
316-
ExtensionManager::autoloadExtensions();
317316
$prefix = self::CORE_DRIVER_NAMESPACE;
318317
$classMap = self::createClassMap(__DIR__ . '/Drivers');
319318
$driverList = [];

lib/Phpfastcache/Core/Pool/DriverBaseTrait.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface
7777
$this->instanceId = $instanceId;
7878

7979
if (!$this->driverCheck()) {
80-
throw new PhpfastcacheDriverCheckException(\sprintf(ExtendedCacheItemPoolInterface::DRIVER_CHECK_FAILURE, $this->getDriverName()));
80+
throw new PhpfastcacheDriverCheckException(
81+
\sprintf(
82+
ExtendedCacheItemPoolInterface::DRIVER_CHECK_FAILURE,
83+
$this->getDriverName(),
84+
$this->getHelp() ? " Additionally, {$this->getHelp()}" : ''
85+
)
86+
);
8187
}
8288
$this->eventManager->dispatch(Event::CACHE_DRIVER_CHECKED, $this);
8389

@@ -92,7 +98,7 @@ public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface
9298
$this->getDriverName(),
9399
$e->getMessage(),
94100
$e->getLine() ?: 'unknown line',
95-
$e->getFile() ?: 'unknown file'
101+
$e->getFile() ?: 'unknown file',
96102
),
97103
0,
98104
$e

lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
interface ExtendedCacheItemPoolInterface extends CacheItemPoolInterface, EventManagerDispatcherInterface, ClassNamespaceResolverInterface, TaggableCacheItemPoolInterface
3838
{
3939
public const DRIVER_CHECK_FAILURE = '%s is not installed or is misconfigured, cannot continue.
40-
Also, please verify the suggested dependencies in composer because as of the V6, 3rd party libraries are no longer required.';
40+
Also, please verify the suggested dependencies in composer because as of the V6, 3rd party libraries are no longer required.%s';
4141

42-
public const DRIVER_CONNECT_FAILURE = '%s failed to connect with the following error message: "%s" line %d in %s';
42+
public const DRIVER_CONNECT_FAILURE = '%s failed to connect with the following error message: "%s" line %d in %s.';
4343

4444
public const DRIVER_KEY_WRAPPER_INDEX = 'k';
4545

lib/Phpfastcache/Drivers/Wincache/Driver.php

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public function driverCheck(): bool
4040
return extension_loaded('wincache') && function_exists('wincache_ucache_set');
4141
}
4242

43+
public function getHelp(): string
44+
{
45+
return <<<HELP
46+
Wincache PECL extension is not maintained anymore and has been superseded. Check sourceforge for more informations: https://sourceforge.net/projects/wincache/'
47+
HELP;
48+
}
49+
4350
/**
4451
* @return DriverStatistic
4552
*/

tests/Wincache.test.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/**
4+
*
5+
* This file is part of Phpfastcache.
6+
*
7+
* @license MIT License (MIT)
8+
*
9+
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files.
10+
*
11+
* @author Georges.L (Geolim4) <contact@geolim4.com>
12+
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
13+
*/
14+
15+
use Phpfastcache\CacheManager;
16+
use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException;
17+
use Phpfastcache\Tests\Helper\TestHelper;
18+
use Phpfastcache\Drivers\Wincache\Config as WincacheConfig;
19+
use Redis as RedisClient;
20+
21+
chdir(__DIR__);
22+
require_once __DIR__ . '/../vendor/autoload.php';
23+
$testHelper = new TestHelper('Wincache');
24+
25+
$cacheInstance = CacheManager::getInstance('Wincache', new WincacheConfig());
26+
$testHelper->runCRUDTests($cacheInstance);
27+
28+
$testHelper->terminateTest();

0 commit comments

Comments
 (0)