Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 55 additions & 11 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@ env:
jobs:

lint:
name: Lint and Test
name: Lint and Test (PHP ${{ matrix.php }})
runs-on: ubuntu-22.04
timeout-minutes: 10
timeout-minutes: 20
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
include:
- php: '7.4'
wordpress_image: latest
xdebug: '3.1.6'
- php: '8.2'
wordpress_image: php8.2
xdebug: '3.2.1'
- php: '8.3'
wordpress_image: php8.3
xdebug: '3.3.2'
env:
WORDPRESS_IMAGE_VERSION: ${{ matrix.wordpress_image }}
steps:

- name: Checkout
Expand All @@ -40,8 +55,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ hashFiles( 'composer.lock' ) }}
restore-keys: ${{ runner.os }}-php-
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles( 'composer.lock' ) }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-

- name: Log in to the Container registry
uses: docker/login-action@v3
Expand All @@ -63,19 +78,43 @@ jobs:
run: npm run build

- name: Pull custom Docker images
run: docker compose pull wordpress
# `--ignore-pull-failures` so unpublished tags (e.g. php8.3 before
# docker-images.yml has published it from master) still pass. Compose
# then builds from local/docker/wordpress/Dockerfile.
run: docker compose pull --ignore-pull-failures wordpress

- name: Build WordPress image for matrix PHP
run: docker compose build --build-arg PHP_VERSION=${{ matrix.php }} --build-arg XDEBUG_VERSION=${{ matrix.xdebug }} wordpress

- name: Confirm container PHP version
run: npm run which-php

- name: Test
run: npm run test

e2e:
name: E2E
name: E2E (PHP ${{ matrix.php }})
runs-on: ubuntu-22.04
timeout-minutes: 12
timeout-minutes: 20
needs: lint
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
include:
- php: '7.4'
wordpress_image: latest
xdebug: '3.1.6'
- php: '8.2'
wordpress_image: php8.2
xdebug: '3.2.1'
- php: '8.3'
wordpress_image: php8.3
xdebug: '3.3.2'
env:
WORDPRESS_IMAGE_VERSION: ${{ matrix.wordpress_image }}
steps:

- name: Checkout
Expand All @@ -101,8 +140,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ hashFiles( 'composer.lock' ) }}
restore-keys: ${{ runner.os }}-php-
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles( 'composer.lock' ) }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-

- name: Map stream.wpenv.net to localhost
run: echo "127.0.0.1 stream.wpenv.net" | sudo tee -a /etc/hosts
Expand Down Expand Up @@ -150,11 +189,16 @@ jobs:
# :443 with ERR_CONNECTION_CLOSED. Build locally so the branch's
# Dockerfile actually applies; Docker layer caching keeps this cheap
# when the Dockerfile hasn't changed since the last published build.
run: docker compose build wordpress
# PHP_VERSION / XDEBUG_VERSION match docker-compose.build.yml so
# unpublished tags (php8.3) still produce the matrix PHP runtime.
run: docker compose build --build-arg PHP_VERSION=${{ matrix.php }} --build-arg XDEBUG_VERSION=${{ matrix.xdebug }} wordpress

- name: Start WordPress
run: npm run start

- name: Confirm container PHP version
run: npm run which-php

