[TYPO3-core] RFC: #11438: Add a registry to t3lib

Bastian Waidelich bastian at typo3.org
Mon Aug 10 20:58:41 CEST 2009


Ingo Renner wrote:

Hi Ingo & all,

> For certain purposes it'd be nice to have a place to store key, value 
> pairs.

As I said, I think it's a useful feature but my opinion is:

1. The registry should be usable from extensions too
2. If 1 is true, we need a "namespaced" registry
3. If 2 is true, this should be well implemented not by some special 
syntax like "prefix.key"
4. We should expect, that people are using this. So loading all possible 
values (even from inactive extensions) into memory in the constructor 
seems to be unthrifty

Attached is a modified version of your patch that incorporates following 
changes:

- Namespaced records. added namespace-argument to get(), set() and remove()
- Given namespace will be validated for each of these methods to avoid 
"silent errors" for spelling mistakes
- Records won't be fetched in the constructor anymore
- get() lazy-loads all values of the given namespace as soon as you 
access it the first time.
- added method removeAll() to delete all values for a given namespace

Additionally I've fixed a bug that occured due to the fact that 
$GLOBALS['TYPO3_DB']->sql_affected_rows() returns 0 when the value has 
not been changed leading to a "duplicate entry" SQL error when calling 
set twice with the same parameters.

I've adapted the test case by using a mock of t3lib_db in order to avoid 
side-effects.

Two changes I weren't sure about:
1. I've added a "@return void" to methods that do not return anything
2. I've removed the @author tags from the unit tests

Bastian
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 11438_v3.diff
Url: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090810/07e086d6/attachment.txt 


More information about the TYPO3-team-core mailing list