Skip to content

Styleci #3

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

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f84d046
add support for Zend Max Exeuction Timers on FreeBSD (#13393)
dunglas Feb 16, 2024
2065829
[ci skip] NEWS
arnaud-lb Feb 16, 2024
51591ab
[ci skip] Adding myself as reviewer
arnaud-lb Feb 16, 2024
9a034c9
[ci skip] Adding myself as reviewer
arnaud-lb Feb 16, 2024
babe818
[ci skip] Merge branch 'PHP-8.3'
arnaud-lb Feb 16, 2024
2592398
Refactor PHP_SOCKADDR_CHECKS (#13406)
petk Feb 16, 2024
b5c3cbf
Check sockaddr_storage.ss_family with AC_CHECK_MEMBERS (#13407)
petk Feb 16, 2024
eaaffae
zend_call_stack sort of GH-13358 follow-up. (#13368)
devnexen Feb 16, 2024
e7b1f2a
Change long2ip return type (#13395)
jorgsowa Feb 16, 2024
492b9e0
Add entry on return type of long2ip to NEWS (#13408)
jorgsowa Feb 16, 2024
0941507
ext/ldap: few new unit tests (tls13 protocol). (#13409)
devnexen Feb 16, 2024
e0f6fe2
code formatting ci test
divinity76 Feb 17, 2024
31af39a
run CODE_FORMATTING_CHECK earlier
divinity76 Feb 17, 2024
08489ed
temporarily disable the others
divinity76 Feb 17, 2024
d13ed77
netcat
divinity76 Feb 17, 2024
58131f1
oops
divinity76 Feb 17, 2024
bd6f7c9
test
divinity76 Feb 17, 2024
9d57114
test
divinity76 Feb 17, 2024
913529c
test
divinity76 Feb 17, 2024
f9d5b91
test
divinity76 Feb 17, 2024
9b68cdf
test
divinity76 Feb 17, 2024
0bb20e8
test
divinity76 Feb 17, 2024
4c39f74
test
divinity76 Feb 17, 2024
9fdb233
test
divinity76 Feb 17, 2024
c669b52
test
divinity76 Feb 17, 2024
d603081
test
divinity76 Feb 17, 2024
6e85ec5
test
divinity76 Feb 17, 2024
76015e9
test
divinity76 Feb 17, 2024
7e6fa98
test
divinity76 Feb 17, 2024
a5ef74a
test
divinity76 Feb 17, 2024
5a77f1d
test
divinity76 Feb 17, 2024
f7f15b0
test
divinity76 Feb 17, 2024
ea98954
test
divinity76 Feb 17, 2024
930cd10
test
divinity76 Feb 17, 2024
df5d079
it works :D re-enable CIs
divinity76 Feb 17, 2024
84b6e25
Add style CI
Ayesh Feb 17, 2024
c47e1e8
t
Ayesh Feb 17, 2024
bcac384
WIP
Ayesh Feb 17, 2024
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
75 changes: 75 additions & 0 deletions .github/workflows/styling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Code Styling Check
on:
push:
paths-ignore:
- docs/*
- NEWS
- UPGRADING
- UPGRADING.INTERNALS
- '**/README.*'
- CONTRIBUTING.md
- CODING_STANDARDS.md
- .cirrus.yml
- .travis.yml
- travis/*
- .circleci/*
branches:
- PHP-8.1
- PHP-8.2
- PHP-8.3
- master
pull_request:
paths-ignore:
- docs/*
- NEWS
- UPGRADING
- UPGRADING.INTERNALS
- '**/README.*'
- CONTRIBUTING.md
- CODING_STANDARDS.md
- .cirrus.yml
- .travis.yml
- travis/*
- .circleci/*
branches:
- '**'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
cancel-in-progress: true
jobs:
CODE_FORMATTING_CHECK:
name: Code formatting check
# if: github.repository_owner == 'php' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install packages
run: |
set -x
sudo apt-get update
sudo apt-get install \
git \
clang-format \
php-cli \
netcat-openbsd
- name: Check code formatting
run: |
set -x
echo "foobar" > format.patch
- name: 'Upload artifacts'
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: 'format.patch'
path: format.patch
if-no-files-found: ignore
- name: 'Show summary'
run: |
echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}'
echo 'Artifact URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}'
cat 'Run curl ${{ steps.artifact-upload-step.outputs.artifact-url }} | git patch apply' > $GITHUB_STEP_SUMMARY
4 changes: 3 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
/Zend/zend.* @dstogov
/Zend/zend_alloc.* @dstogov
/Zend/zend_API.* @dstogov
/Zend/zend_call_stack.* @arnaud-lb
/Zend/zend_closures.* @dstogov
/Zend/zend_execute.* @dstogov
/Zend/zend_execute_API.c @dstogov
/Zend/zend_gc.* @dstogov
/Zend/zend_gc.* @dstogov @arnaud-lb
/Zend/zend_hash.* @dstogov
/Zend/zend_inheritance.* @dstogov
/Zend/zend_max_execution_timer.* @arnaud-lb
/Zend/zend_object_handlers.* @dstogov
/Zend/zend_objects.* @dstogov
/Zend/zend_objects_API.* @dstogov
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PHP NEWS
array to hashed). (ilutov)
. Fixed zend fiber build for solaris default mode (32 bits). (David Carlier)
. Fixed zend call stack size for macOs/arm64. (David Carlier)
. Added support for Zend Max Execution Timers on FreeBSD (Kévin Dunglas)

- Curl:
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)
Expand Down Expand Up @@ -174,6 +175,7 @@ PHP NEWS
. Add support for 4 new rounding modes to the round() function. (Jorg Sowa)
. debug_zval_dump() now indicates whether an array is packed. (Max Semenik)
. Fix GH-12143 (Optimize round). (SakiTakamachi)
. Changed return type of long2ip to string from string|false. (Jorg Sowa)

- XML:
. Added XML_OPTION_PARSE_HUGE parser option. (nielsdos)
Expand Down
1 change: 1 addition & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ PHP 8.4 UPGRADE NOTES
decimal number and round it to 0.29. However, "pre-rounding" incorrectly rounds
certain numbers, so this fix removes "pre-rounding" and changes the way numbers
are compared, so that the values ​​are correctly rounded as decimal numbers.
. long2ip() now returns string instead of string|false.

========================================
6. New Functions
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).
- M4 macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and
AC_CHECK_MEMBERS).

c. Windows build system changes
- The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19 have
Expand Down
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static const func_info_t func_infos[] = {
FN("array_rand", MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
F1("base64_encode", MAY_BE_STRING),
F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING),
F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("getopt", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_FALSE|MAY_BE_FALSE),
#if defined(HAVE_NANOSLEEP)
Expand Down
2 changes: 1 addition & 1 deletion Zend/Zend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ AC_ARG_ENABLE([zend-max-execution-timers],
[ZEND_MAX_EXECUTION_TIMERS=$enableval],
[ZEND_MAX_EXECUTION_TIMERS=$ZEND_ZTS])

AS_CASE(["$host_alias"], [*linux*], [], [ZEND_MAX_EXECUTION_TIMERS='no'])
AS_CASE(["$host_alias"], [*linux*|*freebsd*], [], [ZEND_MAX_EXECUTION_TIMERS='no'])

PHP_CHECK_FUNC(timer_create, rt)
if test "$ac_cv_func_timer_create" != "yes"; then
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/stack_limit/stack_limit_010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $expectedMaxSize = match(php_uname('s')) {
'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328
default => 8*1024*1024,
},
'SunOS' => 10 * 1024 * 1024,
'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32
};

Expand Down
37 changes: 6 additions & 31 deletions Zend/zend_call_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef int boolean_t;
#include <sys/lwp.h>
#include <sys/procfs.h>
#include <libproc.h>
#include <thread.h>
#endif

#ifdef ZEND_CHECK_STACK_LIMIT
Expand Down Expand Up @@ -664,43 +665,17 @@ static bool zend_call_stack_get_netbsd(zend_call_stack *stack)
#endif /* defined(__NetBSD__) */

#if defined(__sun)
# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack)
{
pthread_attr_t attr;
int error;
void *addr;
size_t max_size, guard_size;

error = pthread_attr_get_np(pthread_self(), &attr);
if (error) {
return false;
}

error = pthread_attr_getstack(&attr, &addr, &max_size);
if (error) {
return false;
}

error = pthread_attr_getguardsize(&attr, &guard_size);
if (error) {
stack_t s;
if (thr_stksegment(&s) < 0) {
return false;
}

addr = (char *)addr + guard_size;
max_size -= guard_size;

stack->base = (char *)addr + max_size;
stack->max_size = max_size;

stack->max_size = s.ss_size;
stack->base = s.ss_sp;
return true;
}
# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack)
{
return false;
}
# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */

static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack)
{
Expand All @@ -723,7 +698,7 @@ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack)
}

size = (1 << 20);
snprintf(path, sizeof(path), "/proc/%d/map", pid);
snprintf(path, sizeof(path), "/proc/%d/map", (int)pid);

if ((fd = open(path, O_RDONLY)) == -1) {
Prelease(proc, 0);
Expand Down
16 changes: 15 additions & 1 deletion Zend/zend_max_execution_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <errno.h>
#include <sys/syscall.h>
#include <sys/types.h>
# ifdef __FreeBSD__
# include <pthread_np.h>
# endif

#include "zend.h"
#include "zend_globals.h"
Expand All @@ -33,6 +36,13 @@
# define sigev_notify_thread_id _sigev_un._tid
# endif

// FreeBSD doesn't support CLOCK_BOOTTIME
# ifdef __FreeBSD__
# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_MONOTONIC
# else
# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_BOOTTIME
# endif

ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
{
pid_t pid = getpid();
Expand All @@ -45,10 +55,14 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
sev.sigev_notify = SIGEV_THREAD_ID;
sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer);
sev.sigev_signo = SIGRTMIN;
# ifdef __FreeBSD__
sev.sigev_notify_thread_id = pthread_getthreadid_np();
# else
sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
# endif

// Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727
if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) {
if (timer_create(ZEND_MAX_EXECUTION_TIMERS_CLOCK, &sev, &EG(max_execution_timer_timer)) != 0) {
zend_strerror_noreturn(E_ERROR, errno, "Could not create timer");
}

Expand Down
25 changes: 0 additions & 25 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1242,31 +1242,6 @@ AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
AC_MSG_RESULT([done])
])

dnl
dnl PHP_SOCKADDR_CHECKS
dnl
AC_DEFUN([PHP_SOCKADDR_CHECKS], [
dnl Check for struct sockaddr_storage exists.
AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/socket.h>]],
[[struct sockaddr_storage s; s]])],
[ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
])
if test "$ac_cv_sockaddr_storage" = "yes"; then
AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
fi
dnl Check if field sa_len exists in struct sockaddr.
AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/socket.h>]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])],
[ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
])
if test "$ac_cv_sockaddr_sa_len" = "yes"; then
AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
fi
])

