Skip to content

Commit 2807cca

Browse files
committed
Drop support for unsupported PHP versions
1 parent 846d71a commit 2807cca

File tree

5 files changed

+22
-107
lines changed

5 files changed

+22
-107
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@ jobs:
3939
os: 'macos-13'
4040
xdebug: '3.1.2'
4141

42-
- php: '8.0.0'
43-
os: 'ubuntu-20.04'
44-
expect_native: 1
45-
xdebug: '3.1.2'
46-
47-
- php: '7.4.0'
48-
os: 'ubuntu-20.04'
49-
expect_native: 1
50-
xdebug: '3.1.2'
51-
52-
- php: '7.3.0'
53-
os: 'ubuntu-20.04'
54-
expect_native: 1
55-
xdebug: '3.1.2'
56-
5742
runs-on: ${{ matrix.os }}
5843
continue-on-error: ${{ !!matrix.experimental }}
5944
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ install-sh
3131
libtool
3232
ltmain.sh
3333
memprof-*.tgz
34+
memprof_legacy_arginfo.h
3435
missing
3536
mkinstalldirs
3637
modules

memprof.c

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
#endif
3333
#include <assert.h>
3434

35-
#if PHP_VERSION_ID < 80000
36-
#include "memprof_legacy_arginfo.h"
37-
#else
38-
#include "memprof_arginfo.h"
35+
#if PHP_VERSION_ID < 80100
36+
# error "Unsupported PHP version (min supported version: 8.1.0)"
3937
#endif
4038

39+
#include "memprof_arginfo.h"
40+
4141
#define MEMPROF_ENV_PROFILE "MEMPROF_PROFILE"
4242
#define MEMPROF_FLAG_NATIVE "native"
4343
#define MEMPROF_FLAG_DUMP_ON_LIMIT "dump_on_limit"
@@ -202,24 +202,10 @@ static void (*old_zend_execute)(zend_execute_data *execute_data);
202202
static void (*old_zend_execute_internal)(zend_execute_data *execute_data_ptr, zval *return_value);
203203
#define zend_execute_fn zend_execute_ex
204204

