From 58288c8de1bf7d6f0ef0b6515e83c6cfa4dd3a36 Mon Sep 17 00:00:00 2001 From: Alessio Attilio Date: Tue, 17 Nov 2026 00:30:32 +0100 Subject: [PATCH 1/5] Add automatic PR issue linking workflow Fixes #25391 --- .../workflows/link-pull-request-issues.yml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/link-pull-request-issues.yml diff --git a/.github/workflows/link-pull-request-issues.yml b/.github/workflows/link-pull-request-issues.yml new file mode 100644 index 000000000000..6de96db6d5f1 --- /dev/null +++ b/.github/workflows/link-pull-request-issues.yml @@ -0,0 +1,90 @@ +name: Link pull requests to issues + +on: + pull_request_target: + types: + - opened + - edited + - reopened + +permissions: + contents: read + +jobs: + link-issue: + if: github.repository == 'php/php-src' + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title; + const matches = [...title.matchAll(/\bFix GH-(\d+)\b/g)]; + const pullRequest = context.payload.pull_request; + const body = pullRequest.body ?? ''; + const marker = ''; + const withoutManagedReference = body + .replace(/\n?\nFixes #\d+\n?/g, '') + .trimEnd(); + + if (matches.length !== 1) { + if (matches.length > 1) { + core.warning(`Expected one GH issue in the title, found ${matches.length}.`); + } + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const issueNumber = Number(matches[0][1]); + const { owner, repo } = context.repo; + const { data: issue } = await github.rest.issues.get({ + owner, + repo, + issue_number: issueNumber, + }); + + if (issue.pull_request) { + core.warning(`#${issueNumber} is a pull request, not an issue.`); + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const closingReference = new RegExp( + `\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, + 'i', + ); + + if (closingReference.test(withoutManagedReference)) { + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const separator = withoutManagedReference ? '\n\n' : ''; + const updatedBody = `${withoutManagedReference}${separator}${marker}\nFixes #${issueNumber}\n`; + if (body !== updatedBody) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: updatedBody, + }); + } From b4eb79419b3b9fa8b9f6806be98baf58e3cf0e59 Mon Sep 17 00:00:00 2001 From: Alessio Attilio Date: Tue, 17 Nov 2026 00:51:00 +0100 Subject: [PATCH 2/5] Require issue references in matching PR commits Fixes #25391 --- .github/workflows/check-pr-issue-commits.yml | 56 ++++++++++++ .../workflows/link-pull-request-issues.yml | 90 ------------------- 2 files changed, 56 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/check-pr-issue-commits.yml delete mode 100644 .github/workflows/link-pull-request-issues.yml diff --git a/.github/workflows/check-pr-issue-commits.yml b/.github/workflows/check-pr-issue-commits.yml new file mode 100644 index 000000000000..5a09e8ca690b --- /dev/null +++ b/.github/workflows/check-pr-issue-commits.yml @@ -0,0 +1,56 @@ +name: Require issue references in pull request commits + +on: + pull_request_target: + types: + - opened + - edited + - reopened + - synchronize + - ready_for_review + +permissions: + contents: none + +jobs: + check-issue-commits: + if: github.repository == 'php/php-src' + runs-on: ubuntu-latest + permissions: + pull-requests: read + steps: + - uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title; + const references = [...title.matchAll(/\bFix GH-(\d+)\b/g)]; + + if (references.length === 0) { + return; + } + + if (references.length !== 1) { + core.setFailed('The PR title must reference exactly one issue with "Fix GH-XXXXX".'); + return; + } + + const issueNumber = references[0][1]; + const commits = await github.paginate(github.rest.pulls.listCommits, { + ...context.repo, + pull_number: context.issue.number, + per_page: 100, + }); + const closingReference = new RegExp(`\\bFixes\\s+#${issueNumber}\\b`, 'i'); + const missingReferences = commits.filter(({ commit }) => { + const [, ...descriptionLines] = commit.message.split(/\r?\n/); + return !closingReference.test(descriptionLines.join('\n')); + }); + + if (missingReferences.length > 0) { + const details = missingReferences + .map(({ sha, commit }) => `- ${sha.slice(0, 7)} ${commit.message.split(/\r?\n/, 1)[0]}`) + .join('\n'); + core.setFailed( + `Every commit in a PR titled "Fix GH-${issueNumber}" must include "Fixes #${issueNumber}" in its commit message description.\n${details}`, + ); + } diff --git a/.github/workflows/link-pull-request-issues.yml b/.github/workflows/link-pull-request-issues.yml deleted file mode 100644 index 6de96db6d5f1..000000000000 --- a/.github/workflows/link-pull-request-issues.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Link pull requests to issues - -on: - pull_request_target: - types: - - opened - - edited - - reopened - -permissions: - contents: read - -jobs: - link-issue: - if: github.repository == 'php/php-src' - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - uses: actions/github-script@v7 - with: - script: | - const title = context.payload.pull_request.title; - const matches = [...title.matchAll(/\bFix GH-(\d+)\b/g)]; - const pullRequest = context.payload.pull_request; - const body = pullRequest.body ?? ''; - const marker = ''; - const withoutManagedReference = body - .replace(/\n?\nFixes #\d+\n?/g, '') - .trimEnd(); - - if (matches.length !== 1) { - if (matches.length > 1) { - core.warning(`Expected one GH issue in the title, found ${matches.length}.`); - } - if (body.includes(marker)) { - await github.rest.issues.update({ - ...context.repo, - issue_number: pullRequest.number, - body: withoutManagedReference, - }); - } - return; - } - - const issueNumber = Number(matches[0][1]); - const { owner, repo } = context.repo; - const { data: issue } = await github.rest.issues.get({ - owner, - repo, - issue_number: issueNumber, - }); - - if (issue.pull_request) { - core.warning(`#${issueNumber} is a pull request, not an issue.`); - if (body.includes(marker)) { - await github.rest.issues.update({ - ...context.repo, - issue_number: pullRequest.number, - body: withoutManagedReference, - }); - } - return; - } - - const closingReference = new RegExp( - `\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, - 'i', - ); - - if (closingReference.test(withoutManagedReference)) { - if (body.includes(marker)) { - await github.rest.issues.update({ - ...context.repo, - issue_number: pullRequest.number, - body: withoutManagedReference, - }); - } - return; - } - - const separator = withoutManagedReference ? '\n\n' : ''; - const updatedBody = `${withoutManagedReference}${separator}${marker}\nFixes #${issueNumber}\n`; - if (body !== updatedBody) { - await github.rest.issues.update({ - ...context.repo, - issue_number: pullRequest.number, - body: updatedBody, - }); - } From a6f12390debb870346003633ebcd865ed6b9e30a Mon Sep 17 00:00:00 2001 From: Alessio Attilio Date: Wed, 25 Nov 2026 19:55:28 +0100 Subject: [PATCH 3/5] Link issues from matching pull request titles Add the closing reference to the pull request description, where GitHub detects it, instead of requiring it in every commit. Fixes #25391 --- .github/workflows/check-pr-issue-commits.yml | 56 ------------ .../workflows/link-pull-request-issues.yml | 90 +++++++++++++++++++ 2 files changed, 90 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/check-pr-issue-commits.yml create mode 100644 .github/workflows/link-pull-request-issues.yml diff --git a/.github/workflows/check-pr-issue-commits.yml b/.github/workflows/check-pr-issue-commits.yml deleted file mode 100644 index 5a09e8ca690b..000000000000 --- a/.github/workflows/check-pr-issue-commits.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Require issue references in pull request commits - -on: - pull_request_target: - types: - - opened - - edited - - reopened - - synchronize - - ready_for_review - -permissions: - contents: none - -jobs: - check-issue-commits: - if: github.repository == 'php/php-src' - runs-on: ubuntu-latest - permissions: - pull-requests: read - steps: - - uses: actions/github-script@v7 - with: - script: | - const title = context.payload.pull_request.title; - const references = [...title.matchAll(/\bFix GH-(\d+)\b/g)]; - - if (references.length === 0) { - return; - } - - if (references.length !== 1) { - core.setFailed('The PR title must reference exactly one issue with "Fix GH-XXXXX".'); - return; - } - - const issueNumber = references[0][1]; - const commits = await github.paginate(github.rest.pulls.listCommits, { - ...context.repo, - pull_number: context.issue.number, - per_page: 100, - }); - const closingReference = new RegExp(`\\bFixes\\s+#${issueNumber}\\b`, 'i'); - const missingReferences = commits.filter(({ commit }) => { - const [, ...descriptionLines] = commit.message.split(/\r?\n/); - return !closingReference.test(descriptionLines.join('\n')); - }); - - if (missingReferences.length > 0) { - const details = missingReferences - .map(({ sha, commit }) => `- ${sha.slice(0, 7)} ${commit.message.split(/\r?\n/, 1)[0]}`) - .join('\n'); - core.setFailed( - `Every commit in a PR titled "Fix GH-${issueNumber}" must include "Fixes #${issueNumber}" in its commit message description.\n${details}`, - ); - } diff --git a/.github/workflows/link-pull-request-issues.yml b/.github/workflows/link-pull-request-issues.yml new file mode 100644 index 000000000000..6de96db6d5f1 --- /dev/null +++ b/.github/workflows/link-pull-request-issues.yml @@ -0,0 +1,90 @@ +name: Link pull requests to issues + +on: + pull_request_target: + types: + - opened + - edited + - reopened + +permissions: + contents: read + +jobs: + link-issue: + if: github.repository == 'php/php-src' + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title; + const matches = [...title.matchAll(/\bFix GH-(\d+)\b/g)]; + const pullRequest = context.payload.pull_request; + const body = pullRequest.body ?? ''; + const marker = ''; + const withoutManagedReference = body + .replace(/\n?\nFixes #\d+\n?/g, '') + .trimEnd(); + + if (matches.length !== 1) { + if (matches.length > 1) { + core.warning(`Expected one GH issue in the title, found ${matches.length}.`); + } + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const issueNumber = Number(matches[0][1]); + const { owner, repo } = context.repo; + const { data: issue } = await github.rest.issues.get({ + owner, + repo, + issue_number: issueNumber, + }); + + if (issue.pull_request) { + core.warning(`#${issueNumber} is a pull request, not an issue.`); + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const closingReference = new RegExp( + `\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, + 'i', + ); + + if (closingReference.test(withoutManagedReference)) { + if (body.includes(marker)) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: withoutManagedReference, + }); + } + return; + } + + const separator = withoutManagedReference ? '\n\n' : ''; + const updatedBody = `${withoutManagedReference}${separator}${marker}\nFixes #${issueNumber}\n`; + if (body !== updatedBody) { + await github.rest.issues.update({ + ...context.repo, + issue_number: pullRequest.number, + body: updatedBody, + }); + } From 79c2adb2a00457617f4bda555d71349e00f6087b Mon Sep 17 00:00:00 2001 From: Alessio Attilio Date: Wed, 25 Nov 2026 20:36:33 +0100 Subject: [PATCH 4/5] Use an ephemeral port in stream metadata test --- .../stream_get_meta_data_socket_variation4.phpt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt index 14e1a6b38769..96eca440e4bc 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt @@ -4,10 +4,11 @@ Testing stream_get_meta_data() "eof" field on a udp socket bool(false) ["uri"]=> - string(21) "tcp://127.0.0.1:31334" + string(%d) "tcp://127.0.0.1:%d" } @@ -73,7 +74,7 @@ array(8) { ["seekable"]=> bool(false) ["uri"]=> - string(21) "tcp://127.0.0.1:31334" + string(%d) "tcp://127.0.0.1:%d" } @@ -94,5 +95,5 @@ array(8) { ["seekable"]=> bool(false) ["uri"]=> - string(21) "tcp://127.0.0.1:31334" + string(%d) "tcp://127.0.0.1:%d" } From 1cc43a9cbf8ad0eb812d18ab4fa6c7fb3f3d434c Mon Sep 17 00:00:00 2001 From: Alessio Attilio Date: Fri, 27 Nov 2026 00:31:12 +0100 Subject: [PATCH 5/5] Recognize all closing issue reference forms --- .github/workflows/link-pull-request-issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link-pull-request-issues.yml b/.github/workflows/link-pull-request-issues.yml index 6de96db6d5f1..f28f905e7a24 100644 --- a/.github/workflows/link-pull-request-issues.yml +++ b/.github/workflows/link-pull-request-issues.yml @@ -64,7 +64,7 @@ jobs: } const closingReference = new RegExp( - `\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, + `\\b(?:close|closes|fix|fixes|resolve|resolves)\\s+(?:#|GH-)${issueNumber}\\b`, 'i', );