Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey
I have a problem with class conflict.
On my drupal site I have instaled phpbbforum intgration module, and when I try to run cache router - Redefinition class Cache /forum/inludes/cache.php
Comment | File | Size | Author |
---|---|---|---|
#20 | 564460_d5.patch | 4.03 KB | andypost |
#20 | 564460_d6.patch | 4.12 KB | andypost |
#15 | 564460_name.patch | 5.86 KB | andypost |
#8 | 564460_cr_class.patch | 8.98 KB | andypost |
#5 | cr.patch | 22.84 KB | PreZ |
Comments
Comment #1
andypostmaybe change main class name to DrupalCache or CRCache to predict future namespace collisions?
Comment #2
superfedya CreditAttribution: superfedya commentedsame problem :(
Any fix?
Comment #3
fortis CreditAttribution: fortis commentedsame problem...
Comment #4
fortis CreditAttribution: fortis commentedсуперфедя, решил проблему так: http://www.drupal.ru/node/39142#comment-207837
Comment #5
PreZ CreditAttribution: PreZ commentedI have worked around this in three ways.
First, I renamed the Cache class to CacheEngine, and all the engines now extend this class.
Second, I renamed the $cache variable to $cacherouter.
Third, I changed require(engine) to require_once(engine) because I was getting errors about redeclaring a class.
I have submitted a patch to the latest version with these changes. They seem to work fine on my setup.
Comment #6
andypostYay! +1 to CacheEngine
should be global $cacherouter, $user
I see no reason to change $cache to $cacherouter inside engines except parent class name - all this variables are local so there's no collisions
Comment #7
PreZ CreditAttribution: PreZ commentedYeah, I went a little overboard there. But I was not 100% sure how it was used when I made the change - but it's all good. I've done a lot more changes since then to allow for integration between dtools and cacherouter (ie. so the 'simple' performance storage can be saved using cache, even when not using APC as a backend).
This required the creation of a cache_delete standalone function, but also creation of a cache_list function (and equivalent support in the engines and cache router and cache interface). Which also required the creation of an unkey() function equivalent to key(). All in all, probably too much work, but it was an interesting experiment.
But just changing $cache -> $cacherouter is necessary to support phpbb3.
Comment #8
andypost@PreZ this patch is more readable
Comment #9
andypostI think we should take D7 approach and use Drupal{engine}Class for Engines this could help to prevent class name collisions in future
...and makes easy to maintain all branches
Comment #10
andypostTake a closer look at D7 implementation I think it should be
DrupalCache{Engine}
or
Drupal{Engine}Cache
because of Drupal 7 core uses
DrupalDatabaseCache classname
Comment #11
andypostThis was fixed for DRUPAL-6--1 branch
I choose DrupalRouterCache for base class to be more compatible with D7
All Engine classes now {type}CacheEngine
Now it should be ported to 5 branch to proceed next RC
Comment #12
slantview CreditAttribution: slantview commentedI don't think I like DrupalRouterCache as I think it is a confusing name. I think the default class should be CacheEngine and the rest of the engines should be {type}CacheEngine. DrupalRouterCache is confusing because the default class of the CacheRouter is called CacheRouter and I don't want any ambiguity between the two.
CacheEngine is an abstract class that is only really used like an interface not a normal Cache Engine and it certainly isn't the Router. It is simply a base class that we use some functionality of in the cache engines.
steve
Comment #13
andypostAgreed with confusion. Maybe CacherouterEngine is better name for base (abstract) class name to prevent future collisions and looks more native for me.
If we talk about D7 implementation and CacheRouter class so name should be Drupal{type}Cache (like DrupalDatabaseCache) because of nature of cacherouter this class just a router so lets proceed with DrupalCacherouterCache for main class and CacherouterEngine for abstract class for engine?
Engines already {type}CacheEngine in D6 branch but we need decide on main class and engine abstraction
Comment #14
slantview CreditAttribution: slantview commentedThre reason I think CacheEngine is a good name is because it is the abstract class and not an actual _implementation_ of that class. So it won't conflict with the naming conventions used in DrupalCache. I don't think we have to follow core's naming conventions for our internal cache classes anyway, we just need to construct them that they won't interrupt or interfere with core.
Comment #15
andypostI meen collisions when drupal used for integration with any third-party software like bb and others, so prefixing will help
Anyway here the patch, if we use CacheRouter as main class so abstract class should be CacheRouterEngine to unify naming
Comment #16
slantview CreditAttribution: slantview commentedThat sounds fine.
Comment #17
andypostCommited to 6 branch
Comment #18
andypostcommited into 5 http://drupal.org/cvs?commit=324984 with code cleaning
Comment #19
andypostSuppose fixed for D7 http://drupal.org/cvs?commit=325014
Next I think to rename global $cache_router to $_cache_router as proposed by http://drupal.org/coding-standards#naming
Comment #20
andypostHere patches to review
Comment #21
Carl Johan CreditAttribution: Carl Johan commentedPatches are against CVS HEAD or rc1?
Comment #22
andypostDRUPAL-5 & DRUPAL-6--1 http://drupal.org/project/cacherouter/cvs-instructions