dnl
dnl PHP_EBCDIC
dnl
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ dnl Checks for types.
AC_TYPE_UID_T

dnl Checks for sockaddr_storage and sockaddr.sa_len.
PHP_SOCKADDR_CHECKS
AC_CHECK_TYPES([struct sockaddr_storage],,,[#include <sys/socket.h>])
AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#include <sys/socket.h>])

dnl Checks for GCC function attributes on all systems except ones without glibc
dnl Fix for these systems is already included in GCC 7, but not on GCC 6.
Expand Down
3 changes: 0 additions & 3 deletions ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ foreach([
LDAP_OPT_X_TLS_PROTOCOL_TLS1_0,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_1,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_2,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_3,
] as $option) {
$result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $option);
var_dump($result);
Expand All @@ -35,5 +34,3 @@ bool(true)
int(770)
bool(true)
int(771)
bool(true)
int(772)
45 changes: 45 additions & 0 deletions ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--TEST--
ldap_set_option() - Basic test for TLS protocol max ldap option
--CREDITS--
Chad Sikorra <[email protected]>
--EXTENSIONS--
ldap
--SKIPIF--
<?php

if (!defined("LDAP_OPT_X_TLS_PROTOCOL_MAX")) {
die('LDAP_OPT_X_TLS_PROTOCOL_MAX unsupported.');
}
--FILE--
<?php
require "connect.inc";
$link = ldap_connect($uri);

foreach([
LDAP_OPT_X_TLS_PROTOCOL_SSL2,
LDAP_OPT_X_TLS_PROTOCOL_SSL3,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_0,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_1,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_2,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_3,
] as $option) {
$result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $option);
var_dump($result);

ldap_get_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $optionval);
var_dump($optionval);
}
?>
--EXPECT--
bool(true)
int(512)
bool(true)
int(768)
bool(true)
int(769)
bool(true)
int(770)
bool(true)
int(771)
bool(true)
int(772)
3 changes: 0 additions & 3 deletions ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ foreach([
LDAP_OPT_X_TLS_PROTOCOL_TLS1_0,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_1,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_2,
LDAP_OPT_X_TLS_PROTOCOL_TLS1_3,
] as $option) {
$result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $option);
var_dump($result);
Expand All @@ -35,5 +34,3 @@ bool(true)
int(770)
bool(true)
int(771)
bool(true)
int(772)
Loading