- name: Wait for MySQL (from inside the wordpress container)
run: |
npm run cli -- php -r '
Expand Down Expand Up @@ -188,6 +232,6 @@ jobs:
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report
name: playwright-report-php-${{ matrix.php }}
path: playwright-report
retention-days: 7
16 changes: 15 additions & 1 deletion classes/class-as-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class AS_Scheduler implements Scheduler {
* @return void
*/
public function enqueue_async( $hook, $args = array(), $group = '' ) {
as_enqueue_async_action( $hook, $args, $group );
if ( function_exists( 'as_enqueue_async_action' ) ) {
as_enqueue_async_action( $hook, $args, $group );
}
}

/**
Expand All @@ -54,6 +56,10 @@ public function enqueue_async( $hook, $args = array(), $group = '' ) {
* @return void
*/
public function schedule_recurring( $timestamp, $interval, $hook, $args = array(), $group = '' ) {
if ( ! function_exists( 'as_next_scheduled_action' ) || ! function_exists( 'as_schedule_recurring_action' ) ) {
return;
}

if ( false === as_next_scheduled_action( $hook ) ) {
as_schedule_recurring_action( $timestamp, $interval, $hook, $args, $group );
}
Expand All @@ -67,6 +73,10 @@ public function schedule_recurring( $timestamp, $interval, $hook, $args = array(
* @return int|false
*/
public function next_scheduled( $hook, $args = array() ) {
if ( ! function_exists( 'as_next_scheduled_action' ) ) {
return false;
}

return as_next_scheduled_action( $hook, empty( $args ) ? null : $args );
}

Expand All @@ -77,6 +87,10 @@ public function next_scheduled( $hook, $args = array() ) {
* @return bool
*/
public function has_scheduled( $hook ) {
if ( ! function_exists( 'as_has_scheduled_action' ) ) {
return false;
}

return as_has_scheduled_action( $hook );
}

Expand Down
2 changes: 1 addition & 1 deletion classes/class-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function update( $db_version, $current_version, $update_args ) {
$function = 'wp_stream_update_' . ( 'user' === $update_args['type'] ? '' : $update_args['type'] . '_' ) . str_ireplace( '.', '', $version );

if ( version_compare( $db_version, $version, '<' ) ) {
$result = function_exists( $function ) ? call_user_func( $function, $db_version, $current_version ) : $current_version;
$result = function_exists( $function ) ? call_user_func( $function, $db_version, $current_version, $this ) : $current_version;

if ( $current_version !== $result ) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions connectors/class-connector-two-factor.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ public function callback_wp_login_failed( $user_login, $error ) {
$user = get_user_by( 'email', $user_login );
}

if ( ! $user ) {
return;
}

/* Translators: %1$s is the user display name, %2$s is the error code, %3$s is the error message. */
$message = __(
'%1$s Failed 2FA: %2$s %3$s',
Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ We use npm as the canonical task runner for the project. The following commands
- `npm run test-xdebug` will run the PHPunit tests with Xdebug enabled.
- `npm run test-e2e` will run the Playwright E2E tests.
- `npm run test-e2e-debug` will run the Playwright E2E tests in a debug mode (with Chromium browser and dev tools open).
- `npm run switch-to:php7.4` and `npm run switch-to:php8.2` will switch you to either PHP 7.4 or PHP 8.2
- `npm run switch-to:php7.4`, `npm run switch-to:php8.2`, and `npm run switch-to:php8.3` switch the WordPress container PHP version. The default remains PHP 7.4. Confirm with `npm run which-php`.
- `npm run document:connectors` generates [connectors.md](connectors.md). This runs via your local php.
- `npm run large-records-generate` inserts ~1.6M rows to `wp_stream` and ~8.4M rows to `wp_streammeta` for testing
- `npm run large-records-remove` removes the test data only
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ services:
PHP_VERSION: "8.2"
XDEBUG_VERSION: "3.2.1"

wordpress_php8.3:
image: ghcr.io/xwp/stream-wordpress:php8.3
build:
context: ./local/docker/wordpress
args:
PHP_VERSION: "8.3"
XDEBUG_VERSION: "3.3.2"

# Helper image that generates a locally-trusted TLS cert via mkcert for
# the Apache HTTPS vhost on the wordpress service. Pre-built and pushed
# to ghcr.io so CI and contributors don't rebuild it on every fresh
Expand Down
32 changes: 20 additions & 12 deletions includes/db-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
*
* Force update for older versions to call \dbdelta in install() method to fix column widths.
*
* @param string $db_version New database version.
* @param string $current_version Current database version.
* @param string $db_version New database version.
* @param string $current_version Current database version.
* @param \WP_Stream\Install|null $install Install instance performing the update.
*
* @return string
* @return string|false
*/
function wp_stream_update_auto_308( $db_version, $current_version ) {
$plugin = wp_stream_get_instance();
$plugin->install->install( $current_version );
function wp_stream_update_auto_308( $db_version, $current_version, $install = null ) {
if ( ! $install instanceof \WP_Stream\Install ) {
return false;
}

$install->install( $current_version );

return $current_version;
}
Expand Down Expand Up @@ -72,19 +76,23 @@ function wp_stream_update_302( $db_version, $current_version ) {
*
* Update from 1.4.9
*
* @param string $db_version New database version.
* @param string $current_version Current database version.
* @param string $db_version New database version.
* @param string $current_version Current database version.
* @param \WP_Stream\Install|null $install Install instance performing the update.
*
* @return string
* @return string|false
*/
function wp_stream_update_auto_300( $db_version, $current_version ) {
function wp_stream_update_auto_300( $db_version, $current_version, $install = null ) {
global $wpdb;

// Get only the author_meta values that are double-serialized.
$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}stream TO {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context TO {$wpdb->base_prefix}stream_context_tmp" );

$plugin = wp_stream_get_instance();
$plugin->install->install( $current_version );
if ( ! $install instanceof \WP_Stream\Install ) {
return false;
}

$install->install( $current_version );

$starting_row = 0;
$rows_per_round = 5000;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"push-containers": "docker compose --file docker-compose.build.yml push",
"start": "docker compose up --remove-orphans --detach",
"start-xdebug": "XDEBUG_TRIGGER=1 docker compose up --remove-orphans --detach",
"switch-to:php8.3": "docker compose build --build-arg PHP_VERSION=8.3 --build-arg XDEBUG_VERSION=3.3.2 && npm run start",
"switch-to:php8.2": "docker compose build --build-arg PHP_VERSION=8.2 --build-arg XDEBUG_VERSION=3.3.2 && npm run start",
"switch-to:php7.4": "docker compose build && npm run start",
"which-php": "npm run cli -- php --version",
Expand Down
4 changes: 2 additions & 2 deletions stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function wp_stream_fail_php_version() {
/**
* Helper for external plugins which wish to use Stream.
*
* @return WP_Stream\Plugin
* @return WP_Stream\Plugin|null Plugin instance, or null if Stream has not finished constructing.
*/
function wp_stream_get_instance() {
return $GLOBALS['wp_stream'];
return $GLOBALS['wp_stream'] ?? null;
}
Loading
Loading