diff --git a/.env.example b/.env.example
index 1ca8f9658dbef..bdd47dedb82d5 100644
--- a/.env.example
+++ b/.env.example
@@ -45,6 +45,16 @@ LOCAL_PHP_XDEBUG_MODE=develop,debug
# Whether or not to enable Memcached.
LOCAL_PHP_MEMCACHED=false
+##
+# Whether or not to enable PCOV.
+#
+# PCOV is not interoperable with Xdebug. To use PCOV, `LOCAL_PHP_XDEBUG` must be
+# set to `false`. When both are enabled, Xdebug is used and PCOV is disabled.
+#
+# PCOV is only available for PHP 7.4 and higher.
+##
+LOCAL_PHP_PCOV=false
+
##
# The database software to use.
#
@@ -74,9 +84,6 @@ LOCAL_WP_ENVIRONMENT_TYPE=local
LOCAL_WP_DEVELOPMENT_MODE=core
LOCAL_WP_TESTS_DOMAIN=example.org
-# The URL to use when running e2e tests.
-WP_BASE_URL=http://localhost:${LOCAL_PORT}
-
##
# This silences the tips output by the dotenv package.
##
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
index a7a765f7483ea..9825166f0fb38 100644
--- a/.github/actionlint.yaml
+++ b/.github/actionlint.yaml
@@ -1,3 +1,9 @@
+# actionlint does not recognize the `ubuntu-26.04` GitHub-hosted runner label yet.
+# This can be removed once the pinned actionlint version includes it in its list of known labels.
+self-hosted-runner:
+ labels:
+ - ubuntu-26.04
+
# actionlint does not support the `$/` self-repository `uses:` syntax yet.
# See https://github.com/rhysd/actionlint/issues/711.
paths:
diff --git a/.github/actions/download-with-retry/action.yml b/.github/actions/download-with-retry/action.yml
new file mode 100644
index 0000000000000..b2697efdb431f
--- /dev/null
+++ b/.github/actions/download-with-retry/action.yml
@@ -0,0 +1,23 @@
+name: 'Download with retry'
+description: 'Downloads a file with curl, retrying on any error.'
+
+inputs:
+ url:
+ description: 'The URL to download.'
+ required: true
+ output:
+ description: 'The path to save the file to, relative to the workspace.'
+ required: true
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Download the file
+ shell: bash
+ # A stalled attempt (connecting for over 30 s, or under 1 KB/s for 30 s) fails and is
+ # retried: curl has no transfer timeout, and `timeout-minutes` would end the step unretried.
+ # No retry starts after 10 minutes, so a long `Retry-After` can't stretch the waits.
+ run: curl --fail --no-progress-meter --location --retry 5 --retry-all-errors --retry-max-time 600 --connect-timeout 30 --speed-limit 1024 --speed-time 30 --output "$OUTPUT" "$URL"
+ env:
+ URL: ${{ inputs.url }}
+ OUTPUT: ${{ inputs.output }}
diff --git a/.github/actions/run-with-retry/action.yml b/.github/actions/run-with-retry/action.yml
new file mode 100644
index 0000000000000..b7d6ce692d765
--- /dev/null
+++ b/.github/actions/run-with-retry/action.yml
@@ -0,0 +1,28 @@
+name: 'Run with retry'
+description: 'Runs a Bash command, retrying it when it fails. For downloads curl can retry itself, use download-with-retry.'
+
+inputs:
+ command:
+ description: 'The Bash command to run. It runs as code: read values from the `env` of the calling step, not from expressions.'
+ required: true
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Run the command
+ shell: bash
+ # Waits 10 s, then 20 s, between attempts, like `tools/local-env/scripts/utils.js`.
+ run: |
+ for (( attempt = 1; attempt <= MAX_ATTEMPTS; attempt++ )); do
+ if bash -eo pipefail -c "$COMMAND"; then
+ exit 0
+ fi
+ echo "::warning::Command failed on attempt $attempt of $MAX_ATTEMPTS."
+ if (( attempt < MAX_ATTEMPTS )); then
+ sleep $(( attempt * 10 ))
+ fi
+ done
+ exit 1
+ env:
+ COMMAND: ${{ inputs.command }}
+ MAX_ATTEMPTS: 3
diff --git a/.github/actions/setup-npm/action.yml b/.github/actions/setup-npm/action.yml
index fba5bd0257bcc..fe433ce7606d5 100644
--- a/.github/actions/setup-npm/action.yml
+++ b/.github/actions/setup-npm/action.yml
@@ -18,11 +18,22 @@ runs:
id: npm
env:
WORKING_DIRECTORY: ${{ inputs.working-directory }}
+ NPM_INSTALL_MAX_ATTEMPTS: 3
run: |
NPM_VERSION="$(jq -r '.devEngines.packageManager.version // empty' package.json)"
if [ -n "$NPM_VERSION" ]; then
# Contributors need the floor; CI stays on that major's newest release.
- npm install --global "npm@${NPM_VERSION/>=/^}"
+ # The registry can reset the connection mid-download (ECONNRESET), so retry.
+ for (( attempt = 1; attempt <= NPM_INSTALL_MAX_ATTEMPTS; attempt++ )); do
+ if npm install --global "npm@${NPM_VERSION/>=/^}"; then
+ break
+ fi
+ echo "::warning::npm install failed on attempt $attempt of $NPM_INSTALL_MAX_ATTEMPTS."
+ if (( attempt == NPM_INSTALL_MAX_ATTEMPTS )); then
+ exit 1
+ fi
+ sleep $(( attempt * 10 ))
+ done
echo "Required npm version: $NPM_VERSION"
else
echo "No devEngines.packageManager.version, keeping the bundled npm."
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index b8bcf4f4eff2c..f867d4736a8e8 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -3,7 +3,9 @@ Hi there! Thanks for contributing to WordPress!
Pull Requests in this GitHub repository **must** be linked to a ticket in the WordPress Core Trac instance (https://core.trac.wordpress.org), and are only used for code review. **No pull requests will be merged on GitHub.**
-See the WordPress Handbook page on using PRs for Code Review more information: https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/
+See the WordPress Handbook page on using PRs for Code Review for more information: https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/
+
+Do not open pull requests for security vulnerabilities. Please follow the responsible disclosure policy instead: https://make.wordpress.org/core/handbook/testing/reporting-security-vulnerabilities/
If this is your first time contributing, you may also find reviewing these guides first to be helpful:
- FAQs for New Contributors: https://make.wordpress.org/core/handbook/tutorials/faq-for-new-contributors/
diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml
index ad099ad58460a..6739279616a5d 100644
--- a/.github/workflows/coding-standards.yml
+++ b/.github/workflows/coding-standards.yml
@@ -75,9 +75,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -133,7 +133,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ phpcs, jshint, slack-notifications ]
diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml
index e249f6e25475c..ee64fd8490b31 100644
--- a/.github/workflows/end-to-end-tests.yml
+++ b/.github/workflows/end-to-end-tests.yml
@@ -44,15 +44,16 @@ on:
- 'tools/vendors/**'
- 'tools/webpack/**'
- '.github/actions/setup-npm/**'
+ - '.github/actions/download-with-retry/**'
- '.github/workflows/end-to-end-tests.yml'
- '.github/workflows/reusable-end-to-end-tests*.yml'
workflow_dispatch:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -82,10 +83,13 @@ jobs:
fail-fast: false
matrix:
LOCAL_SCRIPT_DEBUG: [ true, false ]
+ # See the "Projects" section in tests/e2e/README.md.
+ test-group: [ 'parallel', 'serial' ]
# A matrix value is needed in the 'name' directive for proper grouping in the GitHub UI.
label: [ 'E2E Tests' ]
with:
LOCAL_SCRIPT_DEBUG: ${{ matrix.LOCAL_SCRIPT_DEBUG }}
+ test-group: ${{ matrix.test-group }}
slack-notifications:
name: Slack Notifications
@@ -105,7 +109,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ e2e-tests, slack-notifications ]
diff --git a/.github/workflows/failed-workflow.yml b/.github/workflows/failed-workflow.yml
index 2da0ff56989d7..0eabce41807b9 100644
--- a/.github/workflows/failed-workflow.yml
+++ b/.github/workflows/failed-workflow.yml
@@ -23,7 +23,7 @@ jobs:
# - Restarts all failed jobs when the workflow fails or is cancelled for the first time.
failed-workflow:
name: Rerun a workflow
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
timeout-minutes: 30
diff --git a/.github/workflows/install-testing.yml b/.github/workflows/install-testing.yml
index 7bc7cab67856a..4e1af59a308fd 100644
--- a/.github/workflows/install-testing.yml
+++ b/.github/workflows/install-testing.yml
@@ -13,6 +13,7 @@ on:
# Always test the workflow after it's updated.
paths:
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/actions/smoke-check/**'
- '.github/workflows/install-testing.yml'
- '.version-support-*.json'
@@ -21,6 +22,7 @@ on:
# Always test the workflow when changes are suggested.
paths:
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/actions/smoke-check/**'
- '.version-support-*.json'
- '.github/workflows/install-testing.yml'
@@ -37,9 +39,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ inputs.wp-version || github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ inputs.wp-version || github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -80,7 +82,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-24.04 ]
+ os: [ ubuntu-26.04 ]
php: ${{ fromJSON( needs.build-test-matrix.outputs.php-versions ) }}
db-type: [ 'mysql' ]
db-version: ${{ fromJSON( needs.build-test-matrix.outputs.mysql-versions ) }}
@@ -104,11 +106,16 @@ jobs:
- db-version: '9.4'
- db-version: '9.5'
- db-version: '9.6'
+ - db-version: '26.7'
# MySQL 9.0+ will not work on PHP 7.2 & 7.3. See https://core.trac.wordpress.org/ticket/61218.
- php: '7.2'
db-version: '9.7'
- php: '7.3'
db-version: '9.7'
+ - php: '7.2'
+ db-version: '26.10'
+ - php: '7.3'
+ db-version: '26.10'
services:
database:
@@ -138,16 +145,20 @@ jobs:
- name: Set up WP-CLI
uses: $/.github/actions/setup-wp-cli
with:
- version: ${{ contains( fromJSON('["5.4", "5.5"]'), matrix.php ) && '2.4.0' || 'latest' }}
+ version: ${{ contains( fromJSON('["5.4", "5.5"]'), matrix.php ) && '2.4.0' || contains( fromJSON('["5.6", "7.0", "7.1"]'), matrix.php ) && '2.12.0' || 'latest' }}
- # WP-CLI extracts tarballs with PharData, which truncates paths longer than 100 characters.
- # Nightly builds are only available as a zip, which is not affected.
+ # WP-CLI 2.x extracts tarballs with PharData, which truncates paths longer than 100 characters.
+ # Zip archives are not affected, so download the zip for every version.
- name: Download WordPress
- run: |
- case "${WP_VERSION}" in
- nightly|trunk) wp core download --version=nightly ;;
- *) curl -fsSL "https://wordpress.org/wordpress-${WP_VERSION}.tar.gz" | tar xz --strip-components=1 ;;
- esac
+ # WP-CLI requests WordPress from WordPress.org once, so a network error fails the job.
+ # It extracts only after a complete download, so a retry starts from an empty directory.
+ uses: $/.github/actions/run-with-retry
+ with:
+ command: |
+ case "${WP_VERSION}" in
+ nightly|trunk) wp core download --version=nightly ;;
+ *) wp core download "https://wordpress.org/wordpress-${WP_VERSION}.zip" ;;
+ esac
env:
WP_VERSION: ${{ inputs.wp-version || 'nightly' }}
@@ -189,7 +200,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml
index 97c6f1099a43e..7c664bae516df 100644
--- a/.github/workflows/javascript-tests.yml
+++ b/.github/workflows/javascript-tests.yml
@@ -76,9 +76,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -119,7 +119,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/javascript-type-checking.yml b/.github/workflows/javascript-type-checking.yml
index 0bf9288b06e82..a65cb7a0afbbb 100644
--- a/.github/workflows/javascript-type-checking.yml
+++ b/.github/workflows/javascript-type-checking.yml
@@ -31,9 +31,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -74,7 +74,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/local-docker-environment.yml b/.github/workflows/local-docker-environment.yml
index c636c695b6d44..a8053e5efdb2f 100644
--- a/.github/workflows/local-docker-environment.yml
+++ b/.github/workflows/local-docker-environment.yml
@@ -64,9 +64,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -97,7 +97,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-24.04 ]
+ os: [ ubuntu-26.04 ]
memcached: [ false, true ]
php: ${{ fromJSON( needs.build-test-matrix.outputs.php-versions ) }}
db-version: ${{ fromJSON( needs.build-test-matrix.outputs.mysql-versions ) }}
@@ -113,8 +113,9 @@ jobs:
- db-version: '9.4'
- db-version: '9.5'
- db-version: '9.6'
- # No PHP 8.5 + Memcached support yet.
- - php: '8.5'
+ - db-version: '26.7'
+ # No PHP 8.6 + Memcached support yet.
+ - php: '8.6'
memcached: true
with:
@@ -142,7 +143,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ build-test-matrix, environment-tests-mysql, slack-notifications ]
diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml
index cc555cf9ef0e7..f8c5f54aeda6e 100644
--- a/.github/workflows/performance.yml
+++ b/.github/workflows/performance.yml
@@ -44,16 +44,18 @@ on:
- 'tools/vendors/**'
- 'tools/webpack/**'
- '.github/actions/setup-npm/**'
+ - '.github/actions/download-with-retry/**'
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/workflows/performance.yml'
- '.github/workflows/reusable-performance-*.yml'
workflow_dispatch:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -63,7 +65,7 @@ permissions: {}
jobs:
determine-matrix:
name: Determine Matrix
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
if: |
(
github.repository == 'WordPress/wordpress-develop' || (
@@ -170,7 +172,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml
index 7bb6869fd5a79..50d9f9d18314a 100644
--- a/.github/workflows/php-compatibility.yml
+++ b/.github/workflows/php-compatibility.yml
@@ -64,9 +64,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -107,7 +107,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/phpstan-pull-request-comments.yml b/.github/workflows/phpstan-pull-request-comments.yml
index aabe26def6414..170d770cd880b 100644
--- a/.github/workflows/phpstan-pull-request-comments.yml
+++ b/.github/workflows/phpstan-pull-request-comments.yml
@@ -32,7 +32,7 @@ jobs:
# - Creates or updates the comment while there are errors, and marks it as resolved once there are none.
phpstan-results:
name: Comment on a pull request with PHPStan results
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: read
issues: write
@@ -57,6 +57,20 @@ jobs:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
+ # The results of the analysis holding selected paths to a stricter rule level. A pull request whose branch does
+ # not have that analysis yet uploads none, which is fine. Whether they were expected is decided from the results
+ # above.
+ - name: Download the results of the strict analysis
+ id: download-strict
+ if: ${{ steps.download.outcome == 'success' }}
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ continue-on-error: true
+ with:
+ name: phpstan-results-strict
+ path: ${{ runner.temp }}/phpstan-results-strict
+ run-id: ${{ github.event.workflow_run.id }}
+ github-token: ${{ github.token }}
+
- name: Create, update, or resolve the PHPStan comment
if: ${{ steps.download.outcome == 'success' }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
@@ -74,7 +88,7 @@ jobs:
// anything at all. They are therefore checked for shape, and only accepted for the pull request whose
// current head is the commit that the run analyzed. That also discards the results of a run that was
// overtaken by a newer push.
- const results = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results/results.json`, 'utf8' ) );
+ const results = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results/results.json`, { encoding: 'utf8' } ) );
const issue_number = results.pull_request;
if ( ! Number.isSafeInteger( issue_number ) || issue_number <= 0 || ! Array.isArray( results.errors ) ) {
core.setFailed( 'The analysis results are malformed.' );
@@ -93,12 +107,62 @@ jobs:
const asString = ( value ) => ( typeof value === 'string' ? value : null );
const asSha = ( value ) => ( typeof value === 'string' && /^[0-9a-f]{40}$/.test( value ) ? value : null );
+ // A rule level is a number, or `max`. Results from a branch that does not report the level have none.
+ const asLevel = ( value ) => ( ( Number.isSafeInteger( value ) && value >= 0 ) || value === 'max' ? value : null );
const normalize = ( error ) => ( {
file: asString( error.file ),
line: Number.isSafeInteger( error.line ) && error.line > 0 ? error.line : null,
message: ( asString( error.message ) ?? '' ).slice( 0, 1000 ),
identifier: /^[A-Za-z0-9.]+$/.test( error.identifier ) ? error.identifier : null,
ignorable: error.ignorable === true,
+ // The analysis that reported the error, and the rule level it analyzed at. Neither is reported per error:
+ // they are those of the results the error was read from, and are kept in the history from there.
+ analysis: error.analysis === 'strict' ? 'strict' : 'default',
+ level: asLevel( error.level ),
+ } );
+
+ // The paths held to a stricter rule level are analyzed a second time, and that analysis uploads its results
+ // separately. The results above list the analyses the run made, and when the strict one is among them but
+ // its results are missing, the comment is left as it is: every error that only analysis reported would
+ // otherwise be shown as resolved. A run from a branch that does not have that analysis yet lists none, and
+ // has only these results.
+ const expectsStrict = Array.isArray( results.analyses ) && results.analyses.includes( 'strict' );
+ let strictErrors = [];
+ let strictLevel = null;
+ let strictChangedInBase = [];
+ if ( expectsStrict ) {
+ let strictResults = null;
+ try {
+ strictResults = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results-strict/results.json`, { encoding: 'utf8' } ) );
+ } catch ( error ) {
+ core.info( `The results of the strict analysis are missing, so the comment is left as it is: ${ error.message }` );
+ return;
+ }
+ if ( strictResults?.pull_request !== issue_number || ! Array.isArray( strictResults.errors ) ) {
+ core.setFailed( 'The results of the strict analysis are malformed.' );
+ return;
+ }
+ strictLevel = asLevel( strictResults.level );
+ strictErrors = strictResults.errors.map( ( error ) => normalize( { ...error, analysis: 'strict', level: strictLevel } ) );
+ strictChangedInBase = Array.isArray( strictResults.changed_in_base ) ? strictResults.changed_in_base : [];
+ }
+
+ // The strict analysis includes everything the default one does, so an error it reports at a lower level is
+ // reported by both. Such an error is listed once, as found by the analysis of the whole codebase, and the
+ // strict one only adds what is left over. Errors are matched as they are below, apart from their line.
+ const errorKey = ( error ) => JSON.stringify( [ error.file, error.identifier, error.message ] );
+ const defaultCounts = new Map();
+ const defaultErrors = results.errors.map( ( error ) => normalize( { ...error, analysis: 'default', level: results.level } ) );
+ for ( const error of defaultErrors ) {
+ defaultCounts.set( errorKey( error ), ( defaultCounts.get( errorKey( error ) ) ?? 0 ) + 1 );
+ }
+ const strictOnly = strictErrors.filter( ( error ) => {
+ const count = defaultCounts.get( errorKey( error ) ) ?? 0;
+ if ( count > 0 ) {
+ defaultCounts.set( errorKey( error ), count - 1 );
+ return false;
+ }
+ return true;
} );
// An error is recognized from one run to the next by its file, identifier and message, but not its line,
@@ -107,10 +171,10 @@ jobs:
// is fixed or added, those after it shift to the history of the one before or after, so their first reports
// can be off, and the one shown as resolved or new is the last rather than the one that was. That is rarer
// than lines being added or removed above them, which would throw off matching them by line.
- const errors = results.errors.map( normalize );
+ const errors = [ ...defaultErrors, ...strictOnly ];
const occurrences = new Map();
for ( const error of [ ...errors ].sort( ( a, b ) => ( a.line ?? 0 ) - ( b.line ?? 0 ) ) ) {
- const key = JSON.stringify( [ error.file, error.identifier, error.message ] );
+ const key = errorKey( error );
const occurrence = occurrences.get( key ) ?? 0;
occurrences.set( key, occurrence + 1 );
error.key = `${ key }#${ occurrence }`;
@@ -164,7 +228,11 @@ jobs:
// Files the base branch has changed since the pull request branched from it, in which the line numbers
// reported can be off in the head commit, since the analysis ran on the head commit merged into the base.
- const changedInBase = new Set( Array.isArray( results.changed_in_base ) ? results.changed_in_base.filter( ( file ) => typeof file === 'string' ) : [] );
+ // Each analysis only lists those among the files it reported errors in, so the lists of both are combined.
+ const changedInBase = new Set(
+ [ ...( Array.isArray( results.changed_in_base ) ? results.changed_in_base : [] ), ...strictChangedInBase ]
+ .filter( ( file ) => typeof file === 'string' )
+ );
const lineMayBeOff = ( error ) => ! error.fixed && Boolean( error.line ) && changedInBase.has( error.file );
const filesWithLinesOff = new Set( active.filter( lineMayBeOff ).map( ( error ) => error.file ) );
@@ -206,7 +274,10 @@ jobs:
// GitHub shows only the first few annotations of each kind from a step on the page of the workflow run, so
// errors left out of a table are pointed to in the log of the step that reported them, which has them all.
- const where = `the log of the [workflow run](${ run.html_url }), in the “Report the analysis results” step`;
+ // Each analysis runs in a job of its own, and an error found only by the strict one is only in that job's log.
+ const where = strictOnly.length > 0
+ ? `the log of the [workflow run](${ run.html_url }), in the “Report the analysis results” step of each of its jobs (errors in strict paths are only in the “strict paths” job)`
+ : `the log of the [workflow run](${ run.html_url }), in the “Report the analysis results” step`;
const table = ( rows, rowLimit, { withResolution = false } = {} ) => {
const shown = rows.slice( 0, rowLimit );
if ( shown.length === 0 ) {
@@ -215,10 +286,14 @@ jobs:
: `The ${ rows.length } errors are not listed here, to keep this comment short. They are listed in ${ where }.`;
}
const more = `…and ${ rows.length - shown.length } more, which are listed in ${ where }.`;
+ // The rule level is only shown in a table listing an error from the strict analysis, so that one listing
+ // only errors from the analysis of the whole codebase looks as it did before there were two. A level
+ // that was not reported, as by a branch from before it was, is left blank.
+ const withLevel = shown.some( ( error ) => error.analysis === 'strict' );
const lines = [
- `| Location | Error | Identifier | First reported |${ withResolution ? ' Resolved |' : '' }`,
- `| --- | --- | --- | --- |${ withResolution ? ' --- |' : '' }`,
- ...shown.map( ( error ) => `| ${ location( error ) } | ${ code( error.message ) } | ${ identifier( error ) } | ${ commit( error.introduced ) } |${ withResolution ? ` ${ commit( error.fixed ) } |` : '' }` ),
+ `| Location | Error | Identifier |${ withLevel ? ' Level |' : '' } First reported |${ withResolution ? ' Resolved |' : '' }`,
+ `| --- | --- | --- |${ withLevel ? ' --- |' : '' } --- |${ withResolution ? ' --- |' : '' }`,
+ ...shown.map( ( error ) => `| ${ location( error ) } | ${ code( error.message ) } | ${ identifier( error ) } |${ withLevel ? ` ${ error.level ?? '' } |` : '' } ${ commit( error.introduced ) } |${ withResolution ? ` ${ commit( error.fixed ) } |` : '' }` ),
];
if ( shown.length < rows.length ) {
lines.push( '', more );
@@ -248,6 +323,11 @@ jobs:
`> ${ filesWithLinesOff.size === 1 ? 'A file with errors has' : `${ filesWithLinesOff.size } files with errors have` } changed in ${ code( pr.base.ref ) } since this branch was last updated, so the line numbers reported in ${ filesWithLinesOff.size === 1 ? 'it' : 'them' } may be off and are not linked. Merge the latest ${ code( pr.base.ref ) } into this branch for accurate links.`,
].join( '\n' ) );
}
+ if ( active.some( ( error ) => error.analysis === 'strict' ) ) {
+ const strictError = strictLevel === null ? 'An error found by the strict analysis' : `An error at level ${ strictLevel }`;
+ const stricterLevel = strictLevel === null ? 'a stricter rule level' : `rule level ${ strictLevel }`;
+ sections.push( `${ strictError } is in a path that ${ code( 'phpstan-strict.neon.dist' ) } holds to ${ stricterLevel }, which the rest of the codebase is not yet held to. See [Stricter analysis of selected paths](${ readmeUrl }#stricter-analysis-of-selected-paths).` );
+ }
} else {
// Resolved by the last commit that resolved anything, so that later commits do not change the comment.
const resolvedBy = resolved.at( -1 )?.fixed ?? run.head_sha;
@@ -261,21 +341,21 @@ jobs:
'> [!IMPORTANT]',
'> **The PHPStan baselines are out of date, so the PHPStan check fails.**',
'>',
- '> An error recorded in a baseline no longer occurs, or occurs a different number of times. If this pull request fixed it, that is expected: nothing needs to change in the code, but each baseline entry records an exact count for a specific file, and the baselines need to catch up. Regenerate them and commit the result:',
+ '> An error recorded in a baseline no longer occurs, or occurs a different number of times. If this pull request fixed it, that is expected: nothing needs to change in the code, but each baseline entry records an exact count for a specific file, and the baselines need to catch up. Remove the stale entries, and commit the result:',
'>',
'> ```bash',
- '> npm run typecheck:php:baselines',
+ '> npm run typecheck:php:fix',
'> ```',
'>',
'> or, outside the Docker environment:',
'>',
'> ```bash',
- '> composer phpstan:baselines',
+ '> composer phpstan:fix',
'> ```',
'>',
- '> Where an error below names an `@phpstan-ignore` comment in the code rather than a baseline entry, remove that comment instead; regenerating will not clear it.',
+ '> This also deletes any baseline left with no entries, and removes any `@phpstan-ignore` comment in the code that no longer ignores anything.',
'>',
- `> See [Regenerating the baselines](${ readmeUrl }#regenerating-the-baselines) for details.`,
+ `> See [Removing stale entries with \`--fix\`](${ readmeUrl }#removing-stale-entries-with---fix) for details, and for regenerating the baselines instead.`,
].join( '\n' ) );
} else {
sections.push( [
@@ -316,8 +396,8 @@ jobs:
// The errors tracked are taken in the order they are listed, so that each one listed keeps its history.
const tracked = [ ...unignorable, ...ignorable ].slice( 0, trackedLimit ).concat( resolved ).map( ( error ) => {
- const { key, file, line, message, identifier, ignorable, introduced, seen, fixed } = error;
- return { key, file, line: lineMayBeOff( error ) ? null : line, message, identifier, ignorable, introduced, seen, fixed };
+ const { key, file, line, message, identifier, ignorable, analysis, level, introduced, seen, fixed } = error;
+ return { key, file, line: lineMayBeOff( error ) ? null : line, message, identifier, ignorable, analysis, level, introduced, seen, fixed };
} );
sections.push( `` );
diff --git a/.github/workflows/phpstan-static-analysis.yml b/.github/workflows/phpstan-static-analysis.yml
index 6a26c75b16525..3d855296e0e0a 100644
--- a/.github/workflows/phpstan-static-analysis.yml
+++ b/.github/workflows/phpstan-static-analysis.yml
@@ -17,8 +17,10 @@ on:
- 'composer.*'
# These files configure PHPStan. Changes could affect the outcome.
- 'phpstan.neon.dist'
+ - 'phpstan-strict.neon.dist'
- 'tests/phpstan/base.neon'
- 'tests/phpstan/baselines/**'
+ - 'tests/phpstan/baselines-strict/**'
# Confirm any changes to relevant workflow files.
- '.github/workflows/phpstan-static-analysis.yml'
- '.github/workflows/reusable-phpstan-static-analysis-v1.yml'
@@ -26,9 +28,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -69,7 +71,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml
index a212e3b6be563..2147698eb1e2b 100644
--- a/.github/workflows/phpunit-tests.yml
+++ b/.github/workflows/phpunit-tests.yml
@@ -74,9 +74,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -87,7 +87,7 @@ jobs:
# Reduce PR testing only for audited Core assets and unrelated companion files.
select-test-coverage:
name: Select PHPUnit coverage
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 5
permissions:
contents: read
@@ -212,8 +212,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-24.04 ]
- php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
+ os: [ ubuntu-26.04 ]
+ php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.0', '8.4', '9.7' ]
tests-domain: [ 'example.org' ]
@@ -234,20 +234,22 @@ jobs:
php: '8.3'
- full-matrix: false
php: '8.4'
+ - full-matrix: false
+ php: '8.5'
# Outside the full matrix, MySQL 5.7 compatibility and the widely used 8.x releases are tested.
- full-matrix: false
db-version: '9.7'
include:
# Include jobs that test with memcached.
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.3'
db-type: 'mysql'
db-version: '8.4'
tests-domain: 'example.org'
multisite: false
memcached: true
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.3'
db-type: 'mysql'
db-version: '8.4'
@@ -255,14 +257,14 @@ jobs:
multisite: true
memcached: true
# Include jobs with a port on the test domain for both single and multisite.
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.4'
db-type: 'mysql'
db-version: '8.4'
tests-domain: 'example.org:8889'
multisite: false
memcached: false
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.4'
db-type: 'mysql'
db-version: '8.4'
@@ -270,7 +272,7 @@ jobs:
multisite: true
memcached: false
# Report test results to the Host Test Results.
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
db-type: 'mysql'
db-version: '8.4'
tests-domain: 'example.org'
@@ -322,10 +324,10 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-24.04 ]
- php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
+ os: [ ubuntu-26.04 ]
+ php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6' ]
db-type: [ 'mariadb' ]
- db-version: [ '5.5', '10.3', '10.5', '10.6', '10.11', '11.4', '11.8' ]
+ db-version: [ '5.5', '10.3', '10.5', '10.6', '10.11', '11.4', '11.8', '12.3' ]
multisite: [ false, true ]
memcached: [ false ]
# Scheduled runs and pull requests labeled with 'Full PHPUnit Matrix' test every PHP and MariaDB version above.
@@ -343,6 +345,8 @@ jobs:
php: '8.3'
- full-matrix: false
php: '8.4'
+ - full-matrix: false
+ php: '8.5'
# Outside the full matrix, MariaDB 5.5 compatibility, 10.6, and newer LTS releases are tested.
- full-matrix: false
db-version: '10.3'
@@ -351,16 +355,16 @@ jobs:
include:
# Include jobs that test with memcached.
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.3'
db-type: 'mariadb'
- db-version: '11.8'
+ db-version: '12.3'
multisite: false
memcached: true
- - os: ubuntu-24.04
+ - os: ubuntu-26.04
php: '8.3'
db-type: 'mariadb'
- db-version: '11.8'
+ db-version: '12.3'
multisite: true
memcached: true
with:
@@ -384,8 +388,6 @@ jobs:
# Because upstream support for innovation releases is dropped when a new one is released (including security updates),
# only the most recent innovation version is tested.
#
- # MariaDB does not currently have a supported innovation release.
- #
test-innovation-releases:
name: PHP ${{ matrix.php }}
uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
@@ -409,10 +411,10 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-24.04 ]
- php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
+ os: [ ubuntu-26.04 ]
+ php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6' ]
db-type: [ 'mysql', 'mariadb' ]
- db-version: [ '12.1' ]
+ db-version: [ '26.10', '13.0' ]
multisite: [ false, true ]
memcached: [ false ]
db-innovation: [ true ]
@@ -423,8 +425,10 @@ jobs:
exclude:
# Exclude version combinations that don't exist.
+ - db-type: 'mariadb'
+ db-version: '26.10'
- db-type: 'mysql'
- db-version: '12.1'
+ db-version: '13.0'
# Outside the full matrix, only the highest and lowest PHP version of each major are tested.
- full-matrix: false
php: '8.1'
@@ -434,6 +438,8 @@ jobs:
php: '8.3'
- full-matrix: false
php: '8.4'
+ - full-matrix: false
+ php: '8.5'
with:
os: ${{ matrix.os }}
php: ${{ matrix.php }}
@@ -520,7 +526,7 @@ jobs:
fail-fast: false
matrix:
php: [ '7.4', '8.4' ]
- db-version: [ '9.7', '11.8' ]
+ db-version: [ '9.7', '12.3' ]
db-type: [ 'mysql', 'mariadb' ]
multisite: [ false ]
@@ -531,7 +537,7 @@ jobs:
db-type: 'mysql'
multisite: true
- php: '8.4'
- db-version: '11.8'
+ db-version: '12.3'
db-type: 'mariadb'
multisite: true
# Test with memcached.
@@ -549,7 +555,7 @@ jobs:
exclude:
# Exclude PHP versions that are not supported by the database versions.
- db-type: 'mysql'
- db-version: '11.8'
+ db-version: '12.3'
- db-type: 'mariadb'
db-version: '9.7'
@@ -564,57 +570,13 @@ jobs:
gutenberg-artifact: ${{ needs.prepare-gutenberg.result != 'skipped' }}
gutenberg-sha: ${{ needs.prepare-gutenberg.outputs.gutenberg-sha }}
- # Runs the PHPUnit test suite with PHP 8.6.
- #
- # The number of testing combinations is intentionally limited because PHP 8.6 is still in beta/RC.
- pre-release-php-8-6:
- name: PHP ${{ matrix.php }}
- uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
- needs: [ select-test-coverage, prepare-gutenberg ]
- permissions:
- contents: read
- if: |
- needs.select-test-coverage.outputs.assets-only != 'true' &&
- startsWith( github.repository, 'WordPress/' ) && (
- github.repository == 'WordPress/wordpress-develop' || (
- github.event_name == 'pull_request' && (
- ! github.event.repository.private ||
- ! github.event.pull_request.draft ||
- contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' )
- )
- )
- )
- strategy:
- fail-fast: false
- matrix:
- php: [ '8.6' ]
- db-version: [ '9.7', '11.8' ]
- db-type: [ 'mysql', 'mariadb' ]
- multisite: [ true, false ]
-
- exclude:
- - db-type: 'mysql'
- db-version: '11.8'
- - db-type: 'mariadb'
- db-version: '9.7'
-
- with:
- php: ${{ matrix.php }}
- db-version: ${{ matrix.db-version }}
- db-type: ${{ matrix.db-type }}
- multisite: ${{ matrix.multisite }}
- phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
- allow-errors: true
- gutenberg-artifact: ${{ needs.prepare-gutenberg.result != 'skipped' }}
- gutenberg-sha: ${{ needs.prepare-gutenberg.outputs.gutenberg-sha }}
-
slack-notifications:
name: Slack Notifications
uses: ./.github/workflows/slack-notifications.yml
permissions:
actions: read
contents: read
- needs: [ select-test-coverage, prepare-gutenberg, test-assets, test-with-mysql, test-with-mariadb, test-innovation-releases, html-api-test-groups, limited-matrix-for-forks, pre-release-php-8-6 ]
+ needs: [ select-test-coverage, prepare-gutenberg, test-assets, test-with-mysql, test-with-mariadb, test-innovation-releases, html-api-test-groups, limited-matrix-for-forks ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
@@ -626,7 +588,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/props-bot.yml b/.github/workflows/props-bot.yml
index eea736f5c4ea3..d5b79311bb576 100644
--- a/.github/workflows/props-bot.yml
+++ b/.github/workflows/props-bot.yml
@@ -31,9 +31,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ contains( fromJSON( '["pull_request_target", "pull_request_review", "pull_request_review_comment"]' ), github.event_name ) && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -48,7 +48,7 @@ jobs:
# - Removes the props-bot label, if necessary.
props-bot:
name: Generate a list of props
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
# The action needs permission `write` permission for PRs in order to add a comment.
pull-requests: write
diff --git a/.github/workflows/pull-request-comments.yml b/.github/workflows/pull-request-comments.yml
index 6c56326774b8d..e7673472910d6 100644
--- a/.github/workflows/pull-request-comments.yml
+++ b/.github/workflows/pull-request-comments.yml
@@ -11,19 +11,111 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.event_name == 'workflow_dispatch' && github.event.number || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.event.pull_request.number || github.event_name == 'workflow_dispatch' && github.event.number || github.sha }}
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
+ # Comments on a pull request when the author is a first time contributor.
+ post-welcome-message:
+ name: Post a welcome comment for first-time contributors
+ runs-on: ubuntu-26.04
+ permissions:
+ issues: write
+ pull-requests: write
+ timeout-minutes: 5
+ if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' && github.event.action == 'opened' }}
+ steps:
+ - name: Post welcome comment
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const { owner, repo } = context.repo;
+ const pr = context.payload.pull_request;
+ const author = pr.user.login;
+
+ // Only comment for first-time contributors.
+ const authorAssociation = pr.author_association;
+ const isFirstTimer = authorAssociation === 'FIRST_TIME_CONTRIBUTOR' || authorAssociation === 'FIRST_TIMER';
+
+ if ( ! isFirstTimer ) {
+ core.info( `Author @${ author } has author association "${ authorAssociation }". Skipping welcome comment.` );
+ return;
+ }
+
+ // Check if the author has opened other pull requests in the repository.
+ const query = `repo:${ owner }/${ repo } is:pr author:${ author }`;
+ const searchResults = await github.rest.search.issuesAndPullRequests( {
+ q: query,
+ per_page: 5,
+ } );
+
+ const otherPRs = searchResults.data.items.filter( ( item ) => item.number !== pr.number );
+ if ( otherPRs.length > 0 ) {
+ core.info( `Author @${ author } has already opened other pull requests. Skipping welcome comment.` );
+ return;
+ }
+
+ // Check if a welcome comment already exists to avoid duplicate comments.
+ const comments = await github.paginate( github.rest.issues.listComments, {
+ owner,
+ repo,
+ issue_number: pr.number,
+ per_page: 100,
+ } );
+
+ const hasWelcomeComment = comments.some( ( comment ) =>
+ comment.user && comment.user.type === 'Bot' && comment.body.includes( 'first pull request to `wordpress-develop`' )
+ );
+
+ if ( hasWelcomeComment ) {
+ core.info( 'A welcome comment already exists on this pull request.' );
+ return;
+ }
+
+ const welcomeLines = [
+ `Hi @${ author }! 👋`,
+ 'Thank you for your contribution to WordPress! 💖',
+ 'It looks like this is your first pull request to `wordpress-develop`. Here are a few things to be aware of that may help you out!',
+ '**Pull requests must be attached to a [Trac](https://core.trac.wordpress.org/) ticket.** WordPress Core does not use GitHub as an issue tracker. To ensure your pull request receives the necessary attention, please include the Trac ticket\'s full URL in your pull request description.',
+ '**Pull requests are never merged on GitHub.** The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.',
+ 'More information about how GitHub pull requests can be used to contribute to WordPress can be found in [the Core Handbook](https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/).',
+ '> [!IMPORTANT]\n> If your pull request addresses a security issue, please close it. Security vulnerabilities must be reported privately and handled according to the project\'s responsible disclosure policy. See [Reporting Security Vulnerabilities](https://make.wordpress.org/core/handbook/testing/reporting-security-vulnerabilities/) in the Core Handbook for more information.',
+ '**Please link your WordPress.org account to GitHub.** To ensure your contribution is correctly credited in a WordPress release, [connect your GitHub account in your WordPress.org profile](https://profiles.wordpress.org/me/). If you do not have a WordPress.org account, you can [register one](https://login.wordpress.org/register). More information is available in [Associating GitHub accounts with WordPress.org profiles](https://make.wordpress.org/core/2020/03/19/associating-github-accounts-with-wordpress-org-profiles/).',
+ '**Please include automated tests.** Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress\' test suites, visit the [Automated Testing](https://make.wordpress.org/core/handbook/testing/automated-testing/) page in the handbook.',
+ 'If you have not had a chance, please review the [Contribute with Code page](https://make.wordpress.org/core/handbook/contribute/) in the [WordPress Core Handbook](https://make.wordpress.org/core/handbook/).',
+ 'The [Developer Hub](https://developer.wordpress.org/) also documents the various [coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/) that are followed:\n- [PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)\n- [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/)\n- [HTML Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/)\n- [JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/)\n- [Accessibility Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/)\n- [Inline Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/)',
+ 'Thank you,\nThe WordPress Project',
+ ];
+
+ await github.rest.issues.createComment( {
+ owner,
+ repo,
+ issue_number: pr.number,
+ body: welcomeLines.join( '\n\n' ),
+ } );
+
+ try {
+ await github.rest.reactions.createForIssue( {
+ owner,
+ repo,
+ issue_number: pr.number,
+ content: 'hooray',
+ } );
+ } catch ( error ) {
+ core.info( `Could not add reaction: ${ error.message }` );
+ }
+
+ core.notice( `Created welcome comment for pull request: ${ pr.html_url }` );
+
# Leaves a comment on a pull request with a link to test the changes in a WordPress Playground instance.
playground-details:
name: Comment on a pull request with Playground details
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
issues: write
pull-requests: write
@@ -127,7 +219,7 @@ jobs:
# Manages comments reminding contributors to include a Trac ticket link when opening a pull request.
trac-ticket-check:
name: Manage Trac ticket reminders for pull requests
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
issues: write
pull-requests: write
diff --git a/.github/workflows/reusable-build-package.yml b/.github/workflows/reusable-build-package.yml
index 4ca4b6e87dcb4..2d1d6ad34e103 100644
--- a/.github/workflows/reusable-build-package.yml
+++ b/.github/workflows/reusable-build-package.yml
@@ -26,7 +26,7 @@ jobs:
name: WordPress
permissions:
contents: read
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 20
steps:
diff --git a/.github/workflows/reusable-cleanup-pull-requests.yml b/.github/workflows/reusable-cleanup-pull-requests.yml
index c0266864b924c..b8e5af9319dad 100644
--- a/.github/workflows/reusable-cleanup-pull-requests.yml
+++ b/.github/workflows/reusable-cleanup-pull-requests.yml
@@ -24,7 +24,7 @@ jobs:
# - Comments on pull requests referencing any fixed tickets before closing.
close-prs:
name: Find and close PRs
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
pull-requests: write
diff --git a/.github/workflows/reusable-coding-standards-javascript.yml b/.github/workflows/reusable-coding-standards-javascript.yml
index c81ef7aa2c262..e58a6c061cada 100644
--- a/.github/workflows/reusable-coding-standards-javascript.yml
+++ b/.github/workflows/reusable-coding-standards-javascript.yml
@@ -29,7 +29,7 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
jshint:
name: JavaScript checks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
diff --git a/.github/workflows/reusable-coding-standards-php.yml b/.github/workflows/reusable-coding-standards-php.yml
index 52779b0aa29b0..cb8700408b0f3 100644
--- a/.github/workflows/reusable-coding-standards-php.yml
+++ b/.github/workflows/reusable-coding-standards-php.yml
@@ -42,7 +42,7 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
phpcs:
name: PHP checks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
diff --git a/.github/workflows/reusable-end-to-end-tests.yml b/.github/workflows/reusable-end-to-end-tests.yml
index 54bd6b4230fab..a7f440e156845 100644
--- a/.github/workflows/reusable-end-to-end-tests.yml
+++ b/.github/workflows/reusable-end-to-end-tests.yml
@@ -32,6 +32,11 @@ on:
required: false
type: 'boolean'
default: true
+ test-group:
+ description: 'The Playwright project to run. Runs the default projects when empty.'
+ required: false
+ type: 'string'
+ default: ''
env:
LOCAL_DIR: build
@@ -62,8 +67,8 @@ jobs:
# - Uploads screenshots and HTML snapshots as an artifact.
# - Ensures version-controlled files are not modified or deleted.
e2e-tests:
- name: SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
- runs-on: ubuntu-24.04
+ name: ${{ inputs.test-group && format( '{0}, ', inputs.test-group ) || '' }}SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
@@ -131,14 +136,22 @@ jobs:
LOCAL_SCRIPT_DEBUG: ${{ inputs.LOCAL_SCRIPT_DEBUG }}
run: npm run env:install
+ - name: Download Gutenberg
+ if: ${{ inputs.install-gutenberg }}
+ # Downloaded on the runner so failed downloads are retried: WP-CLI tries once.
+ # Release branches run this workflow from trunk: `$/` resolves to this workflow's commit, not the caller's.
+ uses: $/.github/actions/download-with-retry
+ with:
+ url: https://downloads.wordpress.org/plugin/gutenberg.${{ inputs.gutenberg-version || 'latest-stable' }}.zip
+ output: gutenberg.zip
+
- name: Install Gutenberg
if: ${{ inputs.install-gutenberg }}
run: |
- npm run env:cli -- plugin install gutenberg \
- ${{ inputs.gutenberg-version && '--version="${GUTENBERG_VERSION}"' || '' }} \
- --path="/var/www/${LOCAL_DIR}"
- env:
- GUTENBERG_VERSION: ${{ inputs.gutenberg-version }}
+ npm run env:cli -- plugin install gutenberg.zip --path="/var/www/${LOCAL_DIR}"
+ rm gutenberg.zip
+ # Installing from a zip doesn't log the version; unpinned branches get the latest.
+ npm run env:cli -- plugin get gutenberg --field=version --path="/var/www/${LOCAL_DIR}"
- name: Install additional languages
run: |
@@ -147,8 +160,14 @@ jobs:
npm run env:cli -- language theme install de_DE --all --path="/var/www/${LOCAL_DIR}"
- name: Run E2E tests
- run: npm run test:e2e
+ run: |
+ if [ -n "${TEST_GROUP}" ]; then
+ npm run test:e2e -- --project="${TEST_GROUP}"
+ else
+ npm run test:e2e
+ fi
env:
+ TEST_GROUP: ${{ inputs.test-group }}
# Chromium is installed above and is the only browser the suite runs. Without this,
# `wp-scripts test-playwright` also downloads Firefox and WebKit on every run.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${{ inputs.install-playwright && '1' || '' }}
@@ -157,7 +176,7 @@ jobs:
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
- name: failures-artifacts${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
+ name: failures-artifacts${{ inputs.test-group && format( '-{0}', inputs.test-group ) || '' }}${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
path: artifacts
if-no-files-found: ignore
include-hidden-files: true
diff --git a/.github/workflows/reusable-javascript-tests.yml b/.github/workflows/reusable-javascript-tests.yml
index 62b237a515e66..bc4d2c9d1ccf8 100644
--- a/.github/workflows/reusable-javascript-tests.yml
+++ b/.github/workflows/reusable-javascript-tests.yml
@@ -30,7 +30,7 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
test-js:
name: Run QUnit tests
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
@@ -62,7 +62,7 @@ jobs:
- name: Install npm Dependencies
run: npm ci
- # Branches prior to 6.1 using outdated versions of Puppeteer fail on newer versions of the `ubuntu-24` image.
+ # Branches prior to 6.1 using outdated versions of Puppeteer fail on the `ubuntu-24.04` image and newer.
# This disables AppArmor in order to work around those failures.
#
# See https://issues.chromium.org/issues/373753919
diff --git a/.github/workflows/reusable-javascript-type-checking-v1.yml b/.github/workflows/reusable-javascript-type-checking-v1.yml
index e0bf36ce19c9c..d8d0eeff785a4 100644
--- a/.github/workflows/reusable-javascript-type-checking-v1.yml
+++ b/.github/workflows/reusable-javascript-type-checking-v1.yml
@@ -28,7 +28,7 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
typecheck:
name: Run JavaScript type checking
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 10
diff --git a/.github/workflows/reusable-performance-report-v2.yml b/.github/workflows/reusable-performance-report-v2.yml
index 56cc147491955..de9a29a7e68ef 100644
--- a/.github/workflows/reusable-performance-report-v2.yml
+++ b/.github/workflows/reusable-performance-report-v2.yml
@@ -51,7 +51,7 @@ jobs:
# - Publish performance results if necessary.
compare:
name: ${{ inputs.multisite && 'Multisite' || 'Single Site' }} ${{ inputs.memcached && 'Memcached' || 'Default' }} ${{ inputs.publish && '(Publishes)' || '' }}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
diff --git a/.github/workflows/reusable-performance-test-v2.yml b/.github/workflows/reusable-performance-test-v2.yml
index bc40646871e0d..edff5788cbe50 100644
--- a/.github/workflows/reusable-performance-test-v2.yml
+++ b/.github/workflows/reusable-performance-test-v2.yml
@@ -21,7 +21,7 @@ on:
description: 'The version being used for baseline measurements.'
required: false
type: 'string'
- default: '7.0.0'
+ default: '7.1.0'
TARGET_SHA:
description: 'SHA hash of the target commit used for "before" measurements.'
required: true
@@ -107,7 +107,7 @@ jobs:
# - Ensure version-controlled files are not modified or deleted.
performance:
name: Test ${{ inputs.subject == 'base' && inputs.BASE_TAG || inputs.subject }}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
@@ -159,6 +159,9 @@ jobs:
run: npm ci
- name: Install Playwright browsers
+ # A hung install would otherwise run until the 6 hour job limit. The cap
+ # leaves room for slow downloads.
+ timeout-minutes: 15
run: npm exec --no -- playwright install --with-deps chromium
- name: Start Docker environment
@@ -202,9 +205,11 @@ jobs:
- name: Set the environment to the baseline version
if: ${{ inputs.subject == 'base' }}
- run: |
- VERSION="${BASE_TAG%.0}"
- wp core download --version="$VERSION" --force --path="${LOCAL_DIR}"
+ # WP-CLI requests the release from WordPress.org once, so a network error fails the job.
+ # It extracts only after a complete download, and `--force` lets a retry overwrite files.
+ uses: $/.github/actions/run-with-retry
+ with:
+ command: wp core download --version="${BASE_TAG%.0}" --force --path="${LOCAL_DIR}"
- name: Install object cache drop-in
if: ${{ inputs.memcached }}
@@ -236,12 +241,29 @@ jobs:
npm run env:cli -- theme enable twentytwentyfour --network --path="/var/www/${LOCAL_DIR}"
npm run env:cli -- theme enable twentytwentyfive --network --path="/var/www/${LOCAL_DIR}"
+ - name: Download WordPress Importer plugin
+ # Downloaded on the runner so failed downloads are retried: WP-CLI tries once.
+ uses: $/.github/actions/download-with-retry
+ with:
+ url: https://downloads.wordpress.org/plugin/wordpress-importer.latest-stable.zip
+ output: wordpress-importer.zip
+
- name: Install WordPress Importer plugin
- run: npm run env:cli -- plugin install wordpress-importer --activate --path="/var/www/${LOCAL_DIR}"
+ run: |
+ npm run env:cli -- plugin install wordpress-importer.zip --activate --path="/var/www/${LOCAL_DIR}"
+ rm wordpress-importer.zip
+
+ - name: Download mock data
+ uses: $/.github/actions/download-with-retry
+ with:
+ url: https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml
+ output: themeunittestdata.wordpress.xml
- name: Import mock data
+ # The importer waits up to 300 s per attachment download and skips the ones that
+ # fail: the cap leaves room for a stalled attachment, not a hung import.
+ timeout-minutes: 15
run: |
- curl -O https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml
npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path="/var/www/${LOCAL_DIR}"
rm themeunittestdata.wordpress.xml
@@ -271,13 +293,15 @@ jobs:
cp ./tests/performance/wp-content/mu-plugins/server-timing.php "./${LOCAL_DIR}/wp-content/mu-plugins/server-timing.php"
- name: Run performance tests
+ id: performance-tests
run: npm run test:performance
env:
TEST_RESULTS_PREFIX: ${{ inputs.subject != 'current' && inputs.subject || '' }}
- name: Archive artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- if: always()
+ # Without test results, a failed setup step would report a second failure here.
+ if: ${{ always() && steps.performance-tests.outcome != 'skipped' }}
with:
name: performance-${{ inputs.multisite && 'multisite' || 'single' }}-${{ inputs.memcached && 'memcached' || 'default' }}-${{ inputs.subject }}
path: artifacts
diff --git a/.github/workflows/reusable-php-compatibility.yml b/.github/workflows/reusable-php-compatibility.yml
index d22ca18a66928..d4bcdad270c40 100644
--- a/.github/workflows/reusable-php-compatibility.yml
+++ b/.github/workflows/reusable-php-compatibility.yml
@@ -35,7 +35,7 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
php-compatibility:
name: Run compatibility checks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
diff --git a/.github/workflows/reusable-phpstan-static-analysis-v1.yml b/.github/workflows/reusable-phpstan-static-analysis-v1.yml
index 321f98189cdf9..aba7162bb2a05 100644
--- a/.github/workflows/reusable-phpstan-static-analysis-v1.yml
+++ b/.github/workflows/reusable-phpstan-static-analysis-v1.yml
@@ -21,8 +21,11 @@ permissions: {}
jobs:
# Runs PHP static analysis tests.
#
- # Violations are reported inline with annotations. For pull requests, the results are also uploaded
- # as an artifact, which the PHPStan Pull Request Comments workflow summarizes in a comment.
+ # Core is analyzed twice, in parallel: the whole codebase with phpstan.neon.dist, and the paths held to a stricter rule
+ # level with phpstan-strict.neon.dist. See tests/phpstan/README.md.
+ #
+ # Violations are reported inline with annotations. For pull requests, the results of each analysis are also uploaded
+ # as an artifact, and the PHPStan Pull Request Comments workflow combines them in a comment.
#
# Performs the following steps:
# - Checks out the repository.
@@ -39,11 +42,33 @@ jobs:
# - Saves the PHPStan result cache.
# - Ensures version-controlled files are not modified or deleted.
phpstan:
- name: Run PHP static analysis
- runs-on: ubuntu-24.04
+ name: Run PHP static analysis (${{ matrix.label }})
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 20
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ # The artifact of the analysis of the whole codebase keeps the name it had before there were two, which is
+ # the name the PHPStan Pull Request Comments workflow on trunk requires. That way the comment is kept up to
+ # date for a pull request whose branch does not have the second analysis yet.
+ #
+ # The analyses are named for their role rather than their rule level, which is read from the configuration
+ # when the results are reported, so that raising either level is an edit of its configuration alone.
+ - analysis: default
+ label: all paths
+ config: phpstan.neon.dist
+ baselines: tests/phpstan/baselines
+ script: phpstan:default
+ artifact: phpstan-results
+ - analysis: strict
+ label: strict paths
+ config: phpstan-strict.neon.dist
+ baselines: tests/phpstan/baselines-strict
+ script: phpstan:strict
+ artifact: phpstan-results-strict
steps:
# For a pull request, the parents of the merge commit are fetched too, to find the files that the base branch
@@ -92,16 +117,21 @@ jobs:
# merged this commit yet runs the workflow it has, and that workflow would prefix-match the
# caches written here: it would analyse without the extensions against reflection derived with
# them. A name of its own leaves those runs restoring only their own caches.
+ #
+ # Each analysis caches separately. Its result cache records the rule level, and is discarded
+ # by a run at another level, so restoring the other analysis's cache would gain nothing.
- name: Cache PHP Static Analysis scan cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .cache # This is defined in the base.neon file.
- key: "phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}"
+ key: "phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}"
restore-keys: |
- phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-
+ phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-
- name: Run PHP static analysis tests
id: phpstan
+ env:
+ SCRIPT: ${{ matrix.script }}
run: |
# The report is written to a file for the steps below, which turn it into annotations,
# the pull request comment, and a check for errors that cannot be reported as warnings.
@@ -111,7 +141,7 @@ jobs:
# The step shell exits on the first failing command, which would also end the step on
# the status of 1 that PHPStan uses for reporting errors. Capture the status instead.
status=0
- composer run phpstan -- -vvv --error-format=json > "${RUNNER_TEMP}/phpstan-report.json" || status=$?
+ composer run "${SCRIPT}" -- -vvv --error-format=json > "${RUNNER_TEMP}/phpstan-report.json" || status=$?
# PHPStan exits 1 when it has errors to report, which is the expected case here and
# is what the annotations are for. Anything higher means it did not finish at all.
@@ -132,11 +162,36 @@ jobs:
- name: Report the analysis results
id: report
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ env:
+ ANALYSIS: ${{ matrix.analysis }}
+ CONFIG: ${{ matrix.config }}
with:
script: |
const fs = require( 'fs' );
- const report = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-report.json`, 'utf8' ) );
+ // The rule level the configuration analyzes at, as a number, or `max`. Only the line of the parameter is
+ // matched, rather than decoding the whole dump, because the JSON PHPStan prints can be invalid: it writes
+ // the `\<` in a message pattern as is, which is not a valid JSON escape.
+ let level = null;
+ try {
+ const parameters = require( 'child_process' ).execFileSync(
+ `${ process.env.GITHUB_WORKSPACE }/vendor/bin/phpstan`,
+ [ 'dump-parameters', `--configuration=${ process.env.CONFIG }`, '--json' ],
+ { encoding: 'utf8' }
+ );
+ const match = parameters.match( /^\s*"level":\s*"?(max|\d+)"?,?$/m );
+ if ( match ) {
+ level = match[ 1 ] === 'max' ? 'max' : Number( match[ 1 ] );
+ }
+ } catch ( error ) {
+ core.warning( `The rule level of ${ process.env.CONFIG } could not be read: ${ error.message }` );
+ }
+
+ // Annotations from the stricter analysis say so, since the same code can pass the other one.
+ const analysis = process.env.ANALYSIS;
+ const titlePrefix = analysis === 'strict' ? `PHPStan (strict${ level === null ? '' : `, level ${ level }` })` : 'PHPStan';
+
+ const report = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-report.json`, { encoding: 'utf8' } ) );
const workspace = `${ process.env.GITHUB_WORKSPACE }/`;
const errors = [];
@@ -150,25 +205,29 @@ jobs:
identifier: message.identifier ?? null,
tip: message.tip ?? null,
ignorable: message.ignorable,
+ fixable: message.fixable ?? false,
} );
}
}
- // Errors that are not specific to a file, such as an `ignoreErrors` entry without a
- // path that no longer matches. These cannot be ignored either.
+ // Errors that are not specific to a file, such as an `ignoreErrors` entry from a config
+ // file PHPStan cannot locate it in. These cannot be ignored either.
for ( const message of report.errors ) {
- errors.push( { file: null, line: null, message, identifier: null, tip: null, ignorable: false } );
+ errors.push( { file: null, line: null, message, identifier: null, tip: null, ignorable: false, fixable: false } );
}
+ // PHPStan marks an error it can fix itself, such as a stale baseline entry, as fixable.
+ const fixHint = 'This can be fixed automatically by running `composer phpstan:fix` (or `npm run typecheck:php:fix`).';
+
for ( const error of errors ) {
- const properties = { title: error.identifier ? `PHPStan: ${ error.identifier }` : 'PHPStan' };
+ const properties = { title: error.identifier ? `${ titlePrefix }: ${ error.identifier }` : titlePrefix };
if ( error.file ) {
properties.file = error.file;
}
if ( error.line ) {
properties.startLine = error.line;
}
- const message = error.tip ? `${ error.message }\n${ error.tip }` : error.message;
+ const message = [ error.message, error.tip, error.fixable ? fixHint : null ].filter( Boolean ).join( '\n' );
if ( error.ignorable ) {
core.warning( message, properties );
} else {
@@ -176,11 +235,16 @@ jobs:
}
}
- // Tips are left out of the results, since they are only shown in the annotations, next to the code.
+ // Tips and whether an error is fixable are left out of the results, since they are only shown in the
+ // annotations, next to the code.
//
// The commit analyzed is the pull request merged into its base branch, whose second parent is the head
// commit. The files with errors that differ between the two are those the base branch has changed, in
// which the line numbers reported can be off in the head commit.
+ //
+ // Each analysis writes its own results. Those of the analysis of the whole codebase also list every
+ // analysis the run makes, so that the comment is not updated from only some of them: an error missing
+ // because its analysis did not upload results would otherwise be shown as resolved.
if ( context.eventName === 'pull_request' ) {
let changedInBase = [];
try {
@@ -195,8 +259,12 @@ jobs:
fs.mkdirSync( `${ process.env.RUNNER_TEMP }/phpstan-results`, { recursive: true } );
fs.writeFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results/results.json`, JSON.stringify( {
pull_request: context.payload.pull_request.number,
+ analysis,
+ level,
+ // Keep this list in step with the `analysis` values of the job's matrix.
+ ...( analysis === 'default' ? { analyses: [ 'default', 'strict' ] } : {} ),
changed_in_base: changedInBase,
- errors: errors.map( ( { tip, ...error } ) => error ),
+ errors: errors.map( ( { tip, fixable, ...error } ) => error ),
} ) );
}
@@ -206,7 +274,7 @@ jobs:
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ github.event_name == 'pull_request' && steps.report.outcome == 'success' }}
with:
- name: phpstan-results
+ name: ${{ matrix.artifact }}
path: ${{ runner.temp }}/phpstan-results/
# Some errors cannot be ignored, so they cannot be reported as warnings either. Most often
@@ -224,7 +292,8 @@ jobs:
- name: Check for errors that cannot be reported as warnings
if: ${{ !cancelled() }}
env:
- BASELINES_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/tests/phpstan/baselines
+ BASELINES_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/${{ matrix.baselines }}
+ LABEL: ${{ matrix.label }}
README_URL: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/tests/phpstan/README.md
run: |
# This step runs even when the analysis above it failed, in which case the report may
@@ -259,28 +328,31 @@ jobs:
#
# A newline renders as a line break rather than a space, so each paragraph is one
# line however long that makes it, and the rendered summary wraps to its own width.
+ #
+ # The heading names the analysis whose baselines are out of date, which is filled in for
+ # the LABEL placeholder when the summary is written, since the heredoc expands nothing.
baselines_summary=$( cat <<'SUMMARY'
- ## PHPStan baselines are out of date
+ ## PHPStan baselines are out of date (LABEL)
An ignored error no longer occurs, or occurs a different number of times, so PHPStan reported it under an `ignore.unmatched` or `ignore.count` identifier.
**If you fixed the error, this is expected.** Each baseline entry records an exact count for a specific file, so that a new occurrence of an already baselined error is reported rather than absorbed. That same exactness means fixing one leaves the baseline describing a state that no longer exists. There is nothing to fix in the code; the baselines just need to catch up.
- Regenerate them and commit the result:
+ Remove the stale entries, and commit the result:
```bash
- npm run typecheck:php:baselines
+ npm run typecheck:php:fix
```
or, outside the Docker environment:
```bash
- composer phpstan:baselines
+ composer phpstan:fix
```
- That rewrites the files under [`tests/phpstan/baselines`][baselines], deletes any whose errors are now all fixed, and updates the list of them in `phpstan.neon.dist`.
+ That runs PHPStan with `--fix`, which lowers the counts in [the baselines][baselines], removes the entries that no longer match, and removes any `@phpstan-ignore` annotation in the code that no longer ignores anything. It then deletes any baseline left with no entries.
- Where the report names an `@phpstan-ignore` annotation in the code rather than a baseline entry, remove that annotation instead; regenerating will not clear it.
+ Alternatively, regenerate the baselines with `npm run typecheck:php:baselines` or `composer phpstan:baselines`. That also deletes any baseline whose errors are now all fixed, but it does not clear an `@phpstan-ignore` annotation.
See [`tests/phpstan/README.md`][readme] for details.
@@ -289,14 +361,14 @@ jobs:
if [ "${ignore_errors}" -gt 0 ]; then
{
- printf '%s\n\n' "${baselines_summary}"
+ printf '%s\n\n' "${baselines_summary/LABEL/${LABEL}}"
echo "[baselines]: ${BASELINES_URL}"
echo "[readme]: ${README_URL}"
} >> "${GITHUB_STEP_SUMMARY}"
- echo "::error title=PHPStan baselines are out of date::An ignored error no longer occurs, or occurs a different number of times. If you fixed it, that is expected: run \`npm run typecheck:php:baselines\` or \`composer phpstan:baselines\` and commit the updated baselines. See ${README_URL}"
+ echo "::error title=PHPStan baselines are out of date (${LABEL})::An ignored error no longer occurs, or occurs a different number of times. If you fixed it, that is expected: run \`npm run typecheck:php:fix\` or \`composer phpstan:fix\` and commit the updated baselines. See ${README_URL}"
else
- echo "::error title=PHPStan reported errors that cannot be ignored::PHPStan reported ${unignorable} error(s) that cannot be ignored or reported as warnings. See the error annotations for details, and ${README_URL} for how to run the analysis locally."
+ echo "::error title=PHPStan reported errors that cannot be ignored (${LABEL})::PHPStan reported ${unignorable} error(s) that cannot be ignored or reported as warnings. See the error annotations for details, and ${README_URL} for how to run the analysis locally."
fi
exit 1
@@ -306,7 +378,7 @@ jobs:
if: ${{ !cancelled() }}
with:
path: .cache
- key: "phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}"
+ key: "phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}"
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
diff --git a/.github/workflows/reusable-phpunit-tests-v1.yml b/.github/workflows/reusable-phpunit-tests-v1.yml
index dc5a0d1edd982..a631b243cd3a9 100644
--- a/.github/workflows/reusable-phpunit-tests-v1.yml
+++ b/.github/workflows/reusable-phpunit-tests-v1.yml
@@ -14,7 +14,7 @@ on:
description: 'Operating system to run tests on'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
repository:
description: 'The repository to check out and test. Defaults to the repository calling this workflow.'
required: false
diff --git a/.github/workflows/reusable-phpunit-tests-v2.yml b/.github/workflows/reusable-phpunit-tests-v2.yml
index 628b5387f0e4f..139c41efccf8c 100644
--- a/.github/workflows/reusable-phpunit-tests-v2.yml
+++ b/.github/workflows/reusable-phpunit-tests-v2.yml
@@ -14,7 +14,7 @@ on:
description: 'Operating system to run tests on'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
repository:
description: 'The repository to check out and test. Defaults to the repository calling this workflow.'
required: false
diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml
index 1e1c85ad0a453..c025ea8d1f576 100644
--- a/.github/workflows/reusable-phpunit-tests-v3.yml
+++ b/.github/workflows/reusable-phpunit-tests-v3.yml
@@ -12,7 +12,7 @@ on:
description: 'Operating system to run tests on'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
repository:
description: 'The repository to check out and test. Defaults to the repository calling this workflow.'
required: false
@@ -114,6 +114,7 @@ env:
LOCAL_PHP: ${{ inputs.php }}-fpm
LOCAL_PHP_XDEBUG: false
LOCAL_PHP_XDEBUG_MODE: 'develop,debug'
+ LOCAL_PHP_PCOV: ${{ inputs.coverage-report }}
LOCAL_DB_TYPE: ${{ inputs.db-type }}
LOCAL_DB_VERSION: ${{ inputs.db-version }}
LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
@@ -292,31 +293,6 @@ jobs:
- name: Install WordPress
run: npm run env:install
- # Installs PCOV as the code coverage driver for the PHPUnit run below.
- #
- # The INI directives tune PCOV for WordPress's codebase:
- # - `pcov.enabled` keeps the Zend hooks active (this is the default, but
- # stated explicitly for clarity).
- # - `pcov.directory` restricts instrumentation to `src/`, so PCOV does not
- # record hits for `vendor/`, `tests/`, or WordPress test fixtures that
- # PHPUnit would discard at report time anyway.
- # - `pcov.initial.files` pre-sizes the internal file tracking array for
- # the thousands of files under `src/`, avoiding reallocation churn
- # during test warmup. The default of 64 is far too low here.
- - name: Install PCOV coverage driver
- if: ${{ inputs.coverage-report }}
- run: |
- docker compose exec -T -u 0 php sh -c '
- pecl install --force pcov-1.0.12 &&
- docker-php-ext-enable pcov &&
- {
- echo "pcov.enabled=1"
- echo "pcov.directory=/var/www/src"
- echo "pcov.initial.files=10000"
- } >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini &&
- php -m | grep -i pcov
- '
-
- name: Run external HTTP tests
if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
diff --git a/.github/workflows/reusable-prepare-gutenberg.yml b/.github/workflows/reusable-prepare-gutenberg.yml
index fd7381550f349..285c2b135788e 100644
--- a/.github/workflows/reusable-prepare-gutenberg.yml
+++ b/.github/workflows/reusable-prepare-gutenberg.yml
@@ -31,7 +31,7 @@ permissions: {}
jobs:
prepare-gutenberg:
name: Gutenberg
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
# Two download attempts of up to six minutes each, where download.js retries internally.
timeout-minutes: 15
outputs:
diff --git a/.github/workflows/reusable-support-json-reader-v1.yml b/.github/workflows/reusable-support-json-reader-v1.yml
index a44aa103208e5..00bdb0de3a865 100644
--- a/.github/workflows/reusable-support-json-reader-v1.yml
+++ b/.github/workflows/reusable-support-json-reader-v1.yml
@@ -44,7 +44,7 @@ jobs:
name: Determine major WordPress version
permissions:
contents: read
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 5
outputs:
version: ${{ steps.major-wp-version.outputs.version }}
@@ -80,7 +80,7 @@ jobs:
name: Determine PHP versions
permissions:
contents: read
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
needs: [ major-wp-version ]
timeout-minutes: 5
outputs:
@@ -123,7 +123,7 @@ jobs:
name: Determine MySQL versions
permissions:
contents: read
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
needs: [ major-wp-version ]
timeout-minutes: 5
outputs:
diff --git a/.github/workflows/reusable-test-core-build-process.yml b/.github/workflows/reusable-test-core-build-process.yml
index 8b42e2b75b72e..90f8dfd0d569e 100644
--- a/.github/workflows/reusable-test-core-build-process.yml
+++ b/.github/workflows/reusable-test-core-build-process.yml
@@ -12,7 +12,7 @@ on:
description: 'Operating system to run tests on'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
directory:
description: 'Directory to run WordPress from. Valid values are `src` or `build`'
required: false
diff --git a/.github/workflows/reusable-test-gutenberg-build-process.yml b/.github/workflows/reusable-test-gutenberg-build-process.yml
index e9c68d232807f..61705c3f96a55 100644
--- a/.github/workflows/reusable-test-gutenberg-build-process.yml
+++ b/.github/workflows/reusable-test-gutenberg-build-process.yml
@@ -14,7 +14,7 @@ on:
description: 'Operating system to run tests on'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
directory:
description: 'Directory to run WordPress from. Valid values are `src` or `build`'
required: false
diff --git a/.github/workflows/reusable-test-local-docker-environment-v1.yml b/.github/workflows/reusable-test-local-docker-environment-v1.yml
index 5d63fbc9aa4b4..fa469a699c446 100644
--- a/.github/workflows/reusable-test-local-docker-environment-v1.yml
+++ b/.github/workflows/reusable-test-local-docker-environment-v1.yml
@@ -12,7 +12,7 @@ on:
description: 'Operating system to test'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
php:
description: 'The version of PHP to use, in the format of X.Y'
required: false
diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml
index 8b05d38ea3d69..cc36c1a80587a 100644
--- a/.github/workflows/reusable-upgrade-testing.yml
+++ b/.github/workflows/reusable-upgrade-testing.yml
@@ -8,7 +8,7 @@ on:
description: 'Operating system to run tests on.'
required: false
type: 'string'
- default: 'ubuntu-24.04'
+ default: 'ubuntu-26.04'
wp:
description: 'The version of WordPress to start with.'
required: true
@@ -95,7 +95,11 @@ jobs:
uses: $/.github/actions/setup-wp-cli
- name: Download WordPress ${{ inputs.wp }}
- run: wp core download --version="${WP_VERSION}"
+ # WP-CLI requests the release from WordPress.org once, so a network error fails the job.
+ # It extracts only after a complete download, so a retry starts from an empty directory.
+ uses: $/.github/actions/run-with-retry
+ with:
+ command: wp core download --version="${WP_VERSION}"
env:
WP_VERSION: ${{ inputs.wp }}
diff --git a/.github/workflows/reusable-workflow-lint.yml b/.github/workflows/reusable-workflow-lint.yml
index a50622decf7cb..ffae1fe618d50 100644
--- a/.github/workflows/reusable-workflow-lint.yml
+++ b/.github/workflows/reusable-workflow-lint.yml
@@ -18,7 +18,7 @@ jobs:
# `run:` script checking, glob syntax validation, and more.
actionlint:
name: Run actionlint
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
timeout-minutes: 5
@@ -52,7 +52,7 @@ jobs:
# - Uploads the SARIF file to GitHub.
zizmor:
name: Zizmor
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
# GitHub Code Security is not enabled on any of the private mirrors.
if: ${{ github.event.repository.private == false }}
permissions:
diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml
index fc9f746a0f878..239e7da9ea403 100644
--- a/.github/workflows/slack-notifications.yml
+++ b/.github/workflows/slack-notifications.yml
@@ -52,7 +52,7 @@ jobs:
# - Constructs and stores a message payload as an output.
prepare:
name: Prepare notifications
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: read
contents: read
@@ -171,7 +171,7 @@ jobs:
failure:
name: Failure notifications
permissions: {}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 20
needs: [ prepare ]
if: ${{ needs.prepare.outputs.previous_conclusion != 'first-failure' && inputs.calling_status == 'failure' || failure() }}
@@ -188,7 +188,7 @@ jobs:
fixed:
name: Fixed notifications
permissions: {}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 20
needs: [ prepare ]
if: ${{ contains( fromJson( '["failure", "cancelled", "none"]' ), needs.prepare.outputs.previous_conclusion ) && inputs.calling_status == 'success' && success() }}
@@ -205,7 +205,7 @@ jobs:
success:
name: Success notifications
permissions: {}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 20
needs: [ prepare ]
if: ${{ inputs.calling_status == 'success' && success() }}
@@ -222,7 +222,7 @@ jobs:
cancelled:
name: Cancelled notifications
permissions: {}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
timeout-minutes: 20
needs: [ prepare ]
if: ${{ inputs.calling_status == 'cancelled' && github.run_attempt == 2 || cancelled() }}
diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml
index 6dc161b3b38b2..9ef0f98821dd9 100644
--- a/.github/workflows/test-and-zip-default-themes.yml
+++ b/.github/workflows/test-and-zip-default-themes.yml
@@ -17,6 +17,7 @@ on:
- 'src/wp-content/themes/twentytwentyone/**'
- 'src/wp-content/themes/twentytwentytwo/**'
- 'src/wp-content/themes/twentytwentyfive/**'
+ - 'src/wp-content/themes/ipsum/**'
# Changes to this workflow file should always verify success.
- '.github/workflows/test-and-zip-default-themes.yml'
pull_request:
@@ -35,6 +36,7 @@ on:
- 'src/wp-content/themes/twentytwentyone/**'
- 'src/wp-content/themes/twentytwentytwo/**'
- 'src/wp-content/themes/twentytwentyfive/**'
+ - 'src/wp-content/themes/ipsum/**'
# Changes to this workflow file should always verify success.
- '.github/workflows/test-and-zip-default-themes.yml'
workflow_dispatch:
@@ -44,12 +46,35 @@ on:
required: true
type: string
default: 'trunk'
+ theme:
+ description: 'The theme to test and zip'
+ required: true
+ type: choice
+ default: 'all'
+ options:
+ - all
+ - ipsum
+ - twentytwentyfive
+ - twentytwentyfour
+ - twentytwentythree
+ - twentytwentytwo
+ - twentytwentyone
+ - twentytwenty
+ - twentynineteen
+ - twentyseventeen
+ - twentysixteen
+ - twentyfifteen
+ - twentyfourteen
+ - twentythirteen
+ - twentytwelve
+ - twentyeleven
+ - twentyten
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
- # or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ # The concurrency group contains the workflow name and the pull request number for pull requests
+ # or the commit hash for any other events, plus the selected branch and theme.
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}-${{ inputs.branch }}-${{ inputs.theme }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -57,6 +82,70 @@ concurrency:
permissions: {}
jobs:
+ # Selects the themes to check, build, and package.
+ determine-themes:
+ name: Determine Themes
+ runs-on: ubuntu-26.04
+ permissions: {}
+ timeout-minutes: 5
+ if: |
+ github.repository == 'WordPress/wordpress-develop' || (
+ github.event_name == 'pull_request' && (
+ ! github.event.repository.private ||
+ ! github.event.pull_request.draft ||
+ contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' )
+ )
+ )
+ outputs:
+ themes: ${{ steps.set-themes.outputs.themes }}
+ build_themes: ${{ steps.set-themes.outputs.build_themes }}
+ has_build_themes: ${{ steps.set-themes.outputs.has_build_themes }}
+ steps:
+ - name: Determine themes to test and zip
+ id: set-themes
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const allThemes = [
+ 'ipsum',
+ 'twentytwentyfive',
+ 'twentytwentyfour',
+ 'twentytwentythree',
+ 'twentytwentytwo',
+ 'twentytwentyone',
+ 'twentytwenty',
+ 'twentynineteen',
+ 'twentyseventeen',
+ 'twentysixteen',
+ 'twentyfifteen',
+ 'twentyfourteen',
+ 'twentythirteen',
+ 'twentytwelve',
+ 'twentyeleven',
+ 'twentyten',
+ ];
+ const buildThemes = [
+ 'ipsum',
+ 'twentytwentyfive',
+ 'twentytwentytwo',
+ 'twentytwentyone',
+ 'twentytwenty',
+ 'twentynineteen',
+ ];
+ const selected = context.eventName === 'workflow_dispatch' ? ( context.payload.inputs?.theme || 'all' ) : 'all';
+
+ if ( selected !== 'all' && ! allThemes.includes( selected ) ) {
+ core.setFailed( 'Unknown theme selected.' );
+ return;
+ }
+
+ const themes = selected === 'all' ? allThemes : [ selected ];
+ const filteredBuildThemes = buildThemes.filter( ( theme ) => themes.includes( theme ) );
+
+ core.setOutput( 'themes', JSON.stringify( themes ) );
+ core.setOutput( 'build_themes', JSON.stringify( filteredBuildThemes ) );
+ core.setOutput( 'has_build_themes', filteredBuildThemes.length > 0 );
+
# Checks for zero-byte files.
#
# Occasionally, binary files such as images and fonts are added to themes incorrectly.
@@ -67,39 +156,15 @@ jobs:
# - Checks for zero-byte (empty) files.
check-for-empty-files:
name: ${{ matrix.theme }} empty file check
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
+ needs: [ determine-themes ]
timeout-minutes: 10
- if: |
- github.repository == 'WordPress/wordpress-develop' || (
- github.event_name == 'pull_request' && (
- ! github.event.repository.private ||
- ! github.event.pull_request.draft ||
- contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' )
- )
- )
strategy:
fail-fast: false
matrix:
- theme: [
- 'ipsum',
- 'twentytwentyfive',
- 'twentytwentyfour',
- 'twentytwentythree',
- 'twentytwentytwo',
- 'twentytwentyone',
- 'twentytwenty',
- 'twentynineteen',
- 'twentyseventeen',
- 'twentysixteen',
- 'twentyfifteen',
- 'twentyfourteen',
- 'twentythirteen',
- 'twentytwelve',
- 'twentyeleven',
- 'twentyten'
- ]
+ theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }}
steps:
- name: Checkout repository
@@ -139,28 +204,17 @@ jobs:
# - Ensures version-controlled files are not modified or deleted.
test-build-scripts:
name: Test ${{ matrix.theme }} build script
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
+ needs: [ determine-themes ]
timeout-minutes: 10
- if: |
- github.repository == 'WordPress/wordpress-develop' || (
- github.event_name == 'pull_request' && (
- ! github.event.repository.private ||
- ! github.event.pull_request.draft ||
- contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' )
- )
- )
+ # Skip this job before expanding an empty build matrix.
+ if: ${{ needs.determine-themes.outputs.has_build_themes == 'true' }}
strategy:
fail-fast: false
matrix:
- theme: [
- 'twentytwentyfive',
- 'twentytwentytwo',
- 'twentytwentyone',
- 'twentytwenty',
- 'twentynineteen',
- ]
+ theme: ${{ fromJson( needs.determine-themes.outputs.build_themes ) }}
defaults:
run:
@@ -246,33 +300,21 @@ jobs:
# - Uploads the theme files as a workflow artifact (files uploaded as an artifact are automatically zipped).
bundle-theme:
name: Create ${{ matrix.theme }} ZIP file
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
contents: read
- needs: [ check-for-empty-files, test-build-scripts ]
+ needs: [ determine-themes, check-for-empty-files, test-build-scripts ]
timeout-minutes: 10
- if: ${{ github.repository == 'WordPress/wordpress-develop' }}
+ if: |
+ ! cancelled() &&
+ github.repository == 'WordPress/wordpress-develop' &&
+ needs.determine-themes.result == 'success' &&
+ needs.check-for-empty-files.result == 'success' &&
+ ( needs.test-build-scripts.result == 'success' || needs.test-build-scripts.result == 'skipped' )
strategy:
fail-fast: false
matrix:
- theme: [
- 'ipsum',
- 'twentytwentyfive',
- 'twentytwentyfour',
- 'twentytwentythree',
- 'twentytwentytwo',
- 'twentytwentyone',
- 'twentytwenty',
- 'twentynineteen',
- 'twentyseventeen',
- 'twentysixteen',
- 'twentyfifteen',
- 'twentyfourteen',
- 'twentythirteen',
- 'twentytwelve',
- 'twentyeleven',
- 'twentyten'
- ]
+ theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }}
steps:
- name: Checkout repository
@@ -291,12 +333,16 @@ jobs:
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Theme ${THEME} does not exist on the selected branch."
+ if [[ "${SELECTED_THEME}" != 'all' ]]; then
+ exit 1
+ fi
fi
env:
THEME: ${{ matrix.theme }}
+ SELECTED_THEME: ${{ github.event_name == 'workflow_dispatch' && inputs.theme || 'all' }}
- name: Set up Node.js for themes needing minification
- if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' ) }}
+ if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: 'src/wp-content/themes/${{ matrix.theme }}/.nvmrc'
@@ -304,18 +350,18 @@ jobs:
- name: Set up npm
# A workflow_dispatch run can check out a release branch, which lacks the action.
- if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' ) && hashFiles('.github/actions/setup-npm/action.yml') != '' }}
+ if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) && hashFiles('.github/actions/setup-npm/action.yml') != '' }}
uses: ./.github/actions/setup-npm
with:
working-directory: src/wp-content/themes/${{ matrix.theme }}
- name: Install npm dependencies
- if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' ) }}
+ if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }}
run: npm ci
working-directory: src/wp-content/themes/${{ matrix.theme }}
- name: Build theme assets
- if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' ) }}
+ if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }}
run: npm run build
working-directory: src/wp-content/themes/${{ matrix.theme }}
@@ -335,7 +381,7 @@ jobs:
permissions:
actions: read
contents: read
- needs: [ check-for-empty-files, bundle-theme, test-build-scripts ]
+ needs: [ determine-themes, check-for-empty-files, bundle-theme, test-build-scripts ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
@@ -347,7 +393,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/test-build-processes.yml b/.github/workflows/test-build-processes.yml
index ed970276e9833..c64bc260c7439 100644
--- a/.github/workflows/test-build-processes.yml
+++ b/.github/workflows/test-build-processes.yml
@@ -50,9 +50,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -77,12 +77,12 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
directory: [ 'src', 'build' ]
test-certificates: [ true ]
include:
# Only prepare artifacts for Playground once.
- - os: 'ubuntu-24.04'
+ - os: 'ubuntu-26.04'
directory: 'build'
save-build: true
prepare-playground: ${{ github.event_name == 'pull_request' && true || '' }}
@@ -112,7 +112,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'macos-15', 'windows-2025' ]
+ os: [ 'macos-26', 'windows-2025' ]
directory: [ 'src', 'build' ]
with:
os: ${{ matrix.os }}
@@ -136,7 +136,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml
index c29be2fb4043e..583a6045213dc 100644
--- a/.github/workflows/test-coverage.yml
+++ b/.github/workflows/test-coverage.yml
@@ -38,9 +38,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -102,7 +102,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml
index 37425c8b3983c..a7d2ddcb01836 100644
--- a/.github/workflows/test-old-branches.yml
+++ b/.github/workflows/test-old-branches.yml
@@ -30,7 +30,7 @@ env:
jobs:
dispatch-workflows-for-old-branches:
name: ${{ matrix.workflow }} for ${{ matrix.branch }}
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
timeout-minutes: 20
diff --git a/.github/workflows/upgrade-develop-testing.yml b/.github/workflows/upgrade-develop-testing.yml
index e097bac30c24f..dcd921c2e6c7e 100644
--- a/.github/workflows/upgrade-develop-testing.yml
+++ b/.github/workflows/upgrade-develop-testing.yml
@@ -15,6 +15,7 @@ on:
- '*.php' # PHP files in the root, like wp-config-sample.php.
# Confirm any changes to relevant workflow files.
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/actions/smoke-check/**'
- '.github/actions/setup-npm/**'
- '.github/workflows/upgrade-develop-testing.yml'
@@ -31,6 +32,7 @@ on:
# Confirm any changes to relevant workflow files.
- '.github/actions/setup-npm/**'
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/workflows/upgrade-develop-testing.yml'
- '.github/workflows/reusable-upgrade-testing.yml'
schedule:
@@ -39,9 +41,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -85,7 +87,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4', '8.4' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.4' ]
@@ -120,7 +122,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4', '8.4' ]
db-type: [ 'mysql' ]
db-version: [ '8.4' ]
@@ -153,7 +155,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/upgrade-testing.yml b/.github/workflows/upgrade-testing.yml
index 9eadc0683f8d9..d4817522585d9 100644
--- a/.github/workflows/upgrade-testing.yml
+++ b/.github/workflows/upgrade-testing.yml
@@ -10,6 +10,7 @@ on:
# Always test the workflow after it's updated.
paths:
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/actions/smoke-check/**'
- '.github/workflows/upgrade-testing.yml'
- '.github/workflows/reusable-upgrade-testing.yml'
@@ -20,6 +21,7 @@ on:
# Always test the workflow when changes are suggested.
paths:
- '.github/actions/setup-wp-cli/**'
+ - '.github/actions/run-with-retry/**'
- '.github/workflows/upgrade-testing.yml'
- '.github/workflows/reusable-upgrade-testing.yml'
workflow_dispatch:
@@ -31,9 +33,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ inputs.new-version || github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ inputs.new-version || github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -73,7 +75,7 @@ jobs:
# "latest" and "nightly" drop nothing. Any other unrecognized target is treated the same way, with a warning.
build-test-matrix:
name: Build Test Matrix
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions: {}
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
timeout-minutes: 5
@@ -161,10 +163,10 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
db-type: [ 'mysql' ]
- db-version: [ '5.7', '8.0', '8.4', '9.7' ]
+ db-version: [ '5.7', '8.0', '8.4', '9.7', '26.10' ]
wp: ${{ fromJSON( needs.build-test-matrix.outputs.recent-releases ) }}
multisite: [ false, true ]
with:
@@ -187,7 +189,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4', '8.0', '8.4' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.4' ]
@@ -213,7 +215,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.4' ]
@@ -243,7 +245,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '8.0', '8.4' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.4' ]
@@ -274,10 +276,10 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ 'ubuntu-24.04' ]
+ os: [ 'ubuntu-26.04' ]
php: [ '7.4' ]
db-type: [ 'mysql' ]
- db-version: [ '5.7', '8.0', '8.4', '9.7' ]
+ db-version: [ '5.7', '8.0', '8.4', '9.7', '26.10' ]
wp: ${{ fromJSON( needs.build-test-matrix.outputs.oldest-wp ) }}
multisite: [ false, true ]
with:
@@ -308,7 +310,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.github/workflows/workflow-lint.yml b/.github/workflows/workflow-lint.yml
index 315cb833c2b18..ea58b4cb50980 100644
--- a/.github/workflows/workflow-lint.yml
+++ b/.github/workflows/workflow-lint.yml
@@ -22,9 +22,9 @@ on:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
- # The concurrency group contains the workflow name and the branch name for pull requests
+ # The concurrency group contains the workflow name and the pull request number for pull requests
# or the commit hash for any other events.
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
@@ -66,7 +66,7 @@ jobs:
failed-workflow:
name: Failed workflow tasks
- runs-on: ubuntu-24.04
+ runs-on: ubuntu-26.04
permissions:
actions: write
needs: [ slack-notifications ]
diff --git a/.gitignore b/.gitignore
index f96e379fbb304..24b4282326304 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ wp-tests-config.php
/tests/phpunit/build
/wp-cli.local.yml
/phpstan.neon
+/phpstan-strict.neon
/*.tsbuildinfo
/jsdoc
/composer.lock
@@ -88,6 +89,7 @@ wp-tests-config.php
/src/wp-content/object-cache.php
/src/wp-content/php-error.php
/src/wp-content/sunrise.php
+/src/wp-content/test-suite-uploads
# Files and folders relating to wp-content build tools.
/src/wp-content/themes/twentynineteen/node_modules
@@ -95,10 +97,12 @@ wp-tests-config.php
/src/wp-content/themes/twentytwenty/node_modules
/src/wp-content/themes/twentytwentytwo/node_modules
/src/wp-content/themes/twentytwentyfive/node_modules
+/src/wp-content/themes/ipsum/node_modules
# Minified files in bundled themes
/src/wp-content/themes/twentytwentytwo/*.min.css
/src/wp-content/themes/twentytwentyfive/*.min.css
+/src/wp-content/themes/ipsum/*.min.css
# Operating system specific files
.DS_Store
diff --git a/.version-support-mysql.json b/.version-support-mysql.json
index c7bda38ff5fe9..68c6d2ac77407 100644
--- a/.version-support-mysql.json
+++ b/.version-support-mysql.json
@@ -1,5 +1,7 @@
{
"7-2": [
+ "26.10",
+ "26.7",
"9.7",
"8.4",
"8.0",
diff --git a/.version-support-php.json b/.version-support-php.json
index fc0128345fdb5..31d8169338822 100644
--- a/.version-support-php.json
+++ b/.version-support-php.json
@@ -6,7 +6,8 @@
"8.2",
"8.3",
"8.4",
- "8.5"
+ "8.5",
+ "8.6"
],
"7-1": [
"7.4",
diff --git a/Gruntfile.js b/Gruntfile.js
index f96eda8ce5f61..0a9270f436847 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -12,6 +12,15 @@ module.exports = function(grunt) {
SOURCE_DIR = 'src/',
BUILD_DIR = 'build/',
WORKING_DIR = grunt.option( 'dev' ) ? SOURCE_DIR : BUILD_DIR,
+ /*
+ * With --symlink, when building into /src, the wp-admin and wp-includes scripts that are copied unchanged from
+ * /src/js/_enqueues are symlinked instead, so that edits to them take effect without a rebuild.
+ *
+ * This is opt-in because Docker Desktop's file sharing can keep serving the previous entry for a path whose
+ * file is replaced, by a symlink or by a file in place of one, failing to read it until the containers are
+ * restarted (`npm run env:restart`). For the same reason, the links in place are kept by later builds.
+ */
+ linkScripts = WORKING_DIR === SOURCE_DIR && grunt.option( 'symlink' ) === true,
BANNER_TEXT = '/*! This file is auto-generated */',
autoprefixer = require( 'autoprefixer' ),
sass = require( 'sass' ),
@@ -30,6 +39,7 @@ module.exports = function(grunt) {
'wp-content/plugins/hello.php',
'wp-content/plugins/akismet/**',
'!wp-content/themes/twenty*/node_modules/**',
+ '!wp-content/themes/ipsum/node_modules/**',
],
// All built CSS files, in /src or /build.
@@ -139,8 +149,7 @@ module.exports = function(grunt) {
'copy',
'cssmin',
'jshint',
- 'uglify',
- 'watch'
+ 'uglify'
],
'standard': [
'banner',
@@ -260,14 +269,28 @@ module.exports = function(grunt) {
css: cssFiles.map( function( file ) {
return setFilePath( WORKING_DIR, file );
} ),
- js: jsFiles.map( function( file ) {
+ js: linkScripts ? {
+ // Clean the files in wp-admin/js one by one, so that the links in place are kept. See the link task.
+ src: jsFiles.map( function( file ) {
+ return setFilePath( WORKING_DIR, 'wp-admin/js/' === file ? 'wp-admin/js/**' : file );
+ } ),
+ filter: function( filepath ) {
+ return ! isLinkedScriptPath( filepath );
+ }
+ } : jsFiles.map( function( file ) {
return setFilePath( WORKING_DIR, file );
} ),
// Clean files built by Webpack.
- 'webpack-assets': webpackFiles.map( function( file ) {
- return setFilePath( WORKING_DIR, file );
- } ),
+ 'webpack-assets': {
+ src: webpackFiles.map( function( file ) {
+ return setFilePath( WORKING_DIR, file );
+ } ),
+ // Keep the link to media-editor.js, which media-*.js matches. See the link task.
+ filter: function( filepath ) {
+ return ! linkScripts || ! isLinkedScriptPath( filepath );
+ }
+ },
/*
* Clean files sourced from the downloaded zip file built by the Gutenberg repository.
@@ -902,6 +925,7 @@ module.exports = function(grunt) {
src: [
'wp-content/themes/twentytwentytwo/style.css',
'wp-content/themes/twentytwentyfive/style.css',
+ 'wp-content/themes/ipsum/style.css',
]
}
},
@@ -1646,29 +1670,37 @@ module.exports = function(grunt) {
},
_watch: {
options: {
- interval: 2000
+ // Directories that are never watched, so that they are not searched.
+ ignored: [
+ '**/.{svn,git}/**',
+ '**/node_modules/**',
+ 'vendor/**',
+ BUILD_DIR + '**',
+ // Third-party plugins, other than those that the build copies.
+ SOURCE_DIR + 'wp-content/plugins/!(index.php|hello.php|akismet)/**',
+ // Third-party themes.
+ SOURCE_DIR + 'wp-content/themes/!(twenty*|ipsum|index.php)/**',
+ // Uploads, translations, and other content that is not part of the build.
+ SOURCE_DIR + 'wp-content/!(index.php|plugins|themes)/**'
+ ]
},
+ /*
+ * Copies changed files from /src to /build. Its files are those of the copy:files task, set below, so
+ * that the same files are copied as by the build. When building into /src with --dev, there is nothing to
+ * copy, so this target is removed.
+ */
all: {
- files: [
- SOURCE_DIR + '**',
- '!' + SOURCE_DIR + 'js/**/*.js',
- // Ignore version control directories.
- '!' + SOURCE_DIR + '**/.{svn,git}/**',
- // Ignore third-party plugins.
- '!' + SOURCE_DIR + 'wp-content/plugins/**'
- ],
- tasks: ['clean:dynamic', 'copy:dynamic'],
+ files: [],
+ tasks: ['watch-dynamic:all', 'clean:dynamic', 'copy:dynamic', 'copy:dynamic-js'],
options: {
- dot: true,
- spawn: false
+ dot: true
}
},
'js-enqueues': {
files: [SOURCE_DIR + 'js/_enqueues/**/*.js'],
- tasks: ['clean:dynamic', 'copy:dynamic-js', 'uglify:dynamic'],
+ tasks: ['watch-dynamic:js-enqueues', 'clean:dynamic', 'copy:dynamic-js', 'uglify:dynamic', 'watch-uglify'],
options: {
- dot: true,
- spawn: false
+ dot: true
}
},
'js-webpack': {
@@ -1677,31 +1709,33 @@ module.exports = function(grunt) {
'!' + SOURCE_DIR + 'js/_enqueues/**/*.js',
'webpack-dev.config.js'
],
- tasks: ['clean:dynamic', 'webpack:dev', 'uglify:dynamic'],
+ tasks: ['watch-dynamic:js-webpack', 'clean:dynamic', 'webpack:dev'],
options: {
- dot: true,
- spawn: false
+ dot: true
}
},
config: {
files: [
'Gruntfile.js',
'webpack.config.js'
- ]
+ ],
+ options: {
+ reload: true
+ }
},
colors: {
- files: [SOURCE_DIR + 'wp-admin/css/colors/**'],
+ files: [SOURCE_DIR + 'wp-admin/css/colors/**/*.scss'],
tasks: ['sass:colors']
},
rtl: {
files: [
SOURCE_DIR + 'wp-admin/css/*.css',
- SOURCE_DIR + 'wp-includes/css/*.css'
+ SOURCE_DIR + 'wp-includes/css/*.css',
+ // Built stylesheets, written next to the sources with --dev.
+ '!' + SOURCE_DIR + '{wp-admin,wp-includes}/css/*.min.css',
+ '!' + SOURCE_DIR + '{wp-admin,wp-includes}/css/*-rtl*.css'
],
- tasks: ['rtlcss:dynamic'],
- options: {
- spawn: false
- }
+ tasks: ['watch-dynamic:rtl', 'rtlcss:dynamic']
},
test: {
files: [
@@ -1720,6 +1754,35 @@ module.exports = function(grunt) {
grunt.config.set( 'copy.files.files', copyFilesOptions );
}
+ if ( WORKING_DIR === SOURCE_DIR ) {
+ // When building into /src, there is nothing for the `all` watch target to copy, so its files are not watched.
+ delete grunt.config.data._watch.all;
+ } else {
+ /*
+ * Watch the files that the copy:files task copies, so that a change is copied as by the build, including
+ * the sources it copies to other paths, such as _index.php, and wp-config-sample.php from the root.
+ */
+ grunt.config( [ '_watch', 'all', 'files' ], grunt.config( 'copy.files.files' )[0].src.map( function( pattern ) {
+ return pattern.charAt( 0 ) === '!' ? '!' + SOURCE_DIR + pattern.slice( 1 ) : SOURCE_DIR + pattern;
+ } ).concat( Object.keys( getMappedBuildFiles() ).map( function( dest ) {
+ return getMappedBuildFiles()[ dest ];
+ } ) ) );
+ }
+
+ /*
+ * The `phpunit` watch target, also added here rather than only by the `watch` task, so that the watch task has
+ * it after restarting for a change to this file.
+ */
+ if ( /^_?watch:phpunit$/.test( grunt.cli.tasks[ 0 ] ) || 'undefined' !== typeof grunt.option( 'phpunit' ) ) {
+ grunt.config( [ '_watch', 'phpunit' ], {
+ files: [
+ SOURCE_DIR + '**/*.php',
+ 'tests/phpunit/**/*.php'
+ ],
+ tasks: [ 'phpunit:default' ]
+ } );
+ }
+
// Register tasks.
@@ -1798,20 +1861,13 @@ module.exports = function(grunt) {
} );
} );
- grunt.renameTask( 'watch', '_watch' );
+ grunt.registerTask( '_watch', 'Runs the tasks of the watch targets whose files change.', require( './tools/watch/task.js' )( grunt ) );
grunt.registerTask( 'watch', 'Watches files for changes and runs the related tasks. Use watch:phpunit or --phpunit to also run PHPUnit tests.', function() {
if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) {
grunt.task.run( 'build' );
}
- if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] || 'undefined' !== typeof grunt.option( 'phpunit' ) ) {
- grunt.config.data._watch.phpunit = {
- files: [ '**/*.php' ],
- tasks: [ 'phpunit:default' ]
- };
- }
-
grunt.task.run( '_' + this.nameArgs );
} );
@@ -1986,10 +2042,123 @@ module.exports = function(grunt) {
grunt.registerTask( 'copy:js', 'Copies JavaScript files from npm packages, vendor libraries, wp-admin, and wp-includes.', [
'copy:npm-packages',
'copy:vendor-js',
- 'copy:admin-js',
- 'copy:includes-js'
+ linkScripts ? 'link:admin-js' : 'copy:admin-js',
+ linkScripts ? 'link:includes-js' : 'copy:includes-js'
] );
+ /**
+ * Checks whether a path is a symlink, including one whose target no longer exists.
+ *
+ * @param {string} filepath Path to check.
+ * @return {boolean} Whether the path is a symlink.
+ */
+ function isSymlink( filepath ) {
+ try {
+ return fs.lstatSync( filepath ).isSymbolicLink();
+ } catch ( e ) {
+ return false;
+ }
+ }
+
+ // The scripts' symlinks in place before the build, and the directories that hold them, keyed by path.
+ var linkedScriptPaths = null;
+
+ /**
+ * Checks whether a path is a script's symlink as created by the link task, or a directory that holds one.
+ *
+ * @param {string} filepath Path to check.
+ * @return {boolean} Whether the path is or holds a script's symlink.
+ */
+ function isLinkedScriptPath( filepath ) {
+ var files, dest;
+
+ // Collect the links and the directories that hold them once, as the clean tasks check each path.
+ if ( ! linkedScriptPaths ) {
+ linkedScriptPaths = {};
+ files = Object.assign( {},
+ grunt.config( [ 'copy', 'admin-js', 'files' ] ),
+ grunt.config( [ 'copy', 'includes-js', 'files' ] )
+ );
+ Object.keys( files ).forEach( function( linkPath ) {
+ if ( ! isSymlink( linkPath ) || fs.readlinkSync( linkPath ) !== path.relative( path.dirname( linkPath ), files[ linkPath ][ 0 ] ) ) {
+ return;
+ }
+ linkedScriptPaths[ linkPath ] = true;
+ for ( dest = path.dirname( linkPath ); dest !== '.' && ! linkedScriptPaths[ dest ]; dest = path.dirname( dest ) ) {
+ linkedScriptPaths[ dest ] = true;
+ }
+ } );
+ }
+
+ return !! linkedScriptPaths[ filepath.replace( /\/$/, '' ) ];
+ }
+
+ grunt.registerTask( 'link', 'Symlinks the files of a copy task to their sources, falling back to copying them where symlinks cannot be created.', function( target ) {
+ var files = grunt.config( [ 'copy', target, 'files' ] );
+ var linked = 0;
+ var unchanged = 0;
+ var copied = 0;
+ var canLink = true;
+
+ if ( ! files ) {
+ grunt.fail.warn( 'The copy:' + target + ' task has no files to link.' );
+ return;
+ }
+
+ Object.keys( files ).forEach( function( dest ) {
+ var src = files[ dest ][ 0 ];
+ var linkTarget = path.relative( path.dirname( dest ), src );
+
+ /*
+ * Keep a link that is already in place. Docker Desktop's file sharing can keep serving the previous
+ * entry for a path that is replaced, failing to read it until the containers are restarted.
+ */
+ if ( isSymlink( dest ) && fs.readlinkSync( dest ) === linkTarget && grunt.file.exists( src ) ) {
+ unchanged++;
+ return;
+ }
+
+ // Remove the previous copy or link, so that neither is written through.
+ if ( isSymlink( dest ) || grunt.file.exists( dest ) ) {
+ fs.unlinkSync( dest );
+ }
+
+ // Like the copy task, skip a source that does not exist.
+ if ( ! grunt.file.exists( src ) ) {
+ grunt.verbose.writeln( 'Source file ' + src + ' not found.' );
+ return;
+ }
+ grunt.file.mkdir( path.dirname( dest ) );
+
+ if ( canLink ) {
+ try {
+ // A relative link also resolves inside the Docker containers, which mount the repository elsewhere.
+ fs.symlinkSync( linkTarget, dest, 'file' );
+ linked++;
+ return;
+ } catch ( e ) {
+ // Creating symlinks on Windows requires Developer Mode or administrator rights.
+ if ( [ 'EPERM', 'EACCES', 'ENOTSUP', 'ENOSYS' ].indexOf( e.code ) === -1 ) {
+ throw e;
+ }
+ canLink = false;
+ grunt.log.writeln( 'Symlinks cannot be created (' + e.code + '), so the files are copied instead.' );
+ }
+ }
+
+ grunt.file.copy( src, dest );
+ copied++;
+ } );
+
+ grunt.log.ok( 'Linked ' + linked + ' ' + grunt.util.pluralize( linked, 'file/files' ) +
+ ( unchanged ? ', kept ' + unchanged + ' existing ' + grunt.util.pluralize( unchanged, 'link/links' ) : '' ) +
+ ( copied ? ', copied ' + copied + ' ' + grunt.util.pluralize( copied, 'file/files' ) : '' ) + '.' );
+
+ if ( linked ) {
+ grunt.log.writeln( 'If the local environment cannot read the linked files, restart it with `npm run env:restart`.' );
+ }
+ } );
+
grunt.registerTask( 'uglify:all', 'Minifies all JavaScript files.', [
'uglify:core',
'uglify:emoji-loader',
@@ -2496,104 +2665,227 @@ module.exports = function(grunt) {
grunt.registerTask('default', 'Runs the build task.', ['build']);
/*
- * Automatically updates the `:dynamic` configurations
- * so that only the changed files are updated.
+ * Changes seen by each watch target since its tasks last ran, keyed by file path.
+ *
+ * The watch task runs the tasks of a target once for all the changes made within its debounce delay, so the
+ * changes are collected here and the `:dynamic` configurations are set from all of them when the tasks run,
+ * by the `watch-dynamic` task, which each target runs first.
*/
- grunt.event.on( 'watch', function( action, filepath, target ) {
- var src;
+ var watchedChanges = {};
- // Only configure the dynamic tasks based on known targets.
- if ( [ 'all', 'rtl', 'webpack', 'js-enqueues', 'js-webpack' ].indexOf( target ) === -1 ) {
+ // The uglify targets to run for the changed scripts that the uglify:core task does not minify.
+ var watchedUglifyTargets = [];
+
+ grunt.event.on( 'watch', function( action, filepath, target ) {
+ if ( [ 'all', 'rtl', 'js-enqueues', 'js-webpack' ].indexOf( target ) === -1 ) {
return;
}
+ watchedChanges[ target ] = watchedChanges[ target ] || {};
+
// Normalize filepath for Windows.
- filepath = filepath.replace( /\\/g, '/' );
-
- // If the target is a file in the restructured js src.
- if ( target === 'js-enqueues' ) {
- var files = {};
- var configs, dest;
-
- // If it's a vendor file which are configured with glob matchers.
- if ( filepath.indexOf( SOURCE_DIR + 'js/_enqueues/vendor/' ) === 0 ) {
- // Grab the glob matchers from the copy task.
- configs = grunt.config( [ 'copy', 'vendor-js', 'files' ] );
-
- // For each glob matcher check if it matches and if so set the variables for our dynamic tasks.
- for ( var i = 0; i < configs.length; i++ ) {
- var config = configs[ i ];
- var relative = path.relative( config.cwd, filepath );
- var minimatch = require('minimatch');
-
- if ( minimatch.match( config.src, relative, {} ) ) {
- dest = config.dest + relative;
- src = [ path.relative( WORKING_DIR, dest ) ];
- files[ dest ] = [ filepath ];
- break;
- }
+ watchedChanges[ target ][ filepath.replace( /\\/g, '/' ) ] = action;
+ } );
+
+ /**
+ * Gets the destination of a file in the restructured js src, relative to the working directory.
+ *
+ * @param {string} filepath Path of the source file.
+ * @return {?{dest: string, src: string}} The destination and source of the copy, or null if the file is not copied.
+ */
+ function getEnqueuedScriptCopy( filepath ) {
+ var configs, i, dest, relative;
+
+ // If it's a vendor file which are configured with glob matchers.
+ if ( filepath.indexOf( SOURCE_DIR + 'js/_enqueues/vendor/' ) === 0 ) {
+ configs = grunt.config( [ 'copy', 'vendor-js', 'files' ] );
+
+ // Find the glob matcher that copies it. The other entries map files from node_modules.
+ for ( i = 0; i < configs.length; i++ ) {
+ if ( ! configs[ i ].cwd ) {
+ continue;
}
- // Or if it's another file which has a straight mapping.
- } else {
- configs = Object.assign( {},
- grunt.config( [ 'copy', 'admin-js', 'files' ] ),
- grunt.config( [ 'copy', 'includes-js', 'files' ] )
- );
+ relative = path.relative( configs[ i ].cwd, filepath ).replace( /\\/g, '/' );
- for ( dest in configs ) {
- // If a file in the mapping matches then set the variables for our dynamic tasks.
- if ( dest && configs.hasOwnProperty( dest ) && configs[ dest ][0] === './' + filepath ) {
- files[ dest ] = configs[ dest ];
- src = [ path.relative( WORKING_DIR, dest ) ];
- break;
- }
+ if ( relative.indexOf( '../' ) !== 0 && grunt.file.isMatch( configs[ i ].src, relative ) ) {
+ return { dest: configs[ i ].dest + relative, src: filepath };
}
}
+ return null;
+ }
+
+ // Or if it's another file which has a straight mapping.
+ configs = Object.assign( {},
+ grunt.config( [ 'copy', 'admin-js', 'files' ] ),
+ grunt.config( [ 'copy', 'includes-js', 'files' ] )
+ );
- // Configure our dynamic-js copy task which uses a file mapping rather than simply copying from src to build.
- if ( action !== 'deleted' ) {
- grunt.config( [ 'copy', 'dynamic-js', 'files' ], files );
+ for ( dest in configs ) {
+ if ( configs.hasOwnProperty( dest ) && configs[ dest ][ 0 ] === './' + filepath ) {
+ return { dest: dest, src: configs[ dest ][ 0 ] };
}
- // For the webpack builds configure the task to only check those files built by webpack.
- } else if ( target === 'js-webpack' ) {
- src = [
- 'wp-includes/js/media-audiovideo.js',
- 'wp-includes/js/media-grid.js',
- 'wp-includes/js/media-models.js',
- 'wp-includes/js/media-views.js'
- ];
- // Else simply use the path relative to the source directory.
- } else {
- src = [ path.relative( SOURCE_DIR, filepath ) ];
}
+ return null;
+ }
- if ( ! src ) {
- grunt.warn( 'Failed to determine the destination file.' );
- return;
- }
+ /**
+ * Gets the files that the copy:files task copies other than by its glob patterns in /src: those it copies to
+ * another path, such as _index.php to index.php, and wp-config-sample.php from the root.
+ *
+ * @return {ObjectSystem Requirements
Recommendations
' . $plugins_page );
- }
-
- if ( 'themezip' === $form ) {
+ } else {
$themes_page = sprintf(
'%s',
self_admin_url( 'theme-install.php' ),
diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php
index 43f211bbd092a..59a144ed4adc6 100644
--- a/src/wp-admin/includes/class-language-pack-upgrader.php
+++ b/src/wp-admin/includes/class-language-pack-upgrader.php
@@ -68,9 +68,15 @@ public static function async_upgrade( $upgrader = false ) {
return;
}
+ $deferred_updates = wp_get_deferred_translation_updates( $language_updates );
+
foreach ( $language_updates as $key => $language_update ) {
$update = ! empty( $language_update->autoupdate );
+ if ( $update && wp_is_translation_update_deferred( $language_update, $deferred_updates ) ) {
+ $update = false;
+ }
+
/**
* Filters whether to asynchronously update translation for core, a plugin, or a theme.
*
@@ -230,6 +236,7 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) {
}
$language_updates_results = array();
+ $successful_update_ids = array();
foreach ( $language_updates as $language_update ) {
@@ -266,6 +273,10 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) {
break;
}
+ if ( is_array( $result ) ) {
+ $successful_update_ids[ wp_get_translation_update_id( $language_update ) ] = true;
+ }
+
$language_updates_results[] = array(
'language' => $language_update->language,
'type' => $language_update->type,
@@ -274,6 +285,15 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) {
);
}
+ if ( $successful_update_ids ) {
+ $deferred_updates = wp_get_deferred_translation_updates();
+ $remaining = array_diff_key( $deferred_updates, $successful_update_ids );
+
+ if ( $remaining !== $deferred_updates ) {
+ wp_set_deferred_translation_updates( $remaining );
+ }
+ }
+
// Remove upgrade hooks which are not required for translation updates.
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
remove_action( 'upgrader_process_complete', 'wp_version_check' );
diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php
index 0bb8937d0fce4..d60507cd3cfbf 100644
--- a/src/wp-admin/includes/class-wp-automatic-updater.php
+++ b/src/wp-admin/includes/class-wp-automatic-updater.php
@@ -192,6 +192,7 @@ public function is_allowed_dir( $dir ) {
* how things get updated.
*
* @since 3.7.0
+ * @since 7.2.0 Detects a `.git` file, as used by Git worktrees and submodules.
*
* @param string $context The filesystem path to check, in addition to ABSPATH.
* @return bool True if a VCS checkout was discovered at `$context` or ABSPATH,
@@ -230,7 +231,8 @@ public function is_vcs_checkout( $context ) {
continue;
}
- $checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
+ // In a Git worktree or submodule, `.git` is a file rather than a directory.
+ $checkout = file_exists( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
if ( $checkout ) {
break 2;
}
@@ -312,6 +314,10 @@ public function should_update( $type, $item, $context ) {
}
} else {
$update = ! empty( $item->autoupdate );
+
+ if ( $update && wp_is_translation_update_deferred( $item ) ) {
+ $update = false;
+ }
}
// If the `disable_autoupdate` flag is set, override any user-choice, but allow filters.
diff --git a/src/wp-admin/includes/class-wp-internal-pointers.php b/src/wp-admin/includes/class-wp-internal-pointers.php
index 22233884b4beb..0e11d759a9b0e 100644
--- a/src/wp-admin/includes/class-wp-internal-pointers.php
+++ b/src/wp-admin/includes/class-wp-internal-pointers.php
@@ -35,7 +35,7 @@ final class WP_Internal_Pointers {
* @param string $hook_suffix The current admin page.
*/
public static function enqueue_scripts( $hook_suffix ) {
- /*
+ /**
* Register feature pointers
*
* Format:
@@ -47,6 +47,8 @@ public static function enqueue_scripts( $hook_suffix ) {
* array(
* 'themes.php' => 'wp390_widgets'
* )
+ *
+ * @var array
%1$s
%2$s
%1$s
%2$s' . __( 'Registration is open to anyone, and the default role is set to a privileged role.' ) . '
'; $result['status'] = 'critical'; $result['actions'] = sprintf( '', diff --git a/src/wp-admin/includes/comment.php b/src/wp-admin/includes/comment.php index 1cfc93144e978..5f46be6a5cdfa 100644 --- a/src/wp-admin/includes/comment.php +++ b/src/wp-admin/includes/comment.php @@ -47,6 +47,8 @@ function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) { * @since 2.0.0 * @since 5.5.0 A return value was added. * @since 7.1.0 The comment parent can be updated via `$_POST['comment_parent']`. + * @since 7.1.5 Moving a comment to another post is checked against the user's capabilities, + * and the comment type can no longer be changed. * * @return int|WP_Error The value 1 if the comment was updated, 0 if not updated. * A WP_Error object on failure. @@ -75,14 +77,50 @@ function edit_comment() { $_POST['comment_ID'] = (int) $_POST['comment_ID']; } + $comment_id = (int) $_POST['comment_ID']; + $comment = get_comment( $comment_id ); + + /* + * The comment type is not editable from the Edit Comment screen. Changing it + * would turn a private note into a public comment or vice versa, and would + * break the rule that replies share their parent's type. + */ + if ( $comment && isset( $_POST['comment_type'] ) && $_POST['comment_type'] !== $comment->comment_type ) { + return new WP_Error( 'comment_type_invalid', __( 'The comment type cannot be changed.' ) ); + } + + /* + * The capability check above only establishes that the comment may be edited + * where it currently sits, because 'edit_comment' maps to 'edit_post' on the + * comment's current post. Moving the comment to another post has to be + * authorized separately, otherwise a user who can edit a comment on their own + * post could attach it to any post, including posts they can neither read nor + * edit. + */ + + $comment_post_id = $comment ? (int) $comment->comment_post_ID : 0; + + if ( $comment && isset( $_POST['comment_post_ID'] ) ) { + $target_post_id = (int) $_POST['comment_post_ID']; + + $_POST['comment_post_ID'] = $target_post_id; + + if ( $target_post_id !== $comment_post_id ) { + $target_post_check = _wp_check_comment_target_post( $comment, $target_post_id ); + + if ( is_wp_error( $target_post_check ) ) { + return $target_post_check; + } + + $comment_post_id = $target_post_id; + } + } + if ( isset( $_POST['comment_parent'] ) ) { - $comment_id = (int) $_POST['comment_ID']; $comment_parent = (int) $_POST['comment_parent']; $_POST['comment_parent'] = $comment_parent; - $comment = get_comment( $comment_id ); - if ( $comment && $comment_parent && $comment_parent !== (int) $comment->comment_parent ) { if ( ! get_option( 'thread_comments' ) ) { return new WP_Error( 'comment_parent_invalid', __( 'The comment parent cannot be changed because threaded comments are disabled.' ) ); @@ -100,7 +138,7 @@ function edit_comment() { // The parent must be a comment of the same type, on the same post, and publicly visible if the comment is approved. if ( ! $parent - || (int) $parent->comment_post_ID !== (int) $comment->comment_post_ID + || (int) $parent->comment_post_ID !== $comment_post_id || $parent->comment_type !== $comment->comment_type || in_array( $parent_status, array( 'spam', 'trash' ), true ) || ( $comment_is_approved && 'approved' !== $parent_status ) @@ -183,6 +221,71 @@ function edit_comment() { return wp_update_comment( $_POST, true ); } +/** + * Checks that the current user may move a comment to another post. + * + * Mirrors the checks applied by the REST API comments controller when the + * parent post of a comment or note is changed. + * + * @since 7.1.5 + * @access private + * + * @param WP_Comment $comment The comment being moved. + * @param int $post_id ID of the post the comment is being moved to. + * @return true|WP_Error True if the comment may be moved to the post, WP_Error otherwise. + */ +function _wp_check_comment_target_post( WP_Comment $comment, int $post_id ) { + $post = $post_id ? get_post( $post_id ) : null; + + if ( ! $post ) { + return new WP_Error( 'comment_post_invalid', __( 'Invalid post ID.' ) ); + } + + /* + * Notes are editorial content, so they may only be attached to a post the + * user can edit. Any other comment needs either comment moderation rights + * or edit access to the post, matching what 'edit_comment' requires on the + * post the comment is moving away from. + */ + $is_note = 'note' === strtolower( $comment->comment_type ); + + if ( $is_note ) { + $can_target_post = current_user_can( 'edit_post', $post->ID ); + } else { + $can_target_post = current_user_can( 'moderate_comments' ) || current_user_can( 'edit_post', $post->ID ); + } + + if ( ! $can_target_post ) { + return new WP_Error( 'comment_post_invalid', __( 'Sorry, you are not allowed to move this comment to that post.' ) ); + } + + if ( ! $is_note ) { + return true; + } + + $supports_notes = false; + $supports = get_all_post_type_supports( $post->post_type ); + + if ( isset( $supports['editor'] ) && is_array( $supports['editor'] ) ) { + $supports_notes = array_any( + $supports['editor'], + static function ( $item ) { + return is_array( $item ) && ! empty( $item['notes'] ); + } + ); + } + + if ( ! $supports_notes ) { + return new WP_Error( 'comment_post_invalid', __( 'Sorry, this post type does not support notes.' ) ); + } + + if ( 'trash' === $post->post_status || ! current_user_can( 'read_post', $post->ID ) ) { + return new WP_Error( 'comment_post_invalid', __( 'Sorry, you are not allowed to move this comment to that post.' ) ); + } + + return true; +} + /** * Returns a WP_Comment object based on comment ID. * diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 3e0d28d7f85f1..9ba75b74bc4c2 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1417,13 +1417,6 @@ function wp_dashboard_rss_output( $widget_id ) { function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) { $doing_ajax = wp_doing_ajax(); $loading = ''; - $loading .= wp_get_admin_notice( - __( 'This widget requires JavaScript.' ), - array( - 'type' => 'error', - 'additional_classes' => array( 'inline', 'hide-if-js' ), - ) - ); if ( empty( $check_urls ) ) { $widgets = get_option( 'dashboard_widget_options' ); @@ -1509,9 +1502,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options = array(); } - if ( ! isset( $widget_options[ $widget_id ] ) ) { - $widget_options[ $widget_id ] = array(); - } + $widget_options[ $widget_id ] ??= array(); $number = 1; // Hack to use wp_widget_rss_form(). diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 2f6bc25740e2d..90ccab282283a 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -565,6 +565,7 @@ function _rotate_image_resource( $img, $angle ) { * Flips an image resource. Internal use only. * * @since 2.9.0 + * @since 7.2.0 Switched to using imageflip() instead of imagecopyresampled() with negative dimensions. * @deprecated 3.5.0 Use WP_Image_Editor::flip() * @see WP_Image_Editor::flip() * @@ -577,25 +578,43 @@ function _rotate_image_resource( $img, $angle ) { function _flip_image_resource( $img, $horz, $vert ) { _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' ); - $w = imagesx( $img ); - $h = imagesy( $img ); - $dst = wp_imagecreatetruecolor( $w, $h ); + if ( ! is_gd_image( $img ) ) { + return $img; + } - if ( is_gd_image( $dst ) ) { - $sx = $vert ? ( $w - 1 ) : 0; - $sy = $horz ? ( $h - 1 ) : 0; - $sw = $vert ? -$w : $w; - $sh = $horz ? -$h : $h; + // Keep returning a truecolor image, like the previous implementation did. imagewebp() rejects palette images. + if ( ! imageistruecolor( $img ) && ! imagepalettetotruecolor( $img ) ) { + return $img; + } - if ( imagecopyresampled( $dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) { - if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0. - imagedestroy( $img ); - } + // Match the alpha settings of the previous implementation's copy, including when no axis is flipped. + imagealphablending( $img, false ); + imagesavealpha( $img, true ); - $img = $dst; - } + /* + * imageflip() changes the image in place, so the image keeps its current resolution and interlace setting. + * _rotate_image_resource() and _crop_image_resource() copy into a new image, which resets them to GD's defaults: + * 96 DPI and no interlacing. Reset them here too, so a flip gives the same result as the other edits. + * + * @link https://core.trac.wordpress.org/ticket/66113 + */ + imageresolution( $img, 96, 96 ); + imageinterlace( $img, 0 ); + + if ( ! $horz && ! $vert ) { + return $img; } + if ( $horz && $vert ) { + $mode = IMG_FLIP_BOTH; + } elseif ( $horz ) { + $mode = IMG_FLIP_VERTICAL; + } else { + $mode = IMG_FLIP_HORIZONTAL; + } + + imageflip( $img, $mode ); + return $img; } diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index a05531c6d9557..d4b40afc7bb6b 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -964,6 +964,14 @@ function wp_read_image_metadata( $file ) { if ( ! empty( $exif['COMPUTED']['UserComment'] ) ) { $exif_usercomment = trim( $exif['COMPUTED']['UserComment'] ); + + /* + * PHP returns a UserComment shorter than its 8-byte character code + * as the bare code, such as "ASCII". It holds no comment. + */ + if ( in_array( $exif_usercomment, array( 'ASCII', 'UNICODE', 'JIS' ), true ) ) { + $exif_usercomment = ''; + } } if ( $exif_description ) { diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index ee4c2add91e65..9f5b87ce85f93 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -3750,12 +3750,9 @@ function wp_read_video_metadata( $file ) { $metadata['audio'] = $data['audio']; } - if ( empty( $metadata['created_timestamp'] ) ) { - $created_timestamp = wp_get_media_creation_timestamp( $data ); - - if ( false !== $created_timestamp ) { - $metadata['created_timestamp'] = $created_timestamp; - } + $created_timestamp = wp_get_media_creation_timestamp( $data ); + if ( false !== $created_timestamp ) { + $metadata['created_timestamp'] = $created_timestamp; } wp_add_id3_tag_data( $metadata, $data ); diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 9149f50daadd8..54367825514f6 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -96,7 +96,6 @@ function post_submit_meta_box( $post, $args = array() ) { */ do_action( 'post_submitbox_minor_actions', $post ); ?> - -elements. - * @return array - * - * @phpstan-return array{test: string, label: string, status: 'good'|'recommended'|'critical', badge: array{label: string, color: string}, description: string} - * @phpstan-param 'good'|'recommended'|'critical' $status - */ -function wp_secrets_site_health_result( string $test, string $label, string $status, string $description ): array { - $colors = array( - 'good' => 'green', - 'recommended' => 'orange', - 'critical' => 'red', - ); - - return array( - 'test' => $test, - 'label' => $label, - 'status' => $status, - 'badge' => array( - 'label' => __( 'Security' ), - 'color' => $colors[ $status ] ?? 'blue', - ), - 'description' => $description, - ); -} - -/** - * Site Health test: is the site key a dedicated constant, or a weaker fallback? - * - * @since 7.2.0 - * - * @return array - * - * @phpstan-return array{test: string, label: string, status: 'good'|'recommended'|'critical', badge: array{label: string, color: string}, description: string} - */ -function wp_secrets_site_health_test_key_source(): array { - $key_source = _wp_secrets_get_key_manager()->get_keyring()->get_key_source(); - - if ( str_contains( $key_source, 'broken' ) ) { - return wp_secrets_site_health_result( - 'secrets_api_key_source', - __( 'Secrets API key source is broken' ), - 'critical', - sprintf( - '
%s
', - esc_html__( 'The active keyring did not load correctly. No secret can be encrypted or decrypted until this is fixed.' ) - ) - ); - } - - if ( str_contains( $key_source, 'legacy interpretation' ) ) { - return wp_secrets_site_health_result( - 'secrets_api_key_source', - __( 'Secrets API key should be regenerated' ), - 'recommended', - sprintf( - '%s
', - esc_html__( 'WP_SECRETS_KEY is defined, but not in the recommended base64-encoded 32-byte form. Regenerate it with `wp secret generate-key`.' ) - ) - ); - } - - if ( str_contains( $key_source, 'LOGGED_IN_KEY' ) ) { - return wp_secrets_site_health_result( - 'secrets_api_key_source', - __( 'Secrets API is using a fallback key' ), - 'recommended', - sprintf( - '%s
', - esc_html__( 'No dedicated WP_SECRETS_KEY constant is defined. Secrets are encrypted using a key derived from existing salts, which works but is not the recommended configuration. Define WP_SECRETS_KEY with a value from `wp secret generate-key`.' ) - ) - ); - } - - return wp_secrets_site_health_result( - 'secrets_api_key_source', - __( 'Secrets API is using a dedicated key' ), - 'good', - sprintf( '%s
', esc_html( $key_source ) ) - ); -} - -/** - * Site Health test: does every stored secret still decrypt? - * - * Network secrets are included only for a super admin on a multisite install – - * never shown to a site administrator who is not one. - * - * @since 7.2.0 - * - * @return array - * - * @phpstan-return array{test: string, label: string, status: 'good'|'recommended'|'critical', badge: array{label: string, color: string}, description: string} - */ -function wp_secrets_site_health_test_undecryptable(): array { - $broken = wp_secrets_site_health_find_undecryptable( false ); - - if ( is_multisite() && is_super_admin() ) { - $broken = array_merge( $broken, wp_secrets_site_health_find_undecryptable( true ) ); - } - - if ( empty( $broken ) ) { - return wp_secrets_site_health_result( - 'secrets_api_undecryptable', - __( 'All secrets can be decrypted' ), - 'good', - sprintf( '%s
', esc_html__( 'Every stored secret decrypted successfully.' ) ) - ); - } - - $items = ''; - - foreach ( $broken as $entry ) { - $items .= sprintf( - '%s
%s
', - esc_html__( 'The following secrets exist but could not be decrypted with the current key. There is no way to recover the original value. The credential must be re-entered.' ), - $items, - esc_html__( 'This can happen after losing WP_SECRETS_KEY, restoring a database backup without its matching key, or a failed key rotation.' ) - ) - ); -} - -/** - * Finds secrets that fail to decrypt, for one scope. - * - * @since 7.2.0 - * - * @param bool $network Whether to check network-scope secrets. - * @return array List of array( 'name' => ..., 'fingerprint' => ... ). - * - * @phpstan-return list%s
', esc_html__( 'No secret is flagged as needing rotation.' ) ) - ); - } - - return wp_secrets_site_health_result( - 'secrets_api_needs_rotation', - __( 'Some secrets are pending rotation' ), - 'recommended', - sprintf( - '%s
', - esc_html( - sprintf( - /* translators: %d: Number of secrets flagged for rotation. */ - _n( - '%d secret was imported from an existing option and is flagged for rotation. A credential that sat in a plain option has already been through whatever backups and replication paths that option went through; re-entering it with a new value is recommended.', - '%d secrets were imported from existing options and are flagged for rotation. A credential that sat in a plain option has already been through whatever backups and replication paths that option went through; re-entering each with a new value is recommended.', - $count - ), - $count - ) - ) - ) - ); -} - -/** - * Counts secrets flagged needs_rotation, for one scope. - * - * @since 7.2.0 - * - * @param bool $network Whether to check network-scope secrets. - * @return int - * - * @phpstan-return int<0, max> - */ -function wp_secrets_site_health_count_needing_rotation( bool $network ): int { - $entries = $network ? wp_list_network_secrets() : wp_list_secrets(); - - if ( is_wp_error( $entries ) ) { - return 0; - } - - $count = 0; - - foreach ( $entries as $entry ) { - if ( ! empty( $entry['needs_rotation'] ) ) { - ++$count; - } - } - - return $count; -} - -/** - * Adds a Secrets API section to Site Health's debug information. - * - * Counts and class names only – no secret values, and no fingerprints. Network - * scope figures are included only for a super admin on a multisite install. - * - * @since 7.2.0 - * - * @param array` tags). - * @type string $type Optional. Message type, controls HTML class. Possible values include 'error', + * @type string $type Message type, controls HTML class. Possible values include 'error', * 'success', 'warning', 'info'. Default 'error'. * } * } diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php index 7f92fed1b2625..44e6651f09985 100644 --- a/src/wp-admin/includes/theme.php +++ b/src/wp-admin/includes/theme.php @@ -494,18 +494,11 @@ function themes_api( $action, $args = array() ) { } if ( 'query_themes' === $action ) { - if ( ! isset( $args->per_page ) ) { - $args->per_page = 24; - } - } - - if ( ! isset( $args->locale ) ) { - $args->locale = get_user_locale(); + $args->per_page ??= 24; } - if ( ! isset( $args->wp_version ) ) { - $args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y - } + $args->locale ??= get_user_locale(); + $args->wp_version ??= substr( wp_get_wp_version(), 0, 3 ); // x.y /** * Filters arguments used to query for installer pages from the WordPress.org Themes API. diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 5999b53344d95..22d9c3e2f463d 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -926,28 +926,20 @@ 'wp-includes/images/icon-library/archive.svg', 'wp-includes/images/icon-library/aspect-ratio.svg', 'wp-includes/images/icon-library/background.svg', - 'wp-includes/images/icon-library/backup.svg', 'wp-includes/images/icon-library/bell-unread.svg', 'wp-includes/images/icon-library/border.svg', 'wp-includes/images/icon-library/box.svg', 'wp-includes/images/icon-library/breadcrumbs.svg', 'wp-includes/images/icon-library/bug.svg', - 'wp-includes/images/icon-library/button.svg', 'wp-includes/images/icon-library/buttons.svg', 'wp-includes/images/icon-library/cancel-circle-filled.svg', 'wp-includes/images/icon-library/caption.svg', 'wp-includes/images/icon-library/caution-filled.svg', 'wp-includes/images/icon-library/classic.svg', 'wp-includes/images/icon-library/close-small.svg', - 'wp-includes/images/icon-library/close.svg', 'wp-includes/images/icon-library/cloud-download.svg', - 'wp-includes/images/icon-library/cloud-upload.svg', - 'wp-includes/images/icon-library/cloud.svg', - 'wp-includes/images/icon-library/code.svg', - 'wp-includes/images/icon-library/cog.svg', 'wp-includes/images/icon-library/color.svg', 'wp-includes/images/icon-library/column.svg', - 'wp-includes/images/icon-library/columns.svg', 'wp-includes/images/icon-library/comment-author-avatar.svg', 'wp-includes/images/icon-library/comment-author-name.svg', 'wp-includes/images/icon-library/comment-content.svg', @@ -962,8 +954,6 @@ 'wp-includes/images/icon-library/corner-bottom-right.svg', 'wp-includes/images/icon-library/corner-top-left.svg', 'wp-includes/images/icon-library/corner-top-right.svg', - 'wp-includes/images/icon-library/crop.svg', - 'wp-includes/images/icon-library/currency-dollar.svg', 'wp-includes/images/icon-library/currency-euro.svg', 'wp-includes/images/icon-library/currency-pound.svg', 'wp-includes/images/icon-library/custom-link.svg', @@ -972,8 +962,6 @@ 'wp-includes/images/icon-library/drafts.svg', 'wp-includes/images/icon-library/drag-handle.svg', 'wp-includes/images/icon-library/filter.svg', - 'wp-includes/images/icon-library/flip-horizontal.svg', - 'wp-includes/images/icon-library/flip-vertical.svg', 'wp-includes/images/icon-library/footer.svg', 'wp-includes/images/icon-library/format-bold.svg', 'wp-includes/images/icon-library/format-capitalize.svg', @@ -994,10 +982,7 @@ 'wp-includes/images/icon-library/format-uppercase.svg', 'wp-includes/images/icon-library/full-height.svg', 'wp-includes/images/icon-library/fullscreen.svg', - 'wp-includes/images/icon-library/funnel.svg', 'wp-includes/images/icon-library/gift.svg', - 'wp-includes/images/icon-library/globe.svg', - 'wp-includes/images/icon-library/grid.svg', 'wp-includes/images/icon-library/handle.svg', 'wp-includes/images/icon-library/header.svg', 'wp-includes/images/icon-library/heading-level-1.svg', @@ -1012,7 +997,6 @@ 'wp-includes/images/icon-library/inbox.svg', 'wp-includes/images/icon-library/insert-after.svg', 'wp-includes/images/icon-library/insert-before.svg', - 'wp-includes/images/icon-library/institution.svg', 'wp-includes/images/icon-library/justify-bottom.svg', 'wp-includes/images/icon-library/justify-center-vertical.svg', 'wp-includes/images/icon-library/justify-center.svg', @@ -1026,7 +1010,6 @@ 'wp-includes/images/icon-library/keyboard-close.svg', 'wp-includes/images/icon-library/keyboard-return.svg', 'wp-includes/images/icon-library/keyboard.svg', - 'wp-includes/images/icon-library/layout.svg', 'wp-includes/images/icon-library/level-up.svg', 'wp-includes/images/icon-library/lifesaver.svg', 'wp-includes/images/icon-library/line-dashed.svg', @@ -1038,12 +1021,10 @@ 'wp-includes/images/icon-library/list.svg', 'wp-includes/images/icon-library/lock-outline.svg', 'wp-includes/images/icon-library/lock-small.svg', - 'wp-includes/images/icon-library/lock.svg', 'wp-includes/images/icon-library/login.svg', 'wp-includes/images/icon-library/loop.svg', 'wp-includes/images/icon-library/math.svg', 'wp-includes/images/icon-library/media-and-text.svg', - 'wp-includes/images/icon-library/megaphone.svg', 'wp-includes/images/icon-library/more.svg', 'wp-includes/images/icon-library/move-to.svg', 'wp-includes/images/icon-library/navigation-overlay.svg', @@ -1087,8 +1068,6 @@ 'wp-includes/images/icon-library/reset.svg', 'wp-includes/images/icon-library/resize-corner-ne.svg', 'wp-includes/images/icon-library/reusable-block.svg', - 'wp-includes/images/icon-library/rotate-left.svg', - 'wp-includes/images/icon-library/rotate-right.svg', 'wp-includes/images/icon-library/row.svg', 'wp-includes/images/icon-library/seen.svg', 'wp-includes/images/icon-library/send.svg', @@ -1129,17 +1108,12 @@ 'wp-includes/images/icon-library/text-color.svg', 'wp-includes/images/icon-library/text-horizontal.svg', 'wp-includes/images/icon-library/text-vertical.svg', - 'wp-includes/images/icon-library/thumbs-down.svg', - 'wp-includes/images/icon-library/thumbs-up.svg', 'wp-includes/images/icon-library/time-to-read.svg', 'wp-includes/images/icon-library/title.svg', - 'wp-includes/images/icon-library/trash.svg', 'wp-includes/images/icon-library/trending-down.svg', - 'wp-includes/images/icon-library/trending-up.svg', 'wp-includes/images/icon-library/typography.svg', 'wp-includes/images/icon-library/undo.svg', 'wp-includes/images/icon-library/ungroup.svg', - 'wp-includes/images/icon-library/unlock.svg', 'wp-includes/images/icon-library/unseen.svg', 'wp-includes/images/icon-library/video.svg', 'wp-includes/images/icon-library/widget.svg', @@ -1158,15 +1132,41 @@ /* * Restored in WordPress 7.2. * + * 'wp-includes/images/icon-library/backup.svg', * 'wp-includes/images/icon-library/brush.svg', + * 'wp-includes/images/icon-library/button.svg', + * 'wp-includes/images/icon-library/close.svg', + * 'wp-includes/images/icon-library/cloud-upload.svg', + * 'wp-includes/images/icon-library/cloud.svg', + * 'wp-includes/images/icon-library/code.svg', + * 'wp-includes/images/icon-library/cog.svg', + * 'wp-includes/images/icon-library/columns.svg', + * 'wp-includes/images/icon-library/crop.svg', + * 'wp-includes/images/icon-library/currency-dollar.svg', * 'wp-includes/images/icon-library/dashboard.svg', + * 'wp-includes/images/icon-library/flip-horizontal.svg', + * 'wp-includes/images/icon-library/flip-vertical.svg', + * 'wp-includes/images/icon-library/funnel.svg', + * 'wp-includes/images/icon-library/globe.svg', + * 'wp-includes/images/icon-library/grid.svg', + * 'wp-includes/images/icon-library/institution.svg', + * 'wp-includes/images/icon-library/layout.svg', * 'wp-includes/images/icon-library/link.svg', + * 'wp-includes/images/icon-library/lock.svg', * 'wp-includes/images/icon-library/media.svg', + * 'wp-includes/images/icon-library/megaphone.svg', * 'wp-includes/images/icon-library/page.svg', * 'wp-includes/images/icon-library/pin.svg', * 'wp-includes/images/icon-library/plugins.svg', * 'wp-includes/images/icon-library/post-comments.svg', + * 'wp-includes/images/icon-library/rotate-left.svg', + * 'wp-includes/images/icon-library/rotate-right.svg', + * 'wp-includes/images/icon-library/thumbs-down.svg', + * 'wp-includes/images/icon-library/thumbs-up.svg', * 'wp-includes/images/icon-library/tool.svg', + * 'wp-includes/images/icon-library/trash.svg', + * 'wp-includes/images/icon-library/trending-up.svg', + * 'wp-includes/images/icon-library/unlock.svg', * 'wp-includes/images/icon-library/update.svg', * 'wp-includes/images/icon-library/wordpress.svg', */ diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index c3c15c8fe3f2c..e7b02a2a62c8a 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -11,7 +11,7 @@ * * @since 2.7.0 * - * @return object|array|false The response from the API on success, false on failure. + * @return object|false The response from the API on success, false on failure. */ function get_preferred_from_update_core() { $updates = get_core_updates(); @@ -641,6 +641,211 @@ function get_theme_updates() { return $update_themes; } +/** + * Gets plugin names for translation updates. + * + * @since 7.2.0 + * + * @return string[] Plugin names keyed by plugin file, directory, basename, and slug. + */ +function wp_get_translation_update_plugin_names() { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + + $plugin_names = array(); + $all_plugins = get_plugins(); + $plugin_update = get_site_transient( 'update_plugins' ); + + if ( is_object( $plugin_update ) ) { + $plugin_updates = array(); + + if ( ! empty( $plugin_update->response ) && is_array( $plugin_update->response ) ) { + $plugin_updates = array_merge( $plugin_updates, $plugin_update->response ); + } + + if ( ! empty( $plugin_update->no_update ) && is_array( $plugin_update->no_update ) ) { + $plugin_updates = array_merge( $plugin_updates, $plugin_update->no_update ); + } + + foreach ( $plugin_updates as $plugin_file => $plugin_data ) { + $plugin_data = (object) $plugin_data; + + if ( ! empty( $plugin_data->slug ) && ! empty( $all_plugins[ $plugin_file ]['Name'] ) ) { + $plugin_names[ $plugin_data->slug ] = $all_plugins[ $plugin_file ]['Name']; + } + } + } + + foreach ( $all_plugins as $plugin_file => $plugin_data ) { + $plugin_basename = dirname( $plugin_file ); + + if ( isset( $plugin_data['Name'] ) ) { + $plugin_names[ $plugin_file ] = $plugin_data['Name']; + $plugin_names[ basename( $plugin_file, '.php' ) ] = $plugin_data['Name']; + + if ( '.' !== $plugin_basename ) { + $plugin_names[ $plugin_basename ] = $plugin_data['Name']; + } + } + } + + return $plugin_names; +} + +/** + * Gets the display name for a translation update. + * + * @since 7.2.0 + * + * @param object $update Translation update object. + * @param string[]|null $plugin_names Optional. Plugin names keyed by plugin file, directory, + * basename, and slug. Default null. + * @return string The translation update name. + */ +function wp_get_translation_update_name( $update, $plugin_names = null ) { + $type = isset( $update->type ) ? $update->type : ''; + $slug = isset( $update->slug ) ? $update->slug : ''; + + switch ( $type ) { + case 'core': + return 'WordPress'; // Not translated. + + case 'theme': + $theme = wp_get_theme( $slug ); + if ( $theme->exists() ) { + return $theme->get( 'Name' ); + } + break; + + case 'plugin': + if ( null === $plugin_names ) { + $plugin_names = wp_get_translation_update_plugin_names(); + } + + if ( ! empty( $plugin_names[ $slug ] ) ) { + return $plugin_names[ $slug ]; + } + break; + } + + return $slug; +} + +/** + * Gets the display language for a translation update. + * + * @since 7.2.0 + * + * @param string $locale Translation update locale. + * @return string The translation update language. + */ +function wp_get_translation_update_language( $locale ) { + $translations = get_site_transient( 'available_translations' ); + + if ( is_array( $translations ) && ! empty( $translations[ $locale ]['native_name'] ) ) { + return sprintf( + /* translators: 1: Native language name, 2: Locale. */ + __( '%1$s (%2$s)' ), + $translations[ $locale ]['native_name'], + $locale + ); + } + + return $locale; +} + +/** + * Gets display data for available translation updates. + * + * @since 7.2.0 + * + * @return array[] { + * An array of translation update display data. + * + * @type bool $checked Whether the translation update is selected for installation. + * @type bool $deferred Whether the translation update has been deferred. + * @type string $id Translation update identifier. + * @type string $language Translation update language. + * @type string $language_code Translation update locale. + * @type string $name Translation update name. + * @type string $slug Translation update slug. + * @type string $type Translation update type. + * @type string $version Translation update version. + * } + */ +function wp_get_translation_update_data() { + $available_updates = wp_get_translation_updates(); + $deferred_translation_updates = wp_get_deferred_translation_updates( $available_updates ); + $plugin_names = null; + $translation_updates = array(); + + foreach ( $available_updates as $update ) { + $translation_update_id = wp_get_translation_update_id( $update ); + $language = isset( $update->language ) ? $update->language : ''; + $type = isset( $update->type ) ? $update->type : ''; + $deferred = isset( $deferred_translation_updates[ $translation_update_id ] ); + + if ( 'plugin' === $type && null === $plugin_names ) { + $plugin_names = wp_get_translation_update_plugin_names(); + } + + $translation_updates[] = array( + 'checked' => ! $deferred, + 'deferred' => $deferred, + 'id' => $translation_update_id, + 'language' => wp_get_translation_update_language( $language ), + 'language_code' => $language, + 'name' => wp_get_translation_update_name( $update, $plugin_names ), + 'slug' => isset( $update->slug ) ? $update->slug : '', + 'type' => $type, + 'version' => isset( $update->version ) ? $update->version : '', + ); + } + + return $translation_updates; +} + +/** + * Processes a translation update selection and stores the deferred updates. + * + * Only currently available updates included in the submitted form can be selected + * or deferred. Previously deferred updates outside the form remain deferred, while + * newly available updates outside the form are left unchanged. + * + * The caller must check capabilities and the nonce before calling this function. + * + * @since 7.2.0 + * + * @param string[] $translation_update_ids Sanitized identifiers of updates included in the form. + * @param string[] $selected_translation_update_ids Sanitized identifiers of selected updates. + * @return object[]|false Selected current translation updates keyed by identifier, an empty array + * if all updates in the form were deferred, or false if the form contains + * no currently available updates. On false, stored deferrals are unchanged. + */ +function wp_process_translation_update_selection( $translation_update_ids, $selected_translation_update_ids ) { + if ( empty( $translation_update_ids ) ) { + return false; + } + + $current_translation_updates = wp_get_translation_updates_by_id(); + $translation_updates = array_intersect_key( $current_translation_updates, array_flip( $translation_update_ids ) ); + + if ( empty( $translation_updates ) ) { + return false; + } + + $selected_translation_updates = array_intersect_key( $translation_updates, array_flip( $selected_translation_update_ids ) ); + $deferred_translation_updates = array_intersect_key( + $current_translation_updates, + wp_get_deferred_translation_updates() + ); + $deferred_translation_updates = array_diff_key( $deferred_translation_updates, $translation_updates ); + $deferred_translation_updates += array_diff_key( $translation_updates, $selected_translation_updates ); + + wp_set_deferred_translation_updates( $deferred_translation_updates ); + + return $selected_translation_updates; +} + /** * Adds a callback to display update information for themes with updates available. * diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 5c5ebcd312223..5aadc22a2428d 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -892,10 +892,6 @@ function upgrade_all() { upgrade_700(); } - if ( $wp_current_db_version < 64337 ) { - upgrade_720(); - } - maybe_disable_link_manager(); maybe_disable_automattic_widgets(); @@ -2506,23 +2502,6 @@ function upgrade_700() { } } -/** - * Executes changes made in WordPress 7.2. - * - * @ignore - * @since 7.2.0 - * - * @global int $wp_current_db_version The old (current) database version. - */ -function upgrade_720(): void { - global $wp_current_db_version; - - // Grant the Secrets API's site-level capability to administrators. - if ( $wp_current_db_version < 64337 ) { - populate_roles_720(); - } -} - /** * Executes network-level upgrade routines. * diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index 5697a6e9ff0dd..360b51798d32c 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -29,9 +29,7 @@ function wp_list_widgets() { $sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false ); $done[] = $widget['callback']; - if ( ! isset( $widget['params'][0] ) ) { - $widget['params'][0] = array(); - } + $widget['params'][0] ??= array(); $args = array( 'widget_id' => $widget['id'], diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 6a9925b0d4708..6f3b683817447 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -197,7 +197,6 @@ // If this menu item is a child of the previous. if ( ! empty( $menu_item_data['menu_item_parent'] ) && isset( $dbids_to_orders[ (int) $menu_item_data['menu_item_parent'] ] ) - && isset( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) && ( (int) $menu_item_data['menu_item_parent'] === $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) ) { if ( in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) ) { diff --git a/src/wp-admin/network/settings.php b/src/wp-admin/network/settings.php index 1e13084a858c1..e8ec03944cf5f 100644 --- a/src/wp-admin/network/settings.php +++ b/src/wp-admin/network/settings.php @@ -24,12 +24,18 @@ // Handle network admin email change requests. if ( ! empty( $_GET['network_admin_hash'] ) ) { $new_admin_details = get_site_option( 'network_admin_hash' ); - $redirect = 'settings.php?updated=false'; + $redirect = add_query_arg( array( 'updated' => 'false' ), 'settings.php' ); if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['network_admin_hash'] ) && ! empty( $new_admin_details['newemail'] ) ) { update_site_option( 'admin_email', $new_admin_details['newemail'] ); delete_site_option( 'network_admin_hash' ); delete_site_option( 'new_admin_email' ); - $redirect = 'settings.php?updated=true'; + $redirect = add_query_arg( + array( + 'updated' => 'true', + 'network_admin_email_updated' => 'true', + ), + 'settings.php' + ); } wp_redirect( network_admin_url( $redirect ) ); exit; @@ -37,7 +43,7 @@ check_admin_referer( 'dismiss_new_network_admin_email' ); delete_site_option( 'network_admin_hash' ); delete_site_option( 'new_admin_email' ); - wp_redirect( network_admin_url( 'settings.php?updated=true' ) ); + wp_redirect( network_admin_url( 'settings.php' ) ); exit; } @@ -137,9 +143,9 @@ require_once ABSPATH . 'wp-admin/admin-header.php'; -if ( isset( $_GET['updated'] ) ) { +if ( isset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! isset( $_GET['network_admin_email_updated'] ) ) { wp_admin_notice( - __( 'Settings saved.' ), + '' . __( 'Settings saved.' ) . '', array( 'type' => 'success', 'dismissible' => true, @@ -147,10 +153,41 @@ ) ); } + +$new_network_admin_email = get_site_option( 'new_admin_email' ); +$pending_new_network_admin_email = $new_network_admin_email && get_site_option( 'admin_email' ) !== $new_network_admin_email; ?>
' . esc_html( $new_network_admin_email ) . ''
+ );
+ $message .= $pending_network_admin_email_cancel_request_link;
+ wp_admin_notice( $message, array( 'type' => 'info' ) );
+ }
+ ?>