Skip to content

Commit 2ab1e4b

Browse files
authored
PHPC-2230: Drop support for PHP 7.2 and 7.3 (#1450)
* PHPC-2230: Drop support for PHP 7.2 and 7.3 * Remove compatibility code for PHP < 7.4 * Drop tests for legacy PHP serialization behaviour * Remove type match regexes in tests * Match object properties as strings * Fix var_export format in tests * Use wildcards when matching object properties * Remove unnecessary matching pattern in __set_state tests
1 parent b442f4c commit 2ab1e4b

File tree

133 files changed

+206
-2123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+206
-2123
lines changed

.evergreen/config.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,14 +1100,6 @@ axes:
11001100
display_name: "PHP 7.4"
11011101
variables:
11021102
PHP_VERSION: "7.4"
1103-
- id: "7.3"
1104-
display_name: "PHP 7.3"
1105-
variables:
1106-
PHP_VERSION: "7.3"
1107-
- id: "7.2"
1108-
display_name: "PHP 7.2"
1109-
variables:
1110-
PHP_VERSION: "7.2"
11111103

11121104
- id: php-edge-versions
11131105
display_name: PHP Version
@@ -1117,9 +1109,9 @@ axes:
11171109
variables:
11181110
PHP_VERSION: "8.2"
11191111
- id: "oldest-supported"
1120-
display_name: "PHP 7.2"
1112+
display_name: "PHP 7.4"
11211113
variables:
1122-
PHP_VERSION: "7.2"
1114+
PHP_VERSION: "7.4"
11231115

11241116
- id: os
11251117
display_name: OS
@@ -1231,7 +1223,7 @@ buildvariants:
12311223
# Exclude "latest-stable" PHP version for Debian 11 (see: test-mongodb-versions matrix)
12321224
- { "os": "debian11", "mongodb-edge-versions": "*", "php-versions": "8.2" }
12331225
# Exclude PHP versions older than 8.1 on RHEL 9 and Ubuntu 22.04 (OpenSSL 3 is only supported on PHP 8.1+)
1234-
- { "os": ["rhel90", "ubuntu2204-arm64", "ubuntu2204"], "mongodb-edge-versions": "*", "php-versions": ["7.2", "7.3", "7.4", "8.0"] }
1226+
- { "os": ["rhel90", "ubuntu2204-arm64", "ubuntu2204"], "mongodb-edge-versions": "*", "php-versions": ["7.4", "8.0"] }
12351227
tasks:
12361228
- name: "test-standalone-ssl"
12371229
- name: "test-replicaset-auth"

.github/workflows/tests.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,17 @@ jobs:
8181

8282
windows-tests:
8383
name: "Windows Tests"
84-
runs-on: ${{ matrix.os }}
84+
runs-on: windows-2022
8585
defaults:
8686
run:
8787
shell: cmd
8888

8989
strategy:
9090
fail-fast: true
9191
matrix:
92-
os: [ windows-2019, windows-2022 ]
93-
php: [ "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ]
92+
php: [ "7.4", "8.0", "8.1", "8.2" ]
9493
arch: [ x64, x86 ]
9594
ts: [ ts, nts ]
96-
exclude:
97-
- { os: windows-2019, php: "8.2" }
98-
- { os: windows-2019, php: "8.1" }
99-
- { os: windows-2019, php: "8.0" }
100-
- { os: windows-2019, php: "7.4" }
101-
- { os: windows-2019, php: "7.3" }
102-
- { os: windows-2022, php: "7.2" }
10395

10496
steps:
10597
- uses: actions/checkout@v3

.github/workflows/windows-release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
# Note: keep this in sync with the Windows matrix in tests.yml
13-
php: [ "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ]
13+
php: [ "7.4", "8.0", "8.1", "8.2" ]
1414
arch: [ x64, x86 ]
1515
ts: [ ts, nts ]
1616
runs-on: ubuntu-latest

config.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ if test "$PHP_MONGODB" != "no"; then
2727
fi
2828

2929
AC_MSG_RESULT($PHP_MONGODB_PHP_VERSION)
30-
if test "$PHP_MONGODB_PHP_VERSION_ID" -lt "70200"; then
31-
AC_MSG_ERROR([not supported. Need a PHP version >= 7.2.0 (found $PHP_MONGODB_PHP_VERSION)])
30+
if test "$PHP_MONGODB_PHP_VERSION_ID" -lt "70400"; then
31+
AC_MSG_ERROR([not supported. Need a PHP version >= 7.4.0 (found $PHP_MONGODB_PHP_VERSION)])
3232
fi
3333

3434
PHP_ARG_ENABLE([mongodb-developer-flags],

config.w32

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ ARG_WITH("mongodb-client-side-encryption", "MongoDB: Enable client-side encrypti
6666

6767
if (PHP_MONGODB != "no") {
6868
/* Note: ADD_EXTENSION_DEP() only reports the date and standard extensions as
69-
* installed in PHP 7.3.25+, 7.4.13+, and 8.0.0+). On other versions, assume
70-
* that they're always enabled. */
69+
* installed in PHP 7.4.13+ and 8.0.0+). On other versions, assume that
70+
* they're always enabled. */
7171
if (
7272
PHP_VERSION >= 8 ||
73-
(PHP_VERSION == 7 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION >= 25) ||
7473
(PHP_VERSION == 7 && PHP_MINOR_VERSION == 4 && PHP_RELEASE_VERSION >= 13)
7574
) {
7675
ADD_EXTENSION_DEP("mongodb", "date", false);

src/BSON/Document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static PHP_METHOD(MongoDB_BSON_Document, fromPHP)
153153
zval* data;
154154

155155
PHONGO_PARSE_PARAMETERS_START(1, 1)
156-
PHONGO_PARAM_ARRAY_OR_OBJECT(data)
156+
Z_PARAM_ARRAY_OR_OBJECT(data)
157157
PHONGO_PARSE_PARAMETERS_END();
158158

159159
object_init_ex(&zv, php_phongo_document_ce);

src/BSON/Int64.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ static zend_result php_phongo_int64_cast_object(phongo_compat_object_handler_typ
294294
return SUCCESS;
295295

296296
case IS_LONG:
297-
#if PHP_VERSION_ID >= 70300
298297
case _IS_NUMBER:
299-
#endif
300298
#if SIZEOF_ZEND_LONG == 4
301299
if (intern->integer > INT32_MAX || intern->integer < INT32_MIN) {
302300
zend_error(E_WARNING, "Truncating 64-bit integer value %" PRId64 " to 32 bits", intern->integer);

src/BSON/functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PHP_FUNCTION(fromPHP)
2929
bson_t* bson;
3030

3131
PHONGO_PARSE_PARAMETERS_START(1, 1)
32-
PHONGO_PARAM_ARRAY_OR_OBJECT(data)
32+
Z_PARAM_ARRAY_OR_OBJECT(data)
3333
PHONGO_PARSE_PARAMETERS_END();
3434

3535
bson = bson_new();

src/MongoDB/BulkWrite.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, insert)
387387
intern = Z_BULKWRITE_OBJ_P(getThis());
388388

389389
PHONGO_PARSE_PARAMETERS_START(1, 1)
390-
PHONGO_PARAM_ARRAY_OR_OBJECT(zdocument)
390+
Z_PARAM_ARRAY_OR_OBJECT(zdocument)
391391
PHONGO_PARSE_PARAMETERS_END();
392392

393393
bson_flags |= PHONGO_BSON_RETURN_ID;
@@ -429,8 +429,8 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, update)
429429
intern = Z_BULKWRITE_OBJ_P(getThis());
430430

431431
PHONGO_PARSE_PARAMETERS_START(2, 3)
432-
PHONGO_PARAM_ARRAY_OR_OBJECT(zquery)
433-
PHONGO_PARAM_ARRAY_OR_OBJECT(zupdate)
432+
Z_PARAM_ARRAY_OR_OBJECT(zquery)
433+
Z_PARAM_ARRAY_OR_OBJECT(zupdate)
434434
Z_PARAM_OPTIONAL
435435
Z_PARAM_ARRAY_OR_NULL(zoptions)
436436
PHONGO_PARSE_PARAMETERS_END();
@@ -494,7 +494,7 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, delete)
494494
intern = Z_BULKWRITE_OBJ_P(getThis());
495495

496496
PHONGO_PARSE_PARAMETERS_START(1, 2)
497-
PHONGO_PARAM_ARRAY_OR_OBJECT(zquery)
497+
Z_PARAM_ARRAY_OR_OBJECT(zquery)
498498
Z_PARAM_OPTIONAL
499499
Z_PARAM_ARRAY_OR_NULL(zoptions)
500500
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/ClientEncryption.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, rewrapManyDataKey)
408408
const bson_t* bulk_write_result;
409409

410410
PHONGO_PARSE_PARAMETERS_START(1, 2)
411-
PHONGO_PARAM_ARRAY_OR_OBJECT(zfilter)
411+
Z_PARAM_ARRAY_OR_OBJECT(zfilter)
412412
Z_PARAM_OPTIONAL
413413
Z_PARAM_ARRAY_OR_NULL(options)
414414
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static PHP_METHOD(MongoDB_Driver_Command, __construct)
107107
intern = Z_COMMAND_OBJ_P(getThis());
108108

109109
PHONGO_PARSE_PARAMETERS_START(1, 2)
110-
PHONGO_PARAM_ARRAY_OR_OBJECT(document)
110+
Z_PARAM_ARRAY_OR_OBJECT(document)
111111
Z_PARAM_OPTIONAL
112112
Z_PARAM_ARRAY_OR_NULL(options)
113113
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Query.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static PHP_METHOD(MongoDB_Driver_Query, __construct)
414414
zval* options = NULL;
415415

416416
PHONGO_PARSE_PARAMETERS_START(1, 2)
417-
PHONGO_PARAM_ARRAY_OR_OBJECT(filter)
417+
Z_PARAM_ARRAY_OR_OBJECT(filter)
418418
Z_PARAM_OPTIONAL
419419
Z_PARAM_ARRAY_OR_NULL(options)
420420
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static PHP_METHOD(MongoDB_Driver_Session, advanceClusterTime)
169169
SESSION_CHECK_LIVELINESS(intern, "advanceClusterTime")
170170

171171
PHONGO_PARSE_PARAMETERS_START(1, 1)
172-
PHONGO_PARAM_ARRAY_OR_OBJECT(zcluster_time)
172+
Z_PARAM_ARRAY_OR_OBJECT(zcluster_time)
173173
PHONGO_PARSE_PARAMETERS_END();
174174

175175
php_phongo_zval_to_bson(zcluster_time, PHONGO_BSON_NONE, &cluster_time, NULL);

src/phongo_compat.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,6 @@
1818

1919
#include "phongo_compat.h"
2020

21-
#ifdef ZEND_HASH_GET_APPLY_COUNT /* PHP 7.2 or earlier recursion protection */
22-
zend_bool php_phongo_zend_hash_apply_protection_begin(HashTable* ht)
23-
{
24-
if (!ht) {
25-
return 1;
26-
}
27-
if (ZEND_HASH_GET_APPLY_COUNT(ht) > 0) {
28-
return 0;
29-
}
30-
if (ZEND_HASH_APPLY_PROTECTION(ht)) {
31-
ZEND_HASH_INC_APPLY_COUNT(ht);
32-
}
33-
return 1;
34-
}
35-
36-
zend_bool php_phongo_zend_hash_apply_protection_end(HashTable* ht)
37-
{
38-
if (!ht) {
39-
return 1;
40-
}
41-
if (ZEND_HASH_GET_APPLY_COUNT(ht) == 0) {
42-
return 0;
43-
}
44-
if (ZEND_HASH_APPLY_PROTECTION(ht)) {
45-
ZEND_HASH_DEC_APPLY_COUNT(ht);
46-
}
47-
return 1;
48-
}
49-
#else /* PHP 7.3 or later */
5021
zend_bool php_phongo_zend_hash_apply_protection_begin(zend_array* ht)
5122
{
5223
if (GC_IS_RECURSIVE(ht)) {
@@ -68,7 +39,6 @@ zend_bool php_phongo_zend_hash_apply_protection_end(zend_array* ht)
6839
}
6940
return 1;
7041
}
71-
#endif /* ZEND_HASH_GET_APPLY_COUNT */
7242

7343
#if PHP_VERSION_ID < 80200
7444
const char* zend_get_object_type_case(const zend_class_entry* ce, zend_bool upper_case)

src/phongo_compat.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@
8686
#error Unsupported architecture (integers are neither 32-bit nor 64-bit)
8787
#endif
8888

89-
#if PHP_VERSION_ID < 70300
90-
#define zend_object_alloc(obj_size, ce) ecalloc(1, obj_size + zend_object_properties_size(ce))
91-
#endif
92-
9389
#define ADD_ASSOC_STR(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRL(_key), (char*) ZSTR_VAL(_value));
9490
#define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRL(_key), (char*) (_value));
9591
#define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRL(_key), (char*) (_value), _len);
@@ -176,37 +172,6 @@
176172
#error Unsupported architecture (integers are neither 32-bit nor 64-bit)
177173
#endif /* SIZEOF_ZEND_LONG */
178174

179-
#if PHP_VERSION_ID < 70300
180-
#define ZVAL_COPY_DEREF(z, v) \
181-
do { \
182-
zval* _z3 = (v); \
183-
if (Z_OPT_REFCOUNTED_P(_z3)) { \
184-
if (UNEXPECTED(Z_OPT_ISREF_P(_z3))) { \
185-
_z3 = Z_REFVAL_P(_z3); \
186-
if (Z_OPT_REFCOUNTED_P(_z3)) { \
187-
Z_ADDREF_P(_z3); \
188-
} \
189-
} else { \
190-
Z_ADDREF_P(_z3); \
191-
} \
192-
} \
193-
ZVAL_COPY_VALUE(z, _z3); \
194-
} while (0)
195-
#endif /* PHP_VERSION_ID < 70300 */
196-
197-
#if PHP_VERSION_ID < 70300
198-
static inline zend_bool zend_ini_parse_bool(zend_string* str)
199-
{
200-
if (zend_string_equals_literal_ci(str, "true") ||
201-
zend_string_equals_literal_ci(str, "yes") ||
202-
zend_string_equals_literal_ci(str, "on")) {
203-
return 1;
204-
} else {
205-
return atoi(ZSTR_VAL(str)) != 0;
206-
}
207-
}
208-
#endif /* PHP_VERSION_ID < 70300 */
209-
210175
/* Compatibility macros to override error handling logic */
211176
#define PHONGO_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
212177
do { \
@@ -275,16 +240,6 @@ static inline zend_bool zend_ini_parse_bool(zend_string* str)
275240
Z_PARAM_ZVAL_EX(dest, 1, 0)
276241
#endif
277242

278-
/* Z_PARAM_ARRAY_OR_OBJECT requires 3 arguments in PHP < 7.3.
279-
* See: https://github.com/php/php-src/commit/a595b0f75bf8bc0d3da8ca5cb03f8b1a694d26b2 */
280-
#if PHP_VERSION_ID < 70300
281-
#define PHONGO_PARAM_ARRAY_OR_OBJECT(dest) \
282-
Z_PARAM_ARRAY_OR_OBJECT(dest, 0, 0)
283-
#else
284-
#define PHONGO_PARAM_ARRAY_OR_OBJECT(dest) \
285-
Z_PARAM_ARRAY_OR_OBJECT(dest)
286-
#endif
287-
288243
/* ZEND_ABSTRACT_ME_WITH_FLAGS was introduced in PHP 8.0. */
289244
#ifndef ZEND_ABSTRACT_ME_WITH_FLAGS
290245
#define ZEND_ABSTRACT_ME_WITH_FLAGS(classname, name, arg_info, flags) ZEND_RAW_FENTRY(#name, NULL, arg_info, flags)

0 commit comments

Comments
 (0)