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

Conversation

zeriyoshi
Copy link

APCu works with the default serializer, even if the value set in apc.serializer is invalid.

But, this is unfriendly if you are using a third party serializer such as igbinary. For example, if igbinary is installed before APCu is installed, igbinary will not support APCu. The current behavior of working with the default serializer without warning may produce unintended behavior.

This fix changes it to give an E_WARNING equivalent warning if an unavailable serializer is specified.

- Raise error on invalid serializer.

Co-authored-by: Go Kudo <[email protected]>
apc_cache.c Outdated Show resolved Hide resolved
zeriyoshi and others added 2 commits February 1, 2022 09:53
thanks @nikic

Co-authored-by: Nikita Popov <[email protected]>
@@ -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

--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

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a maintainer but I'm somewhat familiar with the codebase

not supported or not enabled, maybe. There's also the question of whether it should fall back to the "php" serializer instead, given that the actual default ini value is "php" (see linked ticket)

Copy link
Author

Choose a reason for hiding this comment

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

Indeed. The current behavior is complicated and cannot be understood without following the implementation. Also, the situation where the fallback behavior that occurs when it is not present and the flow when php is explicitly specified are separated is probably not desirable.

I have added a comment to your Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants