Cache: Now an empty namespace means disabling namespace support #2931

Closed
wants to merge 833 commits into from
@marc-mabe
Zend Framework member

Now an empty namespace means disabling namespace support

  • Namespace prefixes of empty namespaces are empty (no namespace separator)
  • Some optimisations on empty namespaces
  • Empty namespaces on "clearByNamespace" throws an InvalidArgumentException
  • Empty prefixes on "clearByPrefix" throws an InvalidArgumentException
  • Support for "clearByNamespace" on memory adapter

The xcache adapter will be updated soon on branch develop.

@marc-mabe
Zend Framework member

@ezimuel Could you test the WinCache adapter please

weierophinney and others added some commits Nov 13, 2012
@weierophinney weierophinney Merge branch 'hotfix/2888' into develop
Close #2888
ad8c278
@weierophinney weierophinney Merge branch 'hotfix/2837' into develop
Forward port #2837
75fcb76
@weierophinney weierophinney Merge branch 'master' of git://github.com/DaHaiz/zf2 into feature/2848
Conflicts:
	library/Zend/Form/View/Helper/FormCollection.php
ba3978a
@weierophinney weierophinney [#2848] Minor CS changes
- Aligning operators
- Assuring changes work with current develop branch
2849dae
@weierophinney weierophinney Merge branch 'feature/2848' into develop
Close #2848
a9477a1
@weierophinney weierophinney Merge branch 'feature/view-event-render-post' of git://github.com/Cle…
…mensSahs/zf2 into feature/2855
2a1d136
@weierophinney weierophinney [#2855] Added test for renderer.post event
- Added a test for the renderer.post event to ensure it gets triggered
8963bcc
@weierophinney weierophinney Merge branch 'feature/2855' into develop
Close #2855
f90e2fc
@weierophinney weierophinney Merge branch 'hotfix/2872' into develop
Forward port #2872
104469a
@weierophinney weierophinney Merge branch 'master' of git://github.com/JEDIBC/zf2 into feature/2875 516dcbb
@weierophinney weierophinney [#2875] Added UnknownInputsCapableInterface
- Provides hasUnknown and getUnknown
- BaseInputFilter now implements this additional interface
6d27dd6
@weierophinney weierophinney Merge branch 'feature/2875' into develop
Close #2875
43e3519
@blanchonvincent blanchonvincent Fix word "identifier" aab5188
@weierophinney weierophinney [#2964] Retrieve application events before triggering
- The block that handled exceptions in DefaultRenderingStrategy was
  calling trigger() on the event object -- clearly a problem. Code has
  been modified to retrieve the event manager from the application
  object composed in the event, and trigger from there.
- Additionally, a potential infinite loop was removed (the render event
  was getting triggered a second time from within the catch clause)
- Tests added to ensure that the render.error event is now properly
  triggered.
c111713
@Maks3w Maks3w Merge pull request #2965 from weierophinney/hotfix/2964
[#2964] Retrieve application events before triggering
28056e7
@Maks3w
Zend Framework member

I guess this involve a BC Break due change in the meaning of empty namespace

@marc-mabe
Zend Framework member

@Maks3w
This PR only effects adapters supporting namespaces by prefix (using namespace_separator to separate between namespace and key). It simply changes the way how the internal key will be generated if the namespace is empty -> This effects the internal storage key only.

The only that has been changed for public is that clearByNamespace and clearByPrefix throws an InvalidArgumentException now. But if you don't do that you could run into dangerous mistakes flushing the whole storage instead of only cleaning items of an empty namespace.

The main issue with keys of <namespace><separator><key> it's incompatible with others access such items and if namespace support isn't required it's much overhead handling it with only a separator as prefix.

In the case of the ZendServer* adapters empty namespaces are not supported and resulted in an error (no namespace or a non empty namespace)

Maks3w and others added some commits Nov 14, 2012
@Maks3w Maks3w Forward port #2941
Conflicts:
	library/Zend/File/Transfer/Adapter/AbstractAdapter.php
	library/Zend/Validator/File/ExcludeExtension.php
	library/Zend/Validator/File/ImageSize.php
	library/Zend/Validator/File/NotExists.php
1171669
@Maks3w Maks3w Forward port #2929 8a1305b
@Maks3w Maks3w Forward port #2960 d43b9f3
@Maks3w Maks3w Merge pull request #2914 from stefankleff/hotfix/logger-service-factory
LoggerServiceFactory does not return a logger
b597dd8
@Maks3w Maks3w Forward port #2940 55c7cba
@Maks3w Maks3w Forward port #2921 14fbade
@Maks3w Maks3w Forward port #2905 abe22b8
@Maks3w Maks3w Forward port #2904 a07bdd9
@Maks3w Maks3w Forward port #2901 835da90
@Maks3w Maks3w Forward port #2893 be2556f
@Maks3w Maks3w Merge pull request #2892 from jmikola/patch-2
Revise MongoDB session save handler's gc() docs
79a77f3
@Maks3w Maks3w Forward port #2877 a5632a4
@akrabat akrabat Merge branch 'hotfix/2670' into develop
Forward port #2670
8943900
@Maks3w Maks3w Merge pull request #2975 branch 'hotfix/adapt-classmapautoload-to-int…
…erface-constraint'
6f9402d
@Maks3w Maks3w Forward #2983 22df1aa
@Maks3w Maks3w Forward #2974 ca0f970
Maximilian Walter Zend\Mime\Part::getEncodedStream() did not use correct EOL (Issue #2918) c3bb7fd
@marc-mabe marc-mabe Cache: Added session storage adapter b4844a1
@marc-mabe marc-mabe Merge branch 'hotfix/session-container-exchangeArray' of github.com:m…
…arc-mabe/zf2 into feature/cache-session-storage
85cca66
@marc-mabe marc-mabe Merge branch 'develop' of git://github.com/zendframework/zf2 into fea…
…ture/cache-session-storage
8b7d65d
@Slamdunk Slamdunk Decoupled Zend\Db\Sql from concrete Adapters c518cc2
@Slamdunk Slamdunk Decoupled from Adapter the main Sql factory 389fd10
@marc-mabe marc-mabe Added note of new xcache storage adapter 7fa9175
@marc-mabe marc-mabe Added note of new session storage adapter eb515e6
@Maks3w Maks3w Merge pull request #2990 from marc-mabe/news/xcache
Added note of new xcache storage adapter
fb88bd5
@Maks3w Maks3w Merge pull request #2985 from maximilian-walter/develop
Zend\Mime\Part::getEncodedStream() did not use correct EOL (Issue #2918)
38e6d95
@weierophinney weierophinney Merge branch 'feature/dbsql-interfaces' of git://github.com/Slamdunk/…
…zf2 into hotfix/2989

Conflicts:
	library/Zend/Db/Sql/AbstractSql.php
	library/Zend/Db/Sql/Select.php
8571347
@weierophinney weierophinney Merge branch 'hotfix/2989' into develop
Close #2989
c1972c9
@weierophinney weierophinney Merge branch 'hotfix/2932' into develop
Forward port #2932
ce33449
@weierophinney weierophinney Merge branch 'feature/share-memcached' of git://github.com/marc-mabe/…
…zf2 into feature/memcached-improvements
5223e36
@weierophinney weierophinney Merge branch 'feature/memcached-improvements' into develop
Close #2876
8099772
@weierophinney weierophinney Merge branch 'hotfix/2878' into develop
Conflicts:
	library/Zend/File/Transfer/Adapter/AbstractAdapter.php
	library/Zend/File/Transfer/Adapter/Http.php
	tests/ZendTest/Log/Writer/AbstractTest.php
	tests/ZendTest/Log/Writer/DbTest.php
500c284
@weierophinney weierophinney Merge branch 'hotfix/2879' into develop
Forward port #2879
748468e
@weierophinney weierophinney Merge branch 'hotfix/2907' into develop
Forward port #2907
c45da93
@weierophinney weierophinney Merge branch 'hotfix/2909' into develop
Forward port #2909
c39cf61
@Maks3w Maks3w Forward port #2994 2428736
@Maks3w Maks3w Forward port #2997 7af2761
@pkarc pkarc Update library/Zend/Json/Server/Response.php 14a423e
@pkarc pkarc Update tests/ZendTest/Json/Server/ResponseTest.php cc54e92
Martin Meredith Add a bunch of traits to ZF2
As requested @

protecinnovations/zf2-traits#1

This is the initial commit to start getting traits into ZF2.

We need to move our tests over - which are currently using Mockery.
331151c
@alexdenvir alexdenvir Improve coding standards on new traits, add tests c568239
Martin Meredith Fix Minor problems with tests b0e0b89
@pkarc pkarc Update library/Zend/Json/Server/Response.php 022fa4c
@alexdenvir alexdenvir Improve function comment quality, clean up tests a little 8add698
@weierophinney weierophinney Merge branch 'hotfix/2924' into develop
Forward port #2924
8eeb1fc
@weierophinney weierophinney Merge branch 'hotfix/2930' into develop
Forward port #2930
247ec78
@weierophinney weierophinney commented on an outdated diff Nov 19, 2012
library/Zend/Cache/Storage/Adapter/Apc.php
@@ -139,9 +139,14 @@ public function getAvailableSpace()
*/
public function getIterator()
{
- $options = $this->getOptions();
- $prefix = $options->getNamespace() . $options->getNamespaceSeparator();
- $pattern = '/^' . preg_quote($prefix, '/') . '/';
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ $pattern = null;
+ } else {
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $pattern = '/^' . preg_quote($prefix, '/') . '/';
+ }
@weierophinney
Zend Framework member

Simplify the above to:

$pattern = null;
if ($namespace !== '') {
    /* set $prefix and $pattern */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney
Zend Framework member

Seeing a test failure in the Memory adapter:

There was 1 failure:

1) ZendTest\Cache\Storage\Adapter\MemoryTest::testGetTotalSpace
Failed asserting that 0 is greater than 0.

tests/ZendTest/Cache/Storage/Adapter/CommonAdapterTest.php:1076

I get this consistently as well - it's not a transient failure. Can you look into it, please?

Otherwise, seems sane for 2.1.0.

weierophinney and others added some commits Nov 19, 2012
@weierophinney weierophinney Merge branch 'hotfix/2957' into develop
Forward port #2957
2e7d402
@weierophinney weierophinney Merge branch 'hotfix/2976' into develop
Forward port #2976
a4a69e6
@weierophinney weierophinney Merge branch 'hotfix/2981' into develop
Forward port #2981
0dcd8df
@weierophinney weierophinney Merge branch 'hotfix/2986' into develop
Conflicts:
	library/Zend/Code/Scanner/PropertyScanner.php
9670eb0
@weierophinney weierophinney Merge branch 'hotfix/2987' into develop
Forward port #2987
577c6c5
@weierophinney weierophinney Merge branch 'hotfix/3002' into develop
Forward port #3002
bf15465
@weierophinney weierophinney Merge branch 'hotfix/3003' into develop
Forward port #3003
ec46781
@weierophinney weierophinney Merge branch 'hotfix/3006' into develop
Forward port #3006
7d0c5e9
@weierophinney weierophinney Merge branch 'hotfix/3008' into develop
Forward port #3008
cb5a3b4
@weierophinney weierophinney Merge branch 'hotfix/3009' into develop
Forward port #3009
713491b
@weierophinney weierophinney Merge branch 'develop' of git://github.com/pkarc/zf2 into hotfix/3011 bbda405
@weierophinney weierophinney [#3011] CS fixes
- trailing whitespace
56fce75
@weierophinney weierophinney Merge branch 'hotfix/3011' into develop
Close #3011
19a1bac
@weierophinney weierophinney Merge branch 'fix/prg-plugins' of git://github.com/cgmartin/zf2 into …
…hotfix/3016
91b6850
@weierophinney weierophinney Merge branch 'hotfix/3016' into develop
Close #3016
aee25b5
@weierophinney weierophinney Merge branch 'hotfix/3013' into develop
Forward port #3013
f671feb
@weierophinney weierophinney Check that service locator exists
- before attempting to pull something from it
213381c
@weierophinney weierophinney Fix CS issues
- EOF endings
9c4c04c
@weierophinney weierophinney Merge branch 'hotfix/service-locator-existence' into develop
Fix failing tests and CS issues on develop branch
7c4f2f9
@cgmartin cgmartin PRG Plugins fix - Lost data if expiration hops set after data is set 52c0ff1
@alexdenvir alexdenvir Remove SharedEventManagerAwareTrait and ServiceManagerAwareTrait, and…
… associated tests
2ffed1f
@alexdenvir alexdenvir Make EventManagerAwareTrait use ProvidesEvents 0cf7a33
@weierophinney weierophinney Merge branch 'feature/traits' of git://github.com/protecinnovations/z…
…f2 into feature/2927
eb4cd51
@weierophinney
Zend Framework member

@marc-mabe I get the same result with either memory_limit -1 or 128M.

Also, with this in place, I get two new errors with the XCache adapter: testClearByPrefixThrowsInvalidArgumentExceptionOnEmptyPrefix and testClearByNamespaceThrowsInvalidArgumentExceptionOnEmptyNamespace both fail, as neither trigger the exception indicated.

@marc-mabe
Zend Framework member

This PR is based an master, for the XCache adapter there is another PR #3069 that fixes it.

I don't know why you get an error on testGetTotalSpace - I'll review it and create a new PR for 2.1 develop hopefully this week (no fix for 2.0 than).

weierophinney and others added some commits Dec 10, 2012
@weierophinney weierophinney Merge branch 'hotfix/3052' into develop
Forward port #3052
e9c2914
@weierophinney weierophinney Merge branch 'feature-cache-service-factory' of git://github.com/blan…
…chonvincent/zf2 into feature/cache-storage-factory
a5ddd7a
@weierophinney weierophinney Merge branch 'feature/cache-storage-factory' into develop
Close #3056
75d68fd
@weierophinney weierophinney Merge branch 'pull-zend-filter-compress-snappy' of git://github.com/g…
…oatherd/zf2 into feature/filter-compress-snappy
b353255
@weierophinney weierophinney Merge branch 'feature/filter-compress-snappy' into develop
Close #3057
c2a89e4
@weierophinney weierophinney Merge branch 'fix/upload-progress' of git://github.com/cgmartin/zf2 i…
…nto feature/form-upload-progress
0d89b4f
@weierophinney weierophinney Merge branch 'feature/form-upload-progress' into develop
Close #3058
33dc18a
@weierophinney weierophinney Merge branch 'fix/add-chromephp-in-writerpluginmanager' of git://gith…
…ub.com/epokmedia/zf2 into hotfix/3059
162ccb2
@weierophinney weierophinney Merge branch 'hotfix/3059' into develop
Close #3059
dfc32b2
@weierophinney weierophinney Merge branch 'hotfix/3061' into develop
Forward port #3061
ec8498a
@weierophinney weierophinney Merge branch 'hotfix/xcache-empty-namespace' of git://github.com/marc…
…-mabe/zf2 into hotfix/3069
79088fa
@weierophinney weierophinney Merge branch 'hotfix/3069' into develop
Close #3069
97c729b
@weierophinney weierophinney Merge branch 'hotfix/3070' into develop
Forward port #3070
ccb2165
@weierophinney weierophinney Merge branch 'hotfix/3077' into develop
Forward port #3077
afb3052
@weierophinney weierophinney Merge branch 'feature/ImplementArrayAccessOnNodeList' of git://github…
….com/BlaineSch/zf2 into feature/dom-nodelist-access
6dcd2d3
@weierophinney weierophinney [#3078] fix failing tests in 5.4.5
- DOMXPath::query() no longer raises an exception on failure; it now
  raises an E_WARNING. Updated code to detect an E_WARNING and raise an
  exception when discovered.
a65ce08
@weierophinney weierophinney Merge branch 'feature/dom-nodelist-access' into develop
Close #3078
f40c4f5
@cgmartin cgmartin FileInput AJAX post fix 62d2845
@RalfEggert RalfEggert Added ValidatorChain::attach() and ValidatorChain::attachByName() to …
…keep consistent with FilterChain

ValidatorChain::addValidator() proxies to ValidatorChain::attach()
ValidatorChain::addByName() proxies to ValidatorChain::attachByName()
d39307a
@weierophinney weierophinney Merge branch 'improvement/shevm-listeners2' of git://github.com/stefa…
…nkleff/zf2 into feature/events-shared-aggregates
f9e1c76
@weierophinney weierophinney [#3084] Split new interface methods into separate interface
- To prevent a BC break (uncovered by running the unit tests), moved new
  attachAggregate() and detachAggregate() methods into a separate interface; the
  SharedEventManager implementation now also implements this new interface.
0482078
@weierophinney weierophinney Merge branch 'feature/events-shared-aggregates' into develop
Close #3084
38a33e6
@weierophinney weierophinney Merge branch 'improvement/logger-factory-writer' of git://github.com/…
…stefankleff/zf2 into feature/logger-constructor-options
68f0fc2
@weierophinney weierophinney Merge branch 'feature/logger-constructor-options' into develop
Close #3086
3a684b6
@weierophinney weierophinney Merge branch 'hotfix/3091' into develop
Forward port #3091
36a4c07
@weierophinney weierophinney Merge branch 'feature/cookies-refactor' of git://github.com/jcrawford…
…/zf2 into hotfix/3093

Conflicts:
	tests/ZendTest/Http/ClientTest.php
a96d872
@weierophinney weierophinney Merge branch 'hotfix/3093' into develop
Close #3093
Fixes #2572
1862af4
@weierophinney weierophinney Merge branch 'updates' of git://github.com/Hounddog/zf2 into feature/…
…template-map-generator
88ec212
@jessiehernandez jessiehernandez Added NTLM authentication support to Zend\Soap\Client\DotNet. 7f03bec
@weierophinney weierophinney [#3106] Cleanup
- Was raising an exception of "view" directory did not exist; modified
  to show error message + usage message
- Removed import for ClassFileLocator
- Changed references from "classmap" to simply "map"
- Changed references from "autoload" to "map"
bed4469
@weierophinney weierophinney Merge branch 'feature/template-map-generator' into develop
Close #3106
8c0dd52
@weierophinney weierophinney Merge branch 'hotfix/3114' into develop
Forward port #3114
549bc06
@weierophinney weierophinney Merge branch 'hotfix/3126' into develop
Forward port #3126
816b27e
@weierophinney weierophinney Merge branch 'hotfix/3127' into develop
Forward port #3127

Conflicts:
	library/Zend/Cache/Storage/Adapter/Memcached.php
	library/Zend/Cache/Storage/Adapter/MemcachedOptions.php
5cc7edc
@weierophinney weierophinney Merge branch 'hotfix/3148' into develop
Forward port #3148

Conflicts:
	tests/ZendTest/Http/ClientTest.php
06b4cfd
@weierophinney weierophinney Merge branch 'hotfix/3149' into develop
Forward port #3149
5052ff2
@weierophinney weierophinney Merge branch 'hotfix/3159' into develop
Forward port #3159
c923b9b
@weierophinney weierophinney Merge branch 'hotfix/3155' into develop
Forward port #3155
2137bbf
@weierophinney weierophinney Merge branch 'hotfix/3156' into develop
Forward port #3156
56e61bd
@weierophinney weierophinney Merge branch 'hotfix/3164' into develop
Forward port #3164
5c27e8e
@weierophinney weierophinney Merge branch 'hotfix/3167' into develop
Forward port #3167
2888753
@weierophinney weierophinney Merge branch 'hotfix/3169' into develop
Forward port #3169
c8372d4
@weierophinney weierophinney Merge branch 'hotfix/3170' into develop
Forward port #3170
c0408fc
@weierophinney weierophinney Merge branch 'hotfix/3171' into develop
Forward port #3171
8711f05
@weierophinney weierophinney Merge branch 'hotfix/3178' into develop
Forward port #3178
8d6c7b5
@weierophinney weierophinney Merge branch 'hotfix/3184' into develop
Forward port #3184
177846d
@weierophinney weierophinney Merge branch 'hotfix/3186' into develop
Forward port #3186
497899b
@weierophinney weierophinney Merge branch 'hotfix/3187' into develop
Forward port #3187
c977b25
@weierophinney weierophinney Merge branch 'hotfix/3194' into develop
Forward port #3194
5a2726c
@weierophinney weierophinney Merge branch 'hotfix/3144' into develop
Forward port #3144
38a4b42
@weierophinney weierophinney Merge branch 'hotfix/3197' into develop
Forward port #3197
36f9b6b
@weierophinney weierophinney Merge branch 'fix/file-upload-ajax' of git://github.com/cgmartin/zf2 …
…into hotfix/3199
41bac39
@weierophinney weierophinney Merge branch 'hotfix/3199' into develop
Close #3199
e347ee1
@weierophinney weierophinney Merge branch 'master' of git://github.com/RalfEggert/zf2 into feature…
…/3200
210b4ff
@jessiehernandez jessiehernandez Deleted leftover coding standards doc comments. 9af3b30
@weierophinney weierophinney [#3200] Added @deprecated annotations 5618743
@weierophinney weierophinney [#3200] Update components to use new validator chain methods
- s/addValidator/attach/
- s/addByName/attachByName/
a1d8d95
@weierophinney weierophinney Merge branch 'feature/3200' into develop
Close #3200
a347c47
@weierophinney weierophinney Merge branch 'hotfix/3201' into develop
Forward port #3201
d0b9231
@weierophinney weierophinney Merge branch 'soap-dotnet-ntlm' of git://github.com/jrhernandez84/zf2…
… into feature/soap-ntlm-auth
bec7072
@weierophinney weierophinney [#3202] CS
- Moved call_user_func override into separate file
- Moved MockCallUserFunc class into separate class file
- Passes php-cs-fixer, and tests run
3434dae
@weierophinney weierophinney Merge branch 'feature/soap-ntlm-auth' into develop
Close #3202
0c9832a
@jessiehernandez

Sorry for this, this is a leftover from the namespace of my company. Should be \Zend\Soap\Client\DotNet

Zend Framework member

Please send us a patch with the fix

weierophinney added some commits Dec 11, 2012
@weierophinney weierophinney Merge branch 'form/remove-attribute' of git://github.com/bakura10/zf2…
… into feature/form-element-removal
2e97e70
@weierophinney weierophinney [#2841] separated interfaces
- Moved attribute removal methods to new interface,
  ElementAttributeRemovalInterface
- Updated Element to implement ElementAttributeRemovalInterface
948eb05
@weierophinney weierophinney Merge branch 'feature/form-element-removal' into develop
Close #2841
bfaa27f
@weierophinney
Zend Framework member

@marc-mabe -- since merging #3069, the two XCache issues go away. Now I have SessionTest::testClearByPrefixThrowsInvalidArgumentExceptionOnEmptyPrefix indicating that the exception expected is not thrown. (This is against develop.)

I'm ignoring the "testGetTotalSpace" error for now, as travis is clearly not encountering the same issue; it's likely specific to my environment.

If you can address the Session storage issue, though, that would be great.

@marc-mabe
Zend Framework member

closed! Will create a new PR on branch develop

@marc-mabe marc-mabe closed this Dec 13, 2012
@eimanavicius

merge of _POST and _FILES leads to vulnerability. Because I can post data structure as in _FILE array and set tmp_name to file path I want to.
Also this type of merge do not support file uploads when file is under additional keywords for example:

$postOther = Array(
    [business] => Array(
        [name] => BigCompany
    )
);
$postFiles = Array(
    [business] => Array(
        [logo] => Array(
            [name] => 400.png
            [type] => image/png
            [tmp_name] => /tmp/php5Wx0aJ
            [error] => 0
            [size] => 15726
        )
    )
);

after array_merge we have same as in $postFiles and loosing 'name' value

That recursive merge issue is definitely a problem, thanks for catching that. I'll make a fix and add some unit tests.

Not sure I understand about the vulnerability you mention, since you can spoof $_FILES information in the request regardless. The Zend\Validator\File\Upload helps to validate file information by doing a is_uploaded_file. This validator gets added by default when adding file inputs to a form.

Sorry, didn't saw Upload Validator contents.

Zend Framework member

Please send any security observation to zf-security@zend.com

@weierophinney
Zend Framework member

@Maks3w this is in unreleased code; the discussion can continue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment