diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml deleted file mode 100644 index 2be14d9a2cd44..0000000000000 --- a/.github/workflows/end-to-end-tests.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: End-to-end Tests - -on: - # The end to end test suite was introduced in WordPress 5.3. - push: - branches: - - master - - trunk - - '5.[3-9]' - - '[6-9].[0-9]' - tags: - - '5.[3-9]*' - - '[6-9].[0-9]*' - pull_request: - branches: - - master - - trunk - - '5.[3-9]' - - '[6-9].[0-9]' - 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 - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -env: - LOCAL_DIR: build - -jobs: - # Runs the end-to-end test suite. - # - # Performs the following steps: - # - Set environment variables. - # - Checks out the repository. - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # - Sets up caching for NPM. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Builds WordPress to run from the `build` directory. - # - Starts the WordPress Docker container. - # - Logs general debug information. - # - Logs the running Docker containers. - # - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container). - # - Install WordPress within the Docker container. - # - Run the E2E tests. - # - todo: Configure Slack notifications for failing tests. - e2e-tests: - name: E2E Tests - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV - echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - php --version - php -i - locale -a - - - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install Dependencies - run: npm ci - - - name: Build WordPress - run: npm run build - - - name: Start Docker environment - run: | - npm run env:start - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - - name: Log running Docker containers - run: docker ps -a - - - name: Docker debug information - run: | - docker -v - docker-compose -v - docker-compose run --rm mysql mysql --version - docker-compose run --rm php php --version - docker-compose run --rm php php -m - docker-compose run --rm php php -i - docker-compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Run E2E tests - run: npm run test:e2e diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml deleted file mode 100644 index 335812b61fb71..0000000000000 --- a/.github/workflows/javascript-tests.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: JavaScript Tests - -on: - # JavaScript testing was introduced in WordPress 3.8. - push: - branches: - - master - - trunk - - '3.[89]' - - '[4-9].[0-9]' - tags: - - '3.[89]*' - - '[4-9].[0-9]*' - pull_request: - branches: - - master - - trunk - - '3.[89]' - - '[4-9].[0-9]' - paths: - # Any change to a JavaScript file should run tests. - - '**.js' - # These files configure NPM. Changes could affect the outcome. - - 'package*.json' - # This file configures ESLint. Changes could affect the outcome. - - '.eslintignore' - # This file configures JSHint. Changes could affect the outcome. - - '.jshintrc' - # Any change to the QUnit directory should run tests. - - 'tests/qunit/**' - # Changes to workflow files should always verify all workflows are successful. - - '.github/workflows/*.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 - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - # Runs the QUnit tests for WordPress. - # - # Performs the following steps: - # - Checks out the repository. - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # - Sets up caching for NPM. - # - Logs updated debug information. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Run the WordPress QUnit tests. - # - todo: Configure Slack notifications for failing tests. - test-js: - name: QUnit Tests - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Log debug information - run: | - npm --version - node --version - git --version - svn --version - - - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Log debug information - run: | - npm --version - node --version - - - name: Install Dependencies - run: npm ci - - - name: Run QUnit tests - run: npm run grunt qunit:compiled diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 1fd865823faa7..72bb8a695944c 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -71,34 +71,8 @@ jobs: os: [ ubuntu-latest ] memcached: [ false ] split_slow: [ false ] - multisite: [ false, true ] - include: - # Additional "slow" jobs for PHP 5.6. - - php: '5.6.20' - os: ubuntu-latest - memcached: false - multisite: false - split_slow: true - - php: '5.6.20' - os: ubuntu-latest - memcached: false - multisite: true - split_slow: true - # Include jobs for PHP 7.4 with memcached. - - php: '7.4' - os: ubuntu-latest - memcached: true - multisite: false - - php: '7.4' - os: ubuntu-latest - memcached: true - multisite: true - # Report the results of the PHP 7.4 without memcached job. - - php: '7.4' - os: ubuntu-latest - memcached: false - multisite: false - report: true + multisite: [ false ] + env: LOCAL_PHP: ${{ matrix.php }}-fpm LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }} @@ -197,48 +171,5 @@ jobs: - name: Install WordPress run: npm run env:install - - name: Run slow PHPUnit tests - if: ${{ matrix.split_slow }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }} - - - name: Run PHPUnit tests for single site excluding slow tests - if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required - - - name: Run PHPUnit tests for Multisite excluding slow tests - if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers - - - name: Run PHPUnit tests - if: ${{ matrix.php >= '7.0' }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} - - - name: Run AJAX tests - if: ${{ ! matrix.split_slow }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax - - - name: Run ms-files tests as a multisite install - if: ${{ matrix.multisite && ! matrix.split_slow }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files - - - name: Run external HTTP tests - if: ${{ ! matrix.multisite && ! matrix.split_slow }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http - - # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - - name: Run (xDebug) tests - if: ${{ ! matrix.split_slow }} - run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__ - - - name: Checkout the WordPress Test Reporter - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }} - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - repository: 'WordPress/phpunit-test-runner' - path: 'test-runner' - - - name: Submit test results to the WordPress.org host test results - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }} - env: - WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}" - run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php + - name: Run only OUR test + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --filter test_widget_display_callback_handles_arrayobject diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml deleted file mode 100644 index abdc989681606..0000000000000 --- a/.github/workflows/test-coverage.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: Code Coverage Report - -on: - # Verify - push: - branches: - - master - - trunk - paths: - - '.github/workflows/test-coverage.yml' - - 'phpunit.xml.dist' - - 'tests/phpunit/multisite.xml' - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - # Allow manually triggering the workflow. - workflow_dispatch: - -env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} - COMPOSER_INSTALL: ${{ false }} - # Controls which NPM script to use for running PHPUnit tests. Options ar `php` and `php-composer`. - PHPUNIT_SCRIPT: php - LOCAL_PHP: '7.4-fpm' - LOCAL_PHP_XDEBUG: true - LOCAL_PHP_MEMCACHED: ${{ false }} - -jobs: - # Sets up WordPress for testing or development use. - # - # Performs the following steps: - # - Set environment variables. - # - Checks out the repository. - # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests). - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # - Sets up caching for NPM. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Logs debug general information. - # - Logs the running Docker containers. - # - Logs WordPress Docker container debug information. - # - Logs debug information about what's installed within the WordPress Docker containers. - # - Install WordPress within the Docker container. - # - Run the PHPUnit tests as a single site. - # - Upload the single site code coverage report to Codecov.io. - # - Run the PHPUnit tests as a multisite. - # - Upload the multisite code coverage report to Codecov.io. - test-coverage-report: - name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - multisite: [ false, true ] - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV - echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Log debug information - run: | - echo "$GITHUB_REF" - echo "$GITHUB_EVENT_NAME" - npm --version - node --version - curl --version - git --version - svn --version - php --version - php -i - locale -a - - - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install Dependencies - run: npm ci - - - name: Docker debug information - run: | - docker -v - docker-compose -v - - - name: Start Docker environment - run: | - npm run env:start - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker-compose run --rm mysql mysql --version - docker-compose run --rm php php --version - docker-compose run --rm php php -m - docker-compose run --rm php php -i - docker-compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Run tests as a single site - if: ${{ ! matrix.multisite }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml - - - name: Upload single site report to Codecov - if: ${{ ! matrix.multisite }} - uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649 # v1.2.1 - with: - file: wp-code-coverage-single-clover-${{ github.sha }}.xml - flags: single,php - - - name: Run tests as a multisite install - if: ${{ matrix.multisite }} - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml - - - name: Upload multisite report to Codecov - if: ${{ matrix.multisite }} - uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649 # v1.2.1 - with: - file: wp-code-coverage-multisite-clover-${{ github.sha }}.xml - flags: multisite,php diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml deleted file mode 100644 index ce16cb28153b5..0000000000000 --- a/.github/workflows/test-npm.yml +++ /dev/null @@ -1,166 +0,0 @@ -name: Test NPM - -on: - push: - branches: - - master - - trunk - - '3.[7-9]' - - '[4-9].[0-9]' - pull_request: - branches: - - master - - trunk - - '3.[7-9]' - - '[4-9].[0-9]' - paths: - # These files configure NPM. Changes could affect the outcome. - - 'package*.json' - # JavaScript files are built using NPM. - - '**.js' - # CSS and SCSS files are built using NPM. - - '**.scss' - - '**.css' - # Changes to workflow files should always verify all workflows are successful. - - '.github/workflows/**.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 - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} - -jobs: - # Verifies that installing NPM dependencies and building WordPress works as expected. - # - # Performs the following steps: - # - Checks out the repository. - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # - Sets up caching for NPM. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Builds WordPress to run from the `build` directory. - # - Cleans up after building WordPress to the `build` directory. - # - Builds WordPress to run from the `src` directory. - # - Cleans up after building WordPress to the `src` directory. - test-npm: - name: Test NPM on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, windows-latest ] - - steps: - - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14 - - - name: Cache NodeJS modules (Ubuntu & MacOS) - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os != 'windows-latest' }} - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Get NPM cache directory (Windows only) - if: ${{ matrix.os == 'windows-latest' }} - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - - name: Cache NodeJS modules (Windows only) - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os == 'windows-latest' }} - with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install Dependencies - run: npm ci - - - name: Build WordPress - run: npm run build - - - name: Clean after building - run: npm run grunt clean - - - name: Build WordPress in /src - run: npm run build:dev - - - name: Clean after building in /src - run: npm run grunt clean -- --dev - - # Verifies that installing NPM dependencies and building WordPress works as expected on MacOS. - # - # This is a separate job in order to that more strict conditions can be used. - # - # Performs the following steps: - # - Checks out the repository. - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # - Sets up caching for NPM. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Builds WordPress to run from the `build` directory. - # - Cleans up after building WordPress to the `build` directory. - # - Builds WordPress to run from the `src` directory. - # - Cleans up after building WordPress to the `src` directory. - test-npm-macos: - name: Test NPM on MacOS - runs-on: macos-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - steps: - - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os != 'windows-latest' }} - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install Dependencies - run: npm ci - - - name: Build WordPress - run: npm run build - - - name: Clean after building - run: npm run grunt clean - - - name: Build WordPress in /src - run: npm run build:dev - - - name: Clean after building in /src - run: npm run grunt clean -- --dev diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml deleted file mode 100644 index 03cd79f4a258a..0000000000000 --- a/.github/workflows/test-old-branches.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Test old branches - -on: - # Verify the workflow is successful when this file is updated. - push: - branches: - - master - - trunk - paths: - - '.github/workflows/test-old-branches.yml' - # Run twice a month on the 1st and 15th at 00:00 UTC. - schedule: - - cron: '0 0 1 * *' - - cron: '0 0 15 * *' - -jobs: - dispatch-workflows-for-old-branches: - name: ${{ matrix.workflow }} for ${{ matrix.branch }} - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - workflow: [ - 'coding-standards.yml', - 'javascript-tests.yml', - 'phpunit-tests.yml', - 'test-npm.yml' - ] - branch: [ - '5.7', '5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0', - '4.9', '4.8', '4.7', '4.6', '4.5', '4.4', '4.3', '4.2', '4.1', '4.0', - '3.9', '3.8', '3.7' - ] - include: - # PHP Compatibility testing was introduced in 5.5. - - branch: '5.7' - workflow: 'php-compatibility.yml' - - branch: '5.6' - workflow: 'php-compatibility.yml' - - branch: '5.5' - workflow: 'php-compatibility.yml' - - # End to End testing was introduced in 5.3 but later removed as there were no meaningful assertions. - # Only the officially supported major branch runs E2E tests so that more assertions can be added, and the - # workflow does not continue to run needlessly on old branches. - - branch: '5.7' - workflow: 'end-to-end-tests.yml' - exclude: - # Coding standards and JavaScript testing did not take place in 3.7. - - branch: '3.7' - workflow: 'coding-standards.yml' - - branch: '3.7' - workflow: 'javascript-tests.yml' - - # Run all branches monthly, but only the currently supported one twice per month. - steps: - - name: Dispatch workflow run - uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # v3.1.0 - if: ${{ github.event_name == 'push' || github.event.schedule == '0 0 15 * *' || matrix.branch == '5.7' }} - with: - github-token: ${{ secrets.GHA_OLD_BRANCH_DISPATCH }} - script: | - github.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: '${{ matrix.workflow }}', - ref: '${{ matrix.branch }}' - }); diff --git a/.github/workflows/welcome-new-contributors.yml b/.github/workflows/welcome-new-contributors.yml deleted file mode 100644 index f475a432a0b86..0000000000000 --- a/.github/workflows/welcome-new-contributors.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Welcome New Contributors - -on: - pull_request_target: - types: [ opened ] - -jobs: - # Comments on a pull request when the author is a new contributor. - post-welcome-message: - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - - steps: - - uses: bubkoo/welcome-action@8dbbac2540d155744c90e4e37da6b05ffc9c5e2c # v1.0.3 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - FIRST_PR_COMMENT: > - 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! - - - **No one monitors this repository for new pull requests.** Pull requests **must** be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the 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 [this blog post](https://make.wordpress.org/core/2020/02/21/working-on-trac-tickets-using-github-pull-requests/). - - - **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: - - - [PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/) - - - [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/) - - - [HTML Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/) - - - [JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/) - - - [Accessibility Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/) - - - [Inline Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/) - - - Thank you, - - The WordPress Project diff --git a/src/wp-includes/class-wp-widget.php b/src/wp-includes/class-wp-widget.php index fa206e7d352ea..b3c7d4b016609 100644 --- a/src/wp-includes/class-wp-widget.php +++ b/src/wp-includes/class-wp-widget.php @@ -366,6 +366,7 @@ public function display_callback( $args, $widget_args = 1 ) { $instances = $this->get_settings(); if ( array_key_exists( $this->number, $instances ) ) { +// if ( isset( $instances[ $this->number ] ) ) { $instance = $instances[ $this->number ]; /** diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 4c34dfcd73e4b..6d30252e72b04 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -590,6 +590,88 @@ function test_wp_widget__register() { // @todo Test WP_Widget::display_callback(). + /** + * @ticket 52728 + */ + function test_widget_display_callback_handles_arrayobject() { + $widget = new WP_Widget_Text(); + + register_widget( $widget ); +/* + update_option( + $widget->option_name, + new ArrayObject( + array( + 2 => array( 'title' => 'Test Title' ), + '_multiwidget' => 1, + '__i__' => true, + ) + ) + ); +*/ +// $this->expectOutputString( 'Test Title' ); + + ob_start(); + $widget->widget( + array( + 'before_widget' => '
', + 'after_widget' => "
\n", + 'before_title' => '

