Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent rewrite flushes for runtime checks #334

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Changes from 2 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
16 changes: 16 additions & 0 deletions includes/Checker/Runtime_Environment_Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,27 @@
// Get the existing active plugins.
$active_plugins = get_option( 'active_plugins' );

// Get the existing permalink structure.
$permalink_structure = get_option( 'permalink_structure' );

Check warning on line 31 in includes/Checker/Runtime_Environment_Setup.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Runtime_Environment_Setup.php#L31

Added line #L31 was not covered by tests

// Set the new prefix.
$old_prefix = $wpdb->set_prefix( $table_prefix . 'pc_' );

// Create and populate the test database tables if they do not exist.
if ( $wpdb->posts !== $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->posts ) ) ) {
/*
* Set the same permalink structure *before* install finishes,
* so that wp_install_maybe_enable_pretty_permalinks() does not flush rewrite rules.
*
* See https://github.com/WordPress/plugin-check/issues/330
*/
add_action(
'populate_options',
static function () use( $permalink_structure ) {
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
add_option( 'permalink_structure', $permalink_structure );
}
);

Check warning on line 49 in includes/Checker/Runtime_Environment_Setup.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Runtime_Environment_Setup.php#L44-L49

Added lines #L44 - L49 were not covered by tests

wp_install(
'Plugin Check',
'plugincheck',
Expand Down