Skip to content

Commit

Permalink
Merge branch 'develop' into fix/42-non-ascii-characters-rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored May 24, 2024
2 parents 5c0a884 + 583c48d commit 2e09d00
Show file tree
Hide file tree
Showing 35 changed files with 1,066 additions and 248 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.yml]
[{*.yml,*.feature}]
indent_style = space
indent_size = 2

Expand Down
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# The following teams will get auto-tagged for a review.
# See https://docs.github.com/en/enterprise/2.15/user/articles/about-code-owners

* @Automattic/redirector
27 changes: 27 additions & 0 deletions .github/workflows/behat-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Behat Testing

on:
push:
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
pull_request:
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
types:
- opened
- reopened
- synchronize

workflow_dispatch:

jobs:
behat:
uses: automattic/wpvip-plugins-.github/.github/workflows/reusable-behat-test.yml@trunk
73 changes: 73 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Integration Tests

on: [push]

jobs:
test:
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }}

env:
WP_VERSION: ${{ matrix.wordpress }}

strategy:
matrix:
include:
# Check lowest supported WP version, with the lowest supported PHP.
- wordpress: '5.9'
php: '7.4'
allowed_failure: false
# Check latest WP with the highest supported PHP.
- wordpress: 'latest'
php: 'latest'
allowed_failure: false
# Check upcoming WP.
- wordpress: 'trunk'
php: 'latest'
allowed_failure: true
# Check upcoming PHP - only needed when a new version has been forked (typically Sep-Nov)
# - wordpress: 'trunk'
# php: 'nightly'
# allowed_failure: true
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: ${{ matrix.ini-values }}
coverage: ${{ matrix.coverage }}

- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: --ignore-platform-req=php+

- name: Set up problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Set up problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Show PHP and PHPUnit version info
run: |
php --version
./vendor/bin/phpunit --version
- name: Start MySQL service
run: sudo systemctl start mysql.service

- name: Install WordPress environment
run: composer prepare ${{ matrix.wordpress }}

- name: Run integration tests (single site)
run: composer test-integration

- name: Run integration tests (multisite)
run: composer test-integration-ms
67 changes: 67 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Unit Tests

on: [push]

jobs:
test:
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }}

env:
WP_VERSION: ${{ matrix.wordpress }}

strategy:
matrix:
include:
# Check lowest supported WP version, with the lowest supported PHP.
- wordpress: '5.9'
php: '7.4'
allowed_failure: false
# Check latest WP with the highest supported PHP.
- wordpress: 'latest'
php: 'latest'
allowed_failure: false
# Check upcoming WP.
- wordpress: 'trunk'
php: 'latest'
allowed_failure: true
# Check upcoming PHP - only needed when a new version has been forked (typically Sep-Nov)
# - wordpress: 'trunk'
# php: 'nightly'
# allowed_failure: true
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: ${{ matrix.ini-values }}
coverage: ${{ matrix.coverage }}

- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: --ignore-platform-req=php+

- name: Set up problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Set up problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Show PHP and PHPUnit version info
run: |
php --version
./vendor/bin/phpunit --version
- name: Run unit tests (single site)
run: composer test-unit

- name: Run unit tests (multisite)
run: composer test-unit-ms
62 changes: 62 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="wpcom-legacy-redirector" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Custom ruleset for wpcom-legacy-redirector plugin.</description>

<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->

<!-- What to scan -->
<file>.</file>
<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>/vendor/</exclude-pattern>

<!-- How to scan -->
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- Show sniff and progress -->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
<!-- Show results with colors -->
<arg name="colors"/>
<!-- Limit to PHP files -->
<arg name="extensions" value="php"/>
<!-- Enables parallel processing when available for faster results. -->
<arg name="parallel" value="8"/>

<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.4-"/>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- WordPress-Extra includes WordPress-Core -->
<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>
<!-- For help in understanding these custom sniff properties:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="5.9"/>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="wpcom-legacy-redirector"/>
</property>
</properties>
</rule>

<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>

<rule ref="WordPress.Files.FileName">
<exclude-pattern>tests/</exclude-pattern>
</rule>

</ruleset>
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

Requires PHP 5.6.
Requires PHP 7.4.
Requires WordPress 5.9.

### Added
- Admin pages to view, add, delete, and validate redirects. Uses new `manage_redirects` capability.
Expand All @@ -19,7 +20,7 @@ Requires PHP 5.6.

## Changed
- Improved adherence to WPCS and VIPCS coding standards.
- Drop PHP 5.3 support.
- Drop PHP 5.3-7.3 support.
- Use WP_CLI:error to halt operation on failed insert using `insert-redirect`.
- Return an error if no redirects were found for a meta key.
- Added performance improvement for `import-from-meta` command.
Expand All @@ -30,7 +31,6 @@ Requires PHP 5.6.
- Trim whitespace around CSV file path, to support dragging a file into the terminal window to add the path.
- Ensure `POST` var is set during CLI command.


## [1.3.0] - 2016-03-29

### Added
Expand Down
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@

WordPress plugin for handling legacy redirects in a scalable manner.

Redirects are stored as a custom post type and use the following fields:

- `post_name` for the md5 hash of the "from" path or URL.
- we use this column, since it's indexed and queries are super fast.
- we also use an md5 just to simplify the storage.
- `post_title` to store the non-md5 version of the "from" path.
- one of either:
- `post_parent` if we're redirect to a post; or
- `post_excerpt` if we're redirecting to an alternate URL.

For detailed documentation, please see https://wpvip.com/plugins/wpcom-legacy-redirector/

Please contact us before using this plugin.
Please see our [wiki](https://github.com/Automattic/WPCOM-Legacy-Redirector/wiki) for detailed documentation.

## Requirements

- PHP 5.6+
- WordPress 4.5+
- PHP 7.4+
- WordPress 5.9+

## Change Log

Expand Down
7 changes: 7 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default:
suites:
default:
contexts:
- Automattic\LegacyRedirector\Tests\Behat\FeatureContext
paths:
- features
Loading

0 comments on commit 2e09d00

Please sign in to comment.