', + 'after_title' => "

\n", + ), + new ArrayObject( + array( + 2 => array( 'title' => 'Test Title' ), + '_multiwidget' => 1, + '__i__' => true, + ) + ) + ); +/* + the_widget( + 'WP_Widget_Text', + get_option( $widget->option_name ), + array( + 'before_widget' => '
', + 'after_widget' => "
\n", + 'before_title' => '

', + 'after_title' => "

\n", + ) + ); +*/ + $widget_content = ob_get_clean(); +// unregister_widget( 'WP_Widget_Text' ); + + +var_dump($widget_content); + unregister_widget( $widget ); + + $this->assertContains( 'Test Title', $widget_content ); + } + +/* + wp_widgets_init(); + $wp_widget_search = $wp_registered_widgets['search-2']['callback'][0]; + + $settings = $wp_widget_search->get_settings(); + $overridden_title = 'Unit Tested'; + + /* + * Note that if a plugin is filtering $settings to be an ArrayIterator, + * then doing this: + * $settings[2]['title'] = $overridden_title; + * Will fail with this: + * > Indirect modification of overloaded element of X has no effect. + * So this is why the value must be obtained. + * / + $instance = $settings[2]; + $instance['title'] = $overridden_title; + $settings[2] = $instance; + + $wp_widget_search->save_settings( $settings ); + + $option_value = get_option( $wp_widget_search->option_name ); +*/ /** * @see WP_Widget::is_preview() */