Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error on invalid serializer. #431

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apc_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,9 @@ PHP_APCU_API zend_bool apc_cache_defense(apc_cache_t *cache, zend_string *key, t
PHP_APCU_API void apc_cache_serializer(apc_cache_t* cache, const char* name) {
if (cache && !cache->serializer) {
cache->serializer = apc_find_serializer(name);
if (strcmp(name, "default") != 0 && !cache->serializer) {
php_error_docref(NULL, E_WARNING, "apc_cache_serializer: serializer \"%s\" is not supported.", name);
}
}
} /* }}} */

Expand Down
12 changes: 12 additions & 0 deletions tests/serializer_invalid.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Serializer: invalid pattern.
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also skip if extension_loaded('igbinary');, since users may have installed and enabled igbinary before running this test

--INI--
apc.enabled=1
apc.enable_cli=1
apc.serializer=igbinary
--FILE--
<?php
--EXPECT--
Warning: Unknown: apc_cache_serializer: serializer "igbinary" is not supported. in Unknown on line 0
11 changes: 11 additions & 0 deletions tests/serializer_valid.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be redundant and the various other tests already assert this notice isn't emitted for valid serializers

Serializer: valid pattern.
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--INI--
apc.enabled=1
apc.enable_cli=1
apc.serializer=php
--FILE--
<?php
--EXPECT--