205-
#if PHP_VERSION_ID < 70200 /* PHP 7.1 */
206-
# define MEMPROF_ZEND_ERROR_CB_ARGS int type, const char *error_filename, const uint error_lineno, const char *format, va_list args
207-
# define MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU type, error_filename, error_lineno, format, args
208-
#elif PHP_VERSION_ID < 80000 /* PHP 7.2 - 7.4 */
209-
# define MEMPROF_ZEND_ERROR_CB_ARGS int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args
210-
# define MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU type, error_filename, error_lineno, format, args
211-
#elif PHP_VERSION_ID < 80100 /* PHP 8.0 */
212-
# define MEMPROF_ZEND_ERROR_CB_ARGS int type, const char *error_filename, const uint32_t error_lineno, zend_string *message
213-
# define MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU type, error_filename, error_lineno, message
214-
#else /* PHP 8.1 */
215-
# define MEMPROF_ZEND_ERROR_CB_ARGS int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message
216-
# define MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU type, error_filename, error_lineno, message
217-
#endif
218-
219-
static void (*old_zend_error_cb)(MEMPROF_ZEND_ERROR_CB_ARGS);
220-
static void (*rinit_zend_error_cb)(MEMPROF_ZEND_ERROR_CB_ARGS);
205+
static void (*old_zend_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
206+
static void (*rinit_zend_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
221207
static zend_bool zend_error_cb_overridden;
222-
static void memprof_zend_error_cb(MEMPROF_ZEND_ERROR_CB_ARGS);
208+
static void memprof_zend_error_cb(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
223209

224210
static PHP_INI_MH((*origOnChangeMemoryLimit)) = NULL;
225211

@@ -819,7 +805,7 @@ static void memprof_zend_execute_internal(zend_execute_data *execute_data_ptr, z
819805
}
820806
}
821807

822-
static zend_bool should_autodump(int error_type, const char *message) {
808+
static zend_bool should_autodump(int error_type, zend_string *message) {
823809
if (EXPECTED(error_type != E_ERROR)) {
824810
return 0;
825811
}
@@ -828,7 +814,7 @@ static zend_bool should_autodump(int error_type, const char *message) {
828814
return 0;
829815
}
830816

831-
if (EXPECTED(strncmp(MEMORY_LIMIT_ERROR_PREFIX, message, strlen(MEMORY_LIMIT_ERROR_PREFIX)) != 0)) {
817+
if (EXPECTED(strncmp(MEMORY_LIMIT_ERROR_PREFIX, ZSTR_VAL(message), strlen(MEMORY_LIMIT_ERROR_PREFIX)) != 0)) {
832818
return 0;
833819
}
834820

@@ -854,16 +840,12 @@ static char * generate_filename(const char * format) {
854840
return filename;
855841
}
856842

857-
static void memprof_zend_error_cb_dump(MEMPROF_ZEND_ERROR_CB_ARGS)
843+
static void memprof_zend_error_cb_dump(int type, zend_string *error_filename,
844+
const uint32_t error_lineno, zend_string *message)
858845
{
859846
char * filename = NULL;
860847
php_stream * stream;
861848
zend_bool error = 0;
862-
#if PHP_VERSION_ID < 80000
863-
const char * message_chr = format;
864-
#else
865-
const char * message_chr = ZSTR_VAL(message);
866-
#endif
867849
zend_string * new_message = NULL;
868850

869851
zend_mm_set_heap(orig_zheap);
@@ -893,27 +875,23 @@ static void memprof_zend_error_cb_dump(MEMPROF_ZEND_ERROR_CB_ARGS)
893875

894876
if (filename != NULL) {
895877
if (error == 0) {
896-
new_message = strpprintf(0, "%s (memprof dumped to %s)", message_chr, filename);
878+
new_message = strpprintf(0, "%s (memprof dumped to %s)", ZSTR_VAL(message), filename);
897879
} else {
898-
new_message = strpprintf(0, "%s (memprof failed dumping to %s, please check file permissions or disk capacity)", message_chr, filename);
880+
new_message = strpprintf(0, "%s (memprof failed dumping to %s, please check file permissions or disk capacity)", ZSTR_VAL(message), filename);
899881
}
900882
efree(filename);
901883
}
902884

903885
if (new_message != NULL) {
904-
#if PHP_VERSION_ID < 80000
905-
format = ZSTR_VAL(new_message);
906-
#else
907886
message = new_message;
908-
#endif
909887
}
910888
} END_WITHOUT_MALLOC_TRACKING;
911889

912890
zend_mm_set_heap(orig_zheap);
913891
zend_set_memory_limit(PG(memory_limit));
914892
zend_mm_set_heap(zheap);
915893

916-
old_zend_error_cb(MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU);
894+
old_zend_error_cb(type, error_filename, error_lineno, message);
917895

918896
WITHOUT_MALLOC_TRACKING {
919897
if (new_message != NULL) {
@@ -923,25 +901,21 @@ static void memprof_zend_error_cb_dump(MEMPROF_ZEND_ERROR_CB_ARGS)
923901

924902
}
925903

926-
static void memprof_zend_error_cb(MEMPROF_ZEND_ERROR_CB_ARGS)
904+
static void memprof_zend_error_cb(int type, zend_string *error_filename,
905+
const uint32_t error_lineno, zend_string *message)
927906
{
928-
#if PHP_VERSION_ID < 80000
929-
const char * message_chr = format;
930-
#else
931-
const char * message_chr = ZSTR_VAL(message);
932-
#endif
933-
934907
if (EXPECTED(!MEMPROF_G(profile_flags).enabled)) {
935-
old_zend_error_cb(MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU);
908+
old_zend_error_cb(type, error_filename, error_lineno, message);
936909
return;
937910
}
938911

939-
if (EXPECTED(!should_autodump(type, message_chr))) {
940-
old_zend_error_cb(MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU);
912+
if (EXPECTED(!should_autodump(type, message))) {
913+
old_zend_error_cb(type, error_filename, error_lineno, message);
941914
return;
942915
}
943916

944-
return memprof_zend_error_cb_dump(MEMPROF_ZEND_ERROR_CB_ARGS_PASSTHRU);
917+
return memprof_zend_error_cb_dump(type, error_filename, error_lineno,
918+
message);
945919
}
946920

947921
static PHP_INI_MH(OnChangeMemoryLimit)

memprof_legacy_arginfo.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

package.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<file name="memprof.c" role="src" />
3535
<file name="memprof.stub.php" role="src" />
3636
<file name="memprof_arginfo.h" role="src" />
37-
<file name="memprof_legacy_arginfo.h" role="src" />
3837
<file name="php_memprof.h" role="src" />
3938
<file name="util.c" role="src" />
4039
<file name="util.h" role="src" />

0 commit comments

Comments
 (0)