Closed (fixed)
Project:
Redis
Version:
7.x-3.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2012 at 14:59 UTC
Updated:
7 Sep 2015 at 09:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pounardOh right... I changed all class_exists("¨Predis::client") to class_exists("Predis\Client"). I remember that in the old days I got serious problems PHP wasn't finding "¨Predis\Client" but was finding "Predis::Client" but now the exact opposite is happening on my box, it seems that you are experiencing what I was experiencing a long time ago...
Can you paste here the revelant changes you made to your settings.php file please?
Can you also give me the PHP version you're using?
Waiting for your answer.
Comment #2
pierrepaul commentedWe stumbled on the bug together, but in my case alpha11 isn't working either.
I've kept my settings.php to the bare minimum :
It might have something to do with my PHP version though : PHP 5.4.6
Comment #3
pounardOk thanks a lot, I will try to solve that before the end of the week thought I cannot promise anything. I'm coming back to you ASAP.
Comment #4
pounardI have to admit that autoloading handling is quite ugly in this module. Bug is arround that.
Comment #5
pbuyle commentedCan X Autoload help or is the auto-loading of Predis needed too early in the bootstrap process?
Comment #6
pounardI think Predis is needed too early for that, hook_boot() is run long after first hits to the cache system have been done.
Comment #7
pbuyle commentedIf you look at the stacktrace,
Redis_Client_Predis::getClient()is invoked twice (14 and 23). And the class load failure happens during the second invocation. Now that second invocation happens during theclass_exists()invocation made byRedis_Client_Predis::setPredisAutoload()(17). PHP tries to load thePredis\Clientclass usingdrupal_autoload_class()(18) which itself end up callingRedis_Client_Predis::getClient()(24) as part of the code registry caching (19 to 23). I guess PHP is avoiding infinite recursion here and returnsTRUEfor the secondclass_exists()invocation. PreventingRedis_Client_Predis::setPredisAutoload()from registering its autoload function and soPredis\Clientis not loaded before being used.Using FALSE as second argument for
class_exists()to avoid using autoload solve the issue on my side.I guess using the "::" syntax works because, at least on my PHP version, it does not work as a namespace separator. So
drupal_autoload_class()is not used to (try to) loadPredis\Client, andRedis_Client_Predis::setPredisAutoload()succeed in registering its autoload function beforePredis\Clientis used.Comment #8
pbuyle commentedSee #7
Comment #9
pounardIs this bug still a bug? It seems that latest releases may have fixed it. I'm closing it as "cannot reproduce" please re open if this happens with the latest release.
Comment #10
aangel commentedRe-opening because this is occurring for me with:
- php 5.4.10
- redis 7.x-2.0-beta4
Comment #11
aangel commentedNever mind...newbie install mistake. Was missing predis library.
Comment #12
pounardHehe, don't worry this kind of mistake happens to all of us. Happy it works for you. Thanks for bothering opening the issue thought, even if it's not.
Comment #13
hiramanpatilFacing issue with below versions-
Redis version - 7.x-2.6
PHP version - 5.2.10 and 5.3.12
Drupal - 7.27
There is no issue with live site which is on pantheon but when I trying to setup it on local environment it gives errors.
Fatal error: Class 'Redis' not found in /ROOT_PATH/sites/all/modules/redis/lib/Redis/Client/PhpRedis.php on line 9Please help me on this.
Thanks
Comment #14
rene bakxI just had the same issue, and the manual for predis is not really up to date with the current state of the library.
What I did was, cloned https://github.com/nrk/predis into a temp folder, then copied the src folder in to my libraries folder. Renamed src into Predis (mind the capital P)
So I ended up with Predis being in /sites/all/Predis and
see http://imgur.com/ozNOcda
Secondly I added the following lines in the bottom of settings.php, and the first line is important.
As a side note, i use the xautoload module on all my projects, so Iam not 100% sure if this trick will work without it. But if I disable xautoload, the rest of my site WSOD's :)
Comment #15
floretan commentedThe location of the files within the Predis library has changed from "lib" to "src" (see https://github.com/nrk/predis/commit/029822fe22acac3a769f14a11f417d9a083...).
Given that there is now a stable 1.0 release of Predis, we can assume that new users will install that version by default. We should just notify existing users updating the redis module that they should also update the Predis library.
Comment #16
floretan commentedWhile the initial symptoms are the same (class not found), there is already an issue for the 1.0 compatibility: #2329055: Compatibility with Predis 1.x
Comment #17
garnett2125 commentedHere is a patch I needed
Comment #18
garnett2125 commentedComment #19
garnett2125 commentedRepository structure have change in the Predis librarie https://github.com/nrk/predis
So I needed to apply this patch for it to works.
I also needed to change PREDIS_BASE_PATH because the folder is no longer libraries/predis/lib/ but libraries/predis/src/ (by default if you don't define this var it will be DRUPAL_ROOT . '/sites/all/libraries/predis/lib/' which doesn't exist)
Hope it helps
Comment #20
pounardOups forgot about this, I need to review it.
Comment #21
candelas commentedGood I found this. I was getting errors because of lib instead of src. Thanks @garnett2125
I hope it gets in dev, so new users will go faster :)
Comment #22
candelas commentedpatch #19 worked library Predis 1.0.2-dev and writing the src correction in settings.php
define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/sites/all/libraries/predis/src/');Comment #23
candelas commentedThe patch is still required because if not you get
Fatal error: require_once(): Failed opening required '/xxx/sites/all/libraries/predis/src/Predis/Client.php
To avoid the problem with having to set
define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/sites/all/libraries/predis/src/');
the #2329055: Compatibility with Predis 1.x should be ported to 7.x-2.x (it is only in 7.x-3.x)
I hope it helps someone :)
Comment #24
pounardIt happens that I accidentally experienced the bug on a project, and it is the only one it actually happens. Somehow, the
!class_exists('Predis\Client')condition fails on this environment where it should not, and the bug triggers; but this is nothing that can be solved by the previous 2 patches... I still need to investigate this further.Comment #25
pivica commentedHmm using redis 7.x-2.15 and predis 1.0.1 and each time i execute drush cc all getting next error
Comment #26
duaelfrSame issue with
- Redis 7.x-3.9
- Predis 1.0.3
- PHP (fpm) 5.6.9
I don't know what's going on but if I copy the
spl_autoload_register()call fromPredis::setPredisAutoload()toredis.autoload.phpit works.My only workaround for now is to include the Predis' autoload.php directly in my settings.php as follows:
Comment #27
duaelfrConfirmed on 7.x-3.x
Comment #28
pounardOk, thanks for the additional details, I'll try to look into this a bit deeper as soon as I can.
Comment #29
weri commentedThe "comment" from DuaelFr (#26) solves the problem, but is not a final solution.
Comment #31
pounardOk this now should be fixed, please wait for the next release (today or tomorrow). Thanks everyone for your patience and all the help you've given.
For your information, the bug is due to the core autoloader, when the Redis_Client_Predis::setPredisAutoload() method is called for the first time and the core autoloader is registered (i.e. if you didn't set the page_cache_without_database variable or you are logged in), core autoloader will attempt a cache_get() call. Because the Predis discovery has already be run once, it won't try a second time, and fail to load the class during the core autoloader recursion.
I had to write a very ugly patch to make this work, the real bug is a core one, an autoloader should never trigger another one, and rely upon database and cache for autoloading creates a chicken and egg problem which causes such ambiguous issues.
Please if the next release does not fix the problem, please re-open this issue.
Comment #32
cola commentedHi All
We use Redis and not Predis. Did you solve also the issue for Redis class?
drush status
PHP Fatal error: Class 'Redis' not found in ../sites/default/settings.php on line 587
Fatal error: Class 'Redis' not found in ../sites/default/settings.php on line 587
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Class 'Redis' not found in ../sites/default/settings.php, line 587
Thank you for your answer
Comment #33
pounard@cola if you experience such errors then the phpredis extension is not enabled in your PHP runtime, check that you have installed the phpredis extension and that you correctly enabled it in your PHP ini files.