Problem/Motivation
Move classes from bootstap.inc and 'use' them instead.
This is motivated by my overall interest in cleaning up bootstrap.inc. Though this is a part of our overall goal making our classes PSR-0 namespaced.
Proposed resolution
Move DrupalCacheArray to new Drupal\Core\Utilities namespace.
Move SchemaCache to new Drupal\Core\Schema namespace. Drupal\Core\Utilities as well.
OOp lock system and inject into into DrupalCacheArray.
'use' new classes where needed.
Remaining tasks
There is an issue open for OOPing the locking system #1225404: Modern event based lock framework proposal - instead of tackling the injection of the locking system inthe DrupalCacheArray as part of this issue, a new refactoring issue should be opened with a dependency on #1225404.
User interface changes
None
API changes
None - just need to 'use' the classes where appropriate.
Comment | File | Size | Author |
---|---|---|---|
#12 | remove-classes-from-bootstrap-1469826-12.patch | 17.86 KB | andremolnar |
#8 | remove-classes-from-bootstrap-1469826-8.patch | 17.88 KB | andremolnar |
#6 | remove-classes-from-bootstrap-1469826-6.patch | 17.51 KB | andremolnar |
#5 | remove-classes-from-bootstrap-1469826-5.patch | 17.5 KB | andremolnar |
Comments
Comment #1
catchDrupalCacheArray itself I don't think belongs in the cache subsystem (at the moment it has a cross-dependency on the lock system for a start), and feels more like a standalone to me.
The Schema class should go in the Drupal\Core\Schema namespace, except we'd need to convert the schema API to classes first. There may be an issue for that already.
Comment #2
Crell CreditAttribution: Crell commentedAgreed with catch. DrupalCacheArray should be its own thing, and we should try to remove those dependencies if possible (or inject them). For schema... Overhauling the Schema API to be more consistent and modern is on my todo list, but so are many other things. :-/
Perhaps we should have a Drupal\Core\Utility for these one-off little classes for the time being, so they don't pollute Drupal\Core if they have nowhere else to go.
Comment #2.0
andremolnar CreditAttribution: andremolnar commentedUpdating proposed solution based on feedback.
Comment #3
andremolnar CreditAttribution: andremolnar commentedUpdated issue with suggestions.
As an initial pass I'll create the new namespaces and move the classes there. As a follow up I'll look at lock.inc and see if it makes sense to OO it and inject it into the DrupalCacheArray
Comment #4
catchThere's an issue for lock.inc at #1225404: Modern event based lock framework proposal however it's gone quite a bit further than a straight OOP-ifying, so I'm wondering if we need a new issue for a straight-as-possible conversion to unblock the general detangling issues such as this.
Comment #5
andremolnar CreditAttribution: andremolnar commentedRather than add a dependency on a yet to be created issue, would it make more sense to move the classes out as a start to 'detangle' and then open an issue to refactor DrupalCacheArray with a note to inject the reworked locking system?
DrupalCache array needs to be refactored anyway since it has comments in the code re: limitations of PHP pre-5.3 (but that's beyond the scope of what I'm trying to achieve here - i.e. bootstrap cleanup and a quick PSR-0 win.).
Comment #6
andremolnar CreditAttribution: andremolnar commentedI had second thoughts (felt icky) about extending a class from one namespace in an entirely different one.
Asked Crell quickly in IRC and now moving SchemaCache into the Utilities namespace (since it extends the DrupalCacheArray).
Comment #7
amateescu CreditAttribution: amateescu commentedMissing @file doc block: http://drupal.org/node/1354#files
Also, missing blank line between the namespace declaration and the use statement, and I think we decided against using "\" in front of class names.
For inspiration, you can take a look at a class that has already been converted, like http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/core/lib/D...
I think we need to drop 'Drupal' and rename to CacheArray.
Meh :)
Comment #8
andremolnar CreditAttribution: andremolnar commentedRe-rolling with suggested fixes from #7.
I also think dropping Drupal from the class name is a good idea / sensible since Drupal classes are namespaced Drupal\ anyway.
Comment #8.0
andremolnar CreditAttribution: andremolnar commentedUpdated motivation for the issue.
Comment #9
andremolnar CreditAttribution: andremolnar commentedComment #10
catchThis looks good to me now. I think we'll eventually want to move the schema cache stuff into the schema namespace, but that can wait on having actual code existing there.
There's not really a problem extending classes in different namespaces as far as I'm concerned - it just shows the various dependencies for what they are.
Comment #11
Crell CreditAttribution: Crell commentedI think we're using singular namespaces, not plural, so it should be Drupal\Core\Utility, not Drupal\Core\Utilities. Other than that, this looks done.
Partially agreed with catch. Inheriting from an out-of-namespace class isn't a bad thing. However, if you're inheriting back and forth like a madman between two namespaces, it is a code smell that maybe they should be the same namespace/package.
Either way, fix the pluralization here and I think we're good to go.
Comment #12
andremolnar CreditAttribution: andremolnar commentedRenamed Utilities to Utility. If testbot comes back green I'll take the liberty of RTBCing this.
Comment #13
andremolnar CreditAttribution: andremolnar commentedComment #14
Crell CreditAttribution: Crell commentedAnd I second that.
Comment #15
catchCommitted/pushed to 8.x, thanks!
Comment #16.0
(not verified) CreditAttribution: commentedUpdating issue based on latest information in the thread and to reflect the lastest patch.