├── tests
├── skipif.inc
├── apc_inc_gh14.phpt
├── apc_clear_cache.phpt
├── apc_001.phpt
├── apc_cache_info.phpt
├── apc_incdec.phpt
├── iterator_008_bc.phpt
└── iterator_005_bc.phpt
├── config.w32
├── config.m4
├── composer.json
├── README.md
├── .travis.yml
├── .gitignore
├── php_apc.h
├── LICENSE
├── package.xml
└── php_apc.c
/tests/skipif.inc:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/config.w32:
--------------------------------------------------------------------------------
1 | // $Id$
2 | // vim:ft=javascript
3 |
4 | ARG_ENABLE("apc", "enable APCu BC support", "no");
5 |
6 | if (PHP_APC != "no") {
7 | EXTENSION("apc", "php_apc.c", PHP_APC_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
8 | ADD_EXTENSION_DEP("apc", "apcu", true);
9 | }
10 |
11 |
12 |
--------------------------------------------------------------------------------
/tests/apc_inc_gh14.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: apc_inc segfaults if APCU is disabled
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=0
7 | apc.enable_cli=0
8 | --FILE--
9 |
12 | ===DONE===
13 | --EXPECTF--
14 | bool(false)
15 | ===DONE===
16 |
--------------------------------------------------------------------------------
/config.m4:
--------------------------------------------------------------------------------
1 | dnl $Id$
2 | dnl config.m4 for apcu-bc extension
3 |
4 | PHP_ARG_ENABLE(apc, whether to enable APCu BC support,
5 | [ --enable-apc Enable APCu BC support])
6 |
7 | if test "$PHP_APC" != "no"; then
8 | PHP_NEW_EXTENSION(apc, php_apc.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
9 | PHP_ADD_EXTENSION_DEP(apc, apcu)
10 | fi
11 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "apcu_bc",
3 | "type": "extension",
4 | "license": [
5 | "PHP License"
6 | ],
7 | "require": {
8 | "php": ">=7.0.0",
9 | "ext-apcu": "~5.1"
10 | },
11 | "authors": [
12 | {
13 | "name": "Joe Watkins",
14 | "email": "krakjoe@php.net"
15 | },
16 | {
17 | "name": "Remi Collet",
18 | "email": "remi@php.net"
19 | }
20 | ],
21 | "description": "APCu Backwards Compatibility Module"
22 | }
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | APCu Backwards Compatibility Module
2 | ===============================
3 |
4 | [](https://travis-ci.org/krakjoe/apcu-bc)
5 |
6 | This module provides a backwards APC compatible API using [APCu](https://github.com/krakjoe/apcu).
7 |
8 | Performance
9 | ===========
10 |
11 | There is no appreciable difference; This layer calls the same internal (to apc) functions that APCu does, but just accepts the old parameters, the only meaningful difference is prototypes and names of functions.
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | sudo: required
3 |
4 | php:
5 | - 7.0
6 | - 7.1
7 | - nightly
8 |
9 | before_script:
10 | - git clone https://github.com/krakjoe/apcu --depth 1
11 | - cd apcu
12 | - phpize
13 | - ./configure
14 | - make
15 | - sudo make install
16 | - cd ../
17 |
18 | script:
19 | - phpize
20 | - ./configure
21 | - make
22 | - sudo make install
23 | - REPORT_EXIT_STATUS=1 php -n run-tests.php -q -n -d extension=apcu.so -d extension=apc.so -d apc.enable=1 -d apc.enable_cli=1 -p `phpenv which php` --show-diff --set-timeout 120
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .deps
2 | .libs/
3 | Makefile
4 | Makefile.fragments
5 | Makefile.global
6 | Makefile.objects
7 | acinclude.m4
8 | aclocal.m4
9 | apc.la
10 | autom4te.cache/
11 | build/
12 | config.guess
13 | config.h
14 | config.h.in
15 | config.h.in~
16 | config.log
17 | config.nice
18 | config.status
19 | config.sub
20 | configure
21 | configure.in
22 | configure.ac
23 | install-sh
24 | libtool
25 | ltmain.sh
26 | ltmain.sh.backup
27 | missing
28 | mkinstalldirs
29 | modules/
30 | php_apc.lo
31 | run-tests.php
32 | run-tests.sh
33 | tmp-php.ini
34 | tests/*.diff
35 | tests/*.exp
36 | tests/*.log
37 | tests/*.out
38 | tests/*.php
39 | tests/*.sh
40 | apcu_bc-*.tgz
41 |
--------------------------------------------------------------------------------
/tests/apc_clear_cache.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: apc_clear_cache
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | apc.file_update_protection=0
9 | --FILE--
10 |
19 | ===DONE===
20 |
21 | --EXPECTF--
22 | string(11) "hello world"
23 | string(11) "hello world"
24 | bool(false)
25 | ===DONE===
26 |
--------------------------------------------------------------------------------
/tests/apc_001.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: apc_store/fetch with strings
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | apc.file_update_protection=0
9 | --FILE--
10 |
24 | ===DONE===
25 |
26 | --EXPECTF--
27 | string(11) "hello world"
28 | string(11) "hello world"
29 | string(4) "nice"
30 | string(11) "hello world"
31 | ===DONE===
32 |
--------------------------------------------------------------------------------
/tests/apc_cache_info.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: apc_clear_cache
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | apc.file_update_protection=0
9 | --FILE--
10 |
21 | ===DONE===
22 |
23 | --EXPECTF--
24 | NULL
25 | array(10) {
26 | ["num_slots"]=>
27 | int(%d)
28 | ["ttl"]=>
29 | int(%d)
30 | ["num_hits"]=>
31 | float(3)
32 | ["num_misses"]=>
33 | float(2)
34 | ["num_inserts"]=>
35 | float(1)
36 | ["num_entries"]=>
37 | int(1)
38 | ["expunges"]=>
39 | float(0)
40 | ["start_time"]=>
41 | int(%d)
42 | ["mem_size"]=>
43 | float(%d)
44 | ["memory_type"]=>
45 | string(%d) "%s"
46 | }
47 | ===DONE===
48 |
--------------------------------------------------------------------------------
/tests/apc_incdec.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: apc_inc / apc_dec
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | apc.file_update_protection=0
9 | --FILE--
10 |
28 | ===DONE===
29 | --EXPECTF--
30 | * Key not set
31 | bool(false)
32 | bool(false)
33 | bool(false)
34 | bool(false)
35 | bool(false)
36 | bool(false)
37 | * Set the key
38 | bool(true)
39 | * Key set
40 | int(101)
41 | int(103)
42 | bool(true)
43 | int(102)
44 | int(99)
45 | bool(true)
46 | ===DONE===
47 |
--------------------------------------------------------------------------------
/php_apc.h:
--------------------------------------------------------------------------------
1 | /*
2 | +----------------------------------------------------------------------+
3 | | APC |
4 | +----------------------------------------------------------------------+
5 | | Copyright (c) 2015-2019 The PHP Group |
6 | +----------------------------------------------------------------------+
7 | | This source file is subject to version 3.01 of the PHP license, |
8 | | that is bundled with this package in the file LICENSE, and is |
9 | | available through the world-wide-web at the following url: |
10 | | http://www.php.net/license/3_01.txt |
11 | | If you did not receive a copy of the PHP license and are unable to |
12 | | obtain it through the world-wide-web, please send a note to |
13 | | license@php.net so we can mail you a copy immediately. |
14 | +----------------------------------------------------------------------+
15 | | Authors: krakjoe |
16 | +----------------------------------------------------------------------+
17 | */
18 |
19 | #ifndef PHP_APC_H
20 | #define PHP_APC_H
21 |
22 | #define PHP_APC_EXTNAME "apc"
23 | #define PHP_APCU_BC_VERSION "1.0.5"
24 | #define PHP_APC_VERSION PHP_APCU_BC_VERSION
25 |
26 | extern zend_module_entry apc_module_entry;
27 | #define apc_module_ptr &apc_module_entry
28 |
29 | #define phpext_apc_ptr apc_module_ptr
30 |
31 | #if defined(ZTS) && defined(COMPILE_DL_APC)
32 | ZEND_TSRMLS_CACHE_EXTERN();
33 | #endif
34 |
35 | #endif /* PHP_APC_H */
36 |
37 | /*
38 | * Local variables:
39 | * tab-width: 4
40 | * c-basic-offset: 4
41 | * End:
42 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
43 | * vim<600: expandtab sw=4 ts=4 sts=4
44 | */
45 |
--------------------------------------------------------------------------------
/tests/iterator_008_bc.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: APCIterator general
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | --FILE--
9 | $value) {
17 | $keys[$key] = $value['key'];
18 | }
19 | ksort($keys);
20 | var_dump($keys);
21 | ?>
22 | ===DONE===
23 |
24 | --EXPECT--
25 | array(41) {
26 | ["key0"]=>
27 | string(4) "key0"
28 | ["key1"]=>
29 | string(4) "key1"
30 | ["key10"]=>
31 | string(5) "key10"
32 | ["key11"]=>
33 | string(5) "key11"
34 | ["key12"]=>
35 | string(5) "key12"
36 | ["key13"]=>
37 | string(5) "key13"
38 | ["key14"]=>
39 | string(5) "key14"
40 | ["key15"]=>
41 | string(5) "key15"
42 | ["key16"]=>
43 | string(5) "key16"
44 | ["key17"]=>
45 | string(5) "key17"
46 | ["key18"]=>
47 | string(5) "key18"
48 | ["key19"]=>
49 | string(5) "key19"
50 | ["key2"]=>
51 | string(4) "key2"
52 | ["key20"]=>
53 | string(5) "key20"
54 | ["key21"]=>
55 | string(5) "key21"
56 | ["key22"]=>
57 | string(5) "key22"
58 | ["key23"]=>
59 | string(5) "key23"
60 | ["key24"]=>
61 | string(5) "key24"
62 | ["key25"]=>
63 | string(5) "key25"
64 | ["key26"]=>
65 | string(5) "key26"
66 | ["key27"]=>
67 | string(5) "key27"
68 | ["key28"]=>
69 | string(5) "key28"
70 | ["key29"]=>
71 | string(5) "key29"
72 | ["key3"]=>
73 | string(4) "key3"
74 | ["key30"]=>
75 | string(5) "key30"
76 | ["key31"]=>
77 | string(5) "key31"
78 | ["key32"]=>
79 | string(5) "key32"
80 | ["key33"]=>
81 | string(5) "key33"
82 | ["key34"]=>
83 | string(5) "key34"
84 | ["key35"]=>
85 | string(5) "key35"
86 | ["key36"]=>
87 | string(5) "key36"
88 | ["key37"]=>
89 | string(5) "key37"
90 | ["key38"]=>
91 | string(5) "key38"
92 | ["key39"]=>
93 | string(5) "key39"
94 | ["key4"]=>
95 | string(4) "key4"
96 | ["key40"]=>
97 | string(5) "key40"
98 | ["key5"]=>
99 | string(4) "key5"
100 | ["key6"]=>
101 | string(4) "key6"
102 | ["key7"]=>
103 | string(4) "key7"
104 | ["key8"]=>
105 | string(4) "key8"
106 | ["key9"]=>
107 | string(4) "key9"
108 | }
109 | ===DONE===
110 |
--------------------------------------------------------------------------------
/tests/iterator_005_bc.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | APC compat: APCIterator delete
3 | --SKIPIF--
4 |
5 | --INI--
6 | apc.enabled=1
7 | apc.enable_cli=1
8 | --FILE--
9 | $value) {
19 | $vals[$key] = $value['key'];
20 | }
21 | foreach($it2 as $key=>$value) {
22 | $vals2[$key] = $value['key'];
23 | }
24 | ksort($vals2);
25 | var_dump($vals);
26 | var_dump($vals2);
27 |
28 | ?>
29 | ===DONE===
30 |
31 | --EXPECT--
32 | array(0) {
33 | }
34 | array(37) {
35 | ["key0"]=>
36 | string(4) "key0"
37 | ["key1"]=>
38 | string(4) "key1"
39 | ["key11"]=>
40 | string(5) "key11"
41 | ["key12"]=>
42 | string(5) "key12"
43 | ["key13"]=>
44 | string(5) "key13"
45 | ["key14"]=>
46 | string(5) "key14"
47 | ["key15"]=>
48 | string(5) "key15"
49 | ["key16"]=>
50 | string(5) "key16"
51 | ["key17"]=>
52 | string(5) "key17"
53 | ["key18"]=>
54 | string(5) "key18"
55 | ["key19"]=>
56 | string(5) "key19"
57 | ["key2"]=>
58 | string(4) "key2"
59 | ["key21"]=>
60 | string(5) "key21"
61 | ["key22"]=>
62 | string(5) "key22"
63 | ["key23"]=>
64 | string(5) "key23"
65 | ["key24"]=>
66 | string(5) "key24"
67 | ["key25"]=>
68 | string(5) "key25"
69 | ["key26"]=>
70 | string(5) "key26"
71 | ["key27"]=>
72 | string(5) "key27"
73 | ["key28"]=>
74 | string(5) "key28"
75 | ["key29"]=>
76 | string(5) "key29"
77 | ["key3"]=>
78 | string(4) "key3"
79 | ["key31"]=>
80 | string(5) "key31"
81 | ["key32"]=>
82 | string(5) "key32"
83 | ["key33"]=>
84 | string(5) "key33"
85 | ["key34"]=>
86 | string(5) "key34"
87 | ["key35"]=>
88 | string(5) "key35"
89 | ["key36"]=>
90 | string(5) "key36"
91 | ["key37"]=>
92 | string(5) "key37"
93 | ["key38"]=>
94 | string(5) "key38"
95 | ["key39"]=>
96 | string(5) "key39"
97 | ["key4"]=>
98 | string(4) "key4"
99 | ["key5"]=>
100 | string(4) "key5"
101 | ["key6"]=>
102 | string(4) "key6"
103 | ["key7"]=>
104 | string(4) "key7"
105 | ["key8"]=>
106 | string(4) "key8"
107 | ["key9"]=>
108 | string(4) "key9"
109 | }
110 | ===DONE===
111 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | --------------------------------------------------------------------
2 | The PHP License, version 3.01
3 | Copyright (c) 1999 - 2014 The PHP Group. All rights reserved.
4 | --------------------------------------------------------------------
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, is permitted provided that the following conditions
8 | are met:
9 |
10 | 1. Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 |
13 | 2. Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in
15 | the documentation and/or other materials provided with the
16 | distribution.
17 |
18 | 3. The name "PHP" must not be used to endorse or promote products
19 | derived from this software without prior written permission. For
20 | written permission, please contact group@php.net.
21 |
22 | 4. Products derived from this software may not be called "PHP", nor
23 | may "PHP" appear in their name, without prior written permission
24 | from group@php.net. You may indicate that your software works in
25 | conjunction with PHP by saying "Foo for PHP" instead of calling
26 | it "PHP Foo" or "phpfoo"
27 |
28 | 5. The PHP Group may publish revised and/or new versions of the
29 | license from time to time. Each version will be given a
30 | distinguishing version number.
31 | Once covered code has been published under a particular version
32 | of the license, you may always continue to use it under the terms
33 | of that version. You may also choose to use such covered code
34 | under the terms of any subsequent version of the license
35 | published by the PHP Group. No one other than the PHP Group has
36 | the right to modify the terms applicable to covered code created
37 | under this License.
38 |
39 | 6. Redistributions of any form whatsoever must retain the following
40 | acknowledgment:
41 | "This product includes PHP software, freely available from
42 | ".
43 |
44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 | OF THE POSSIBILITY OF SUCH DAMAGE.
56 |
57 | --------------------------------------------------------------------
58 |
59 | This software consists of voluntary contributions made by many
60 | individuals on behalf of the PHP Group.
61 |
62 | The PHP Group can be contacted via Email at group@php.net.
63 |
64 | For more information on the PHP Group and the PHP project,
65 | please see .
66 |
67 | PHP includes the Zend Engine, freely available at
68 | .
69 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | apcu_bc
4 | pecl.php.net
5 | APCu Backwards Compatibility Module
6 | This module provides a backwards APC compatible API using APCu.
7 |
8 | Joe Watkins
9 | krakjoe
10 | krakjoe@php.net
11 | yes
12 |
13 |
14 | Remi Collet
15 | remi
16 | remi@php.net
17 | yes
18 |
19 | 2019-02-20
20 |
21 | 1.0.5
22 | 5.1
23 |
24 |
25 | stable
26 | stable
27 |
28 | PHP License
29 |
30 | - fix skipif.inc path in test suite
31 | - remove APCU version from phpinfo
32 | - remove Build date from phpinfo
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 7.0.0
58 |
59 |
60 | 1.10
61 |
62 |
63 | apcu
64 | pecl.php.net
65 | 5.1.2
66 | apcu
67 |
68 |
69 |
70 | apc
71 |
72 |
73 |
74 | 2015-12-07
75 |
76 | 1.0.0
77 | 5.1
78 |
79 |
80 | beta
81 | stable
82 |
83 | PHP License
84 |
85 | - initial release
86 |
87 |
88 |
89 | 2016-01-06
90 |
91 | 1.0.1
92 | 5.1
93 |
94 |
95 | beta
96 | stable
97 |
98 | PHP License
99 |
100 | - fix gh#10 - apc_clear_cache: parameter is optional
101 | - apc_cache_info: both parameters are optional
102 | - add dep on APCu extension
103 |
104 |
105 |
106 | 2016-01-29
107 |
108 | 1.0.2
109 | 5.1
110 |
111 |
112 | beta
113 | stable
114 |
115 | PHP License
116 |
117 | - restore apc behavior, apc_inc / apc_dec fail when key doesnt exists
118 |
119 |
120 |
121 | 2016-02-11
122 |
123 | 1.0.3
124 | 5.1
125 |
126 |
127 | beta
128 | stable
129 |
130 | PHP License
131 |
132 | - fix gh#14: apc_inc segfaults if APCu is disabled
133 | - fix Windows build
134 |
135 |
136 |
137 | 2018-02-16
138 |
139 | 1.0.4
140 | 5.1
141 |
142 |
143 | stable
144 | stable
145 |
146 | PHP License
147 |
148 | - promote as stable (no change)
149 |
150 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/php_apc.c:
--------------------------------------------------------------------------------
1 | /*
2 | +----------------------------------------------------------------------+
3 | | APC |
4 | +----------------------------------------------------------------------+
5 | | Copyright (c) 2015-2019 The PHP Group |
6 | +----------------------------------------------------------------------+
7 | | This source file is subject to version 3.01 of the PHP license, |
8 | | that is bundled with this package in the file LICENSE, and is |
9 | | available through the world-wide-web at the following url: |
10 | | http://www.php.net/license/3_01.txt |
11 | | If you did not receive a copy of the PHP license and are unable to |
12 | | obtain it through the world-wide-web, please send a note to |
13 | | license@php.net so we can mail you a copy immediately. |
14 | +----------------------------------------------------------------------+
15 | | Authors: krakjoe |
16 | +----------------------------------------------------------------------+
17 | */
18 |
19 | #ifdef HAVE_CONFIG_H
20 | # include "config.h"
21 | #endif
22 |
23 | #include "php.h"
24 | #include "zend.h"
25 | #include "zend_API.h"
26 | #include "zend_compile.h"
27 | #include "zend_hash.h"
28 | #include "zend_extensions.h"
29 | #include "zend_interfaces.h"
30 | #include "SAPI.h"
31 |
32 | #include "php_apc.h"
33 | #include "ext/standard/info.h"
34 | #include "ext/apcu/php_apc.h"
35 | #include "ext/apcu/apc_arginfo.h"
36 | #include "ext/apcu/apc_iterator.h"
37 |
38 | #ifdef HAVE_SYS_FILE_H
39 | #include
40 | #endif
41 |
42 | zend_class_entry *apc_bc_iterator_ce;
43 | zend_object_handlers apc_bc_iterator_handlers;
44 |
45 | /* {{{ arginfo */
46 | ZEND_BEGIN_ARG_INFO_EX(arginfo_apcu_bc_cache_info, 0, 0, 0)
47 | ZEND_ARG_INFO(0, type)
48 | ZEND_ARG_INFO(0, limited)
49 | ZEND_END_ARG_INFO()
50 |
51 | ZEND_BEGIN_ARG_INFO_EX(arginfo_apcu_bc_clear_cache, 0, 0, 0)
52 | ZEND_ARG_INFO(0, type)
53 | ZEND_END_ARG_INFO()
54 | /* }}} */
55 |
56 | /* {{{ PHP_FUNCTION declarations */
57 | PHP_FUNCTION(apc_cache_info);
58 | PHP_FUNCTION(apc_clear_cache);
59 | /* }}} */
60 |
61 | /* {{{ PHP_MINFO_FUNCTION(apc) */
62 | static PHP_MINFO_FUNCTION(apc)
63 | {
64 | php_info_print_table_start();
65 | php_info_print_table_row(2, "APC Compatibility", PHP_APCU_BC_VERSION);
66 | php_info_print_table_end();
67 | }
68 | /* }}} */
69 |
70 | static int apc_bc_iterator_init(int module_number);
71 |
72 | /* {{{ PHP_RINIT_FUNCTION(apc) */
73 | static PHP_RINIT_FUNCTION(apc)
74 | {
75 | #if defined(ZTS) && defined(COMPILE_DL_APC)
76 | ZEND_TSRMLS_CACHE_UPDATE();
77 | #endif
78 |
79 | return SUCCESS;
80 | }
81 | /* }}} */
82 |
83 | /* {{{ proto void apc_clear_cache(string cache) */
84 | PHP_FUNCTION(apc_clear_cache) {
85 | zend_string *name = NULL;
86 | zval proxy;
87 |
88 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) != SUCCESS) {
89 | return;
90 | }
91 |
92 | if (name && !strcasecmp(ZSTR_VAL(name), "user")) {
93 | ZVAL_STR(&proxy,
94 | zend_string_init(ZEND_STRL("apcu_clear_cache"), 0));
95 | call_user_function(EG(function_table), NULL, &proxy, return_value, 0, NULL);
96 | zval_ptr_dtor(&proxy);
97 | }
98 | }
99 | /* }}} */
100 |
101 | /* {{{ proto array apc_cache_info(string cache [, bool limited = false]) */
102 | PHP_FUNCTION(apc_cache_info) {
103 | zend_string *name = NULL;
104 | zval param, *limited = ¶m, proxy;
105 |
106 | ZVAL_FALSE(¶m);
107 |
108 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "|Sz", &name, &limited) != SUCCESS) {
109 | return;
110 | }
111 |
112 | if (name && !strcasecmp(ZSTR_VAL(name), "user")) {
113 | ZVAL_STR(&proxy,
114 | zend_string_init(ZEND_STRL("apcu_cache_info"), 0));
115 | call_user_function(EG(function_table), NULL, &proxy, return_value, 1, limited);
116 | zval_ptr_dtor(&proxy);
117 | }
118 | }
119 | /* }}} */
120 |
121 | static void php_apcu_bc_inc_dec(INTERNAL_FUNCTION_PARAMETERS, zend_string *funcname) /* {{{ */
122 | {
123 | zend_string *key;
124 | zend_long step = 1;
125 | zval proxy, params[3], *success = NULL;
126 |
127 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) {
128 | return;
129 | }
130 |
131 | /* Check if key exists to keep old APC behavior */
132 | ZVAL_STR(&proxy, zend_string_init(ZEND_STRL("apcu_exists"), 0));
133 | ZVAL_STR(¶ms[0], key);
134 | call_user_function(EG(function_table), NULL, &proxy, return_value, 1, params);
135 | if (Z_TYPE_INFO_P(return_value) != IS_TRUE) {
136 | if (success) {
137 | ZVAL_DEREF(success);
138 | zval_ptr_dtor(success);
139 | ZVAL_FALSE(success);
140 | }
141 | RETURN_FALSE;
142 | }
143 |
144 | /* inc/dec the key */
145 | ZVAL_STR(&proxy, funcname);
146 | ZVAL_STR(¶ms[0], key);
147 | ZVAL_LONG(¶ms[1], step);
148 | if (success) {
149 | ZVAL_COPY_VALUE(¶ms[2], success);
150 | }
151 | call_user_function(EG(function_table), NULL, &proxy, return_value, (success ? 3 : 2), params);
152 | }
153 | /* }}} */
154 |
155 | /* {{{ proto long apc_inc(string key [, long step [, bool& success]])
156 | */
157 | PHP_FUNCTION(apc_inc) {
158 | php_apcu_bc_inc_dec(INTERNAL_FUNCTION_PARAM_PASSTHRU, zend_string_init(ZEND_STRL("apcu_inc"), 0));
159 | }
160 | /* }}} */
161 |
162 | /* {{{ proto long apc_dec(string key [, long step [, bool &success]])
163 | */
164 | PHP_FUNCTION(apc_dec) {
165 | php_apcu_bc_inc_dec(INTERNAL_FUNCTION_PARAM_PASSTHRU, zend_string_init(ZEND_STRL("apcu_dec"), 0));
166 | }
167 | /* }}} */
168 |
169 | /* {{{ apc_functions[] */
170 | zend_function_entry apc_functions[] = {
171 | PHP_FE(apc_cache_info, arginfo_apcu_bc_cache_info)
172 | PHP_FE(apc_clear_cache, arginfo_apcu_bc_clear_cache)
173 | PHP_FALIAS(apc_store, apcu_store, arginfo_apcu_store)
174 | PHP_FALIAS(apc_fetch, apcu_fetch, arginfo_apcu_fetch)
175 | PHP_FALIAS(apc_enabled, apcu_enabled, arginfo_apcu_enabled)
176 | PHP_FALIAS(apc_delete, apcu_delete, arginfo_apcu_delete)
177 | PHP_FALIAS(apc_add, apcu_add, arginfo_apcu_store)
178 | PHP_FALIAS(apc_sma_info, apcu_sma_info, arginfo_apcu_sma_info)
179 | PHP_FE(apc_inc, arginfo_apcu_inc)
180 | PHP_FE(apc_dec, arginfo_apcu_inc)
181 | PHP_FALIAS(apc_cas, apcu_cas, arginfo_apcu_cas)
182 | PHP_FALIAS(apc_exists, apcu_exists, arginfo_apcu_exists)
183 | PHP_FE_END
184 | };
185 | /* }}} */
186 |
187 | /* {{{ arginfo */
188 | ZEND_BEGIN_ARG_INFO_EX(arginfo_apc_iterator___construct, 0, 0, 1)
189 | ZEND_ARG_INFO(0, ignored)
190 | ZEND_ARG_INFO(0, search)
191 | ZEND_ARG_INFO(0, format)
192 | ZEND_ARG_INFO(0, chunk_size)
193 | ZEND_ARG_INFO(0, list)
194 | ZEND_END_ARG_INFO()
195 | /* }}} */
196 |
197 | /* {{{ proto object APCIterator::__construct(cache, [ mixed search [, long format [, long chunk_size [, long list ]]]]) */
198 | PHP_METHOD(apc_bc_iterator, __construct) {
199 | apc_iterator_t *iterator = apc_iterator_fetch(getThis());
200 | zend_long format = APC_ITER_ALL;
201 | zend_long chunk_size=0;
202 | zval *search = NULL;
203 | zend_long list = APC_LIST_ACTIVE;
204 | zend_string *cache;
205 |
206 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|zlll", &cache, &search, &format, &chunk_size, &list) == FAILURE) {
207 | return;
208 | }
209 |
210 | if (apc_is_enabled()) {
211 | apc_iterator_obj_init(iterator, search, format, chunk_size, list);
212 | }
213 | }
214 | /* }}} */
215 |
216 | /* {{{ apc_iterator_functions */
217 | static zend_function_entry apc_iterator_functions[] = {
218 | PHP_ME(apc_bc_iterator, __construct, arginfo_apc_iterator___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
219 | PHP_FE_END
220 | };
221 | /* }}} */
222 |
223 | /* {{{ apc_bc_iterator_init */
224 | static int apc_bc_iterator_init(int module_number) {
225 | zend_class_entry ce;
226 |
227 | INIT_CLASS_ENTRY(ce, "APCIterator", apc_iterator_functions);
228 | apc_bc_iterator_ce = zend_register_internal_class_ex(&ce, apc_iterator_get_ce());
229 |
230 | return SUCCESS;
231 | }
232 | /* }}} */
233 |
234 | /* {{{ PHP_MINIT_FUNCTION(apc) */
235 | static PHP_MINIT_FUNCTION(apc)
236 | {
237 | if (apc_iterator_get_ce()) {
238 | apc_bc_iterator_init(module_number);
239 | }
240 | return SUCCESS;
241 | }
242 |
243 | static const zend_module_dep apc_deps[] = {
244 | ZEND_MOD_REQUIRED("apcu")
245 | ZEND_MOD_END
246 | };
247 |
248 | /* {{{ module definition structure */
249 | zend_module_entry apc_module_entry = {
250 | STANDARD_MODULE_HEADER_EX,
251 | NULL,
252 | apc_deps,
253 | PHP_APC_EXTNAME,
254 | apc_functions,
255 | PHP_MINIT(apc),
256 | NULL,
257 | PHP_RINIT(apc),
258 | NULL,
259 | PHP_MINFO(apc),
260 | PHP_APCU_VERSION,
261 | STANDARD_MODULE_PROPERTIES
262 | };
263 | /* }}} */
264 |
265 | #ifdef COMPILE_DL_APC
266 | ZEND_GET_MODULE(apc)
267 | #ifdef ZTS
268 | ZEND_TSRMLS_CACHE_DEFINE();
269 | #endif
270 | #endif
271 | /* }}} */
272 |
273 | /*
274 | * Local variables:
275 | * tab-width: 4
276 | * c-basic-offset: 4
277 | * End:
278 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
279 | * vim<600: expandtab sw=4 ts=4 sts=4
280 | */
281 |
--------------------------------------------------------------------------------