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

build(v3.5) autobuild #700

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 4 additions & 16 deletions includes/Hautelook/Phpass/PasswordHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,10 @@
*/
class PasswordHash
{
/**
* @var string
*/
private $itoa64;
/**
* @var int
*/
private $iteration_count_log2;
/**
* @var bool
*/
private $portable_hashes;
/**
* @var string
*/
private $random_state;
private string $itoa64;
private int $iteration_count_log2;
private bool $portable_hashes;
private string $random_state;

/**
* Constructor
Expand Down
47 changes: 18 additions & 29 deletions includes/cli-server/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,29 @@
* Extracted from the `wp-cli` project: https://wp-cli.org/
*/

if (function_exists('uopz_allow_exit')) {
uopz_allow_exit(true);
}

$root = $_SERVER['DOCUMENT_ROOT'];
$path = '/' . ltrim(parse_url(urldecode($_SERVER['REQUEST_URI']), PHP_URL_PATH), '/');
$path = '/'. ltrim( parse_url( urldecode( $_SERVER['REQUEST_URI'] ),PHP_URL_PATH ), '/' );

define('DB_ENGINE', getenv('DB_ENGINE') ?: 'mysql');

// The self-call will slow down the response handling and will not benefit the test environment.
global $wp_filter;
$wp_filter['do_mu_upgrade'][10][] = [
'accepted_args' => 0,
'function' => static function () {
return false;
}
];
if ( file_exists( $root.$path ) ) {

if (file_exists($root . $path)) {
// Enforces trailing slash, keeping links tidy in the admin
if (is_dir($root . $path) && substr_compare($path, '/', -strlen('/')) !== 0) {
header("Location: $path/");
exit;
}
// Enforces trailing slash, keeping links tidy in the admin
if ( is_dir( $root.$path ) && ! str_ends_with( $path, '/' ) ) {
header( "Location: $path/" );
exit;
}

// Runs PHP file if it exists
if (strpos($path, '.php') !== false) {
chdir(dirname($root . $path));
require_once $root . $path;
} else {
return false;
}
// Runs PHP file if it exists
if ( str_contains( $path, '.php' ) ) {
chdir( dirname( $root.$path ) );
require_once $root.$path;
} else {
return false;
}
} else {
// Otherwise, run `index.php`
chdir($root);
require_once 'index.php';

// Otherwise, run `index.php`
chdir( $root );
require_once 'index.php';
}
5 changes: 1 addition & 4 deletions includes/core-phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
protected $expected_doing_it_wrong = array();
protected $caught_doing_it_wrong = array();

/**
* @var string|null
*/
private static $calledClass;
private static ?string $calledClass = null;

protected static $hooks_saved = array();
protected static $ignore_files;
Expand Down
16 changes: 16 additions & 0 deletions includes/core-phpunit/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,26 @@ function _wp_rest_server_class_filter() {
* @since 5.0.0
*/
function _unhook_block_registration() {
// Block types.
require __DIR__ . '/unregister-blocks-hooks.php';
remove_action( 'init', 'register_core_block_types_from_metadata' );
remove_action( 'init', 'register_block_core_legacy_widget' );
remove_action( 'init', 'register_block_core_widget_group' );
remove_action( 'init', 'register_core_block_types_from_metadata' );

// Block binding sources.
remove_action( 'init', '_register_block_bindings_pattern_overrides_source' );
remove_action( 'init', '_register_block_bindings_post_meta_source' );
}
tests_add_filter( 'init', '_unhook_block_registration', 1000 );

/**
* After the init action has been run once, trying to re-register font collections can cause
* errors. To avoid this, unhook the font registration functions.
*
* @since 6.5.0
*/
function _unhook_font_registration() {
remove_action( 'init', '_wp_register_default_font_collections' );
}
tests_add_filter( 'init', '_unhook_font_registration', 1000 );
2 changes: 1 addition & 1 deletion includes/core-phpunit/includes/testcase-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
abstract class WPRestApiTestCase extends WPTestCase {
protected function assertErrorResponse( $code, $response, $status = null ) {

if ( $response instanceof WP_REST_Response ) {
if ( $response instanceof \WP_REST_Response ) {
$response = $response->as_error();
}

Expand Down
6 changes: 6 additions & 0 deletions includes/core-phpunit/includes/unregister-blocks-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@
remove_action( 'init', 'register_block_core_tag_cloud' );
remove_action( 'init', 'register_block_core_template_part' );
remove_action( 'init', 'register_block_core_term_description' );

// Temporary hook removals to prevent impacting the phpunit tests timing.
remove_action( 'registered_post_type', 'block_core_navigation_link_register_post_type_variation' );
remove_action( 'registered_taxonomy', 'block_core_navigation_link_register_taxonomy_variation' );
remove_action( 'unregistered_post_type', 'block_core_navigation_link_unregister_post_type_variation' );
remove_action( 'unregistered_taxonomy', 'block_core_navigation_link_unregister_taxonomy_variation' );
5 changes: 3 additions & 2 deletions includes/sqlite-database-integration/activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/
function sqlite_plugin_activation_redirect( $plugin ) {
if ( plugin_basename( SQLITE_MAIN_FILE ) === $plugin ) {
wp_redirect( admin_url( 'options-general.php?page=sqlite-integration' ) );
exit;
if ( wp_safe_redirect( admin_url( 'options-general.php?page=sqlite-integration' ) ) ) {
exit;
}
}
}
add_action( 'activated_plugin', 'sqlite_plugin_activation_redirect' );
Expand Down
8 changes: 7 additions & 1 deletion includes/sqlite-database-integration/admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
* @since 1.0.0
*/
function sqlite_add_admin_menu() {
add_options_page(__( 'SQLite integration', 'sqlite-database-integration' ), __( 'SQLite integration', 'sqlite-database-integration' ), 'manage_options', 'sqlite-integration', 'sqlite_integration_admin_screen');
add_options_page(
__( 'SQLite integration', 'sqlite-database-integration' ),
__( 'SQLite integration', 'sqlite-database-integration' ),
'manage_options',
'sqlite-integration',
'sqlite_integration_admin_screen'
);
}
add_action( 'admin_menu', 'sqlite_add_admin_menu' );

Expand Down
2 changes: 1 addition & 1 deletion includes/sqlite-database-integration/deactivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function sqlite_plugin_remove_db_file() {
// Run an action on `shutdown`, to deactivate the option in the MySQL database.
add_action(
'shutdown',
function() {
function () {
global $table_prefix;

// Get credentials for the MySQL database.
Expand Down
6 changes: 3 additions & 3 deletions includes/sqlite-database-integration/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/**
* Plugin Name: SQLite Database Integration
* Description: SQLite database driver drop-in.
* Author: WordPress Performance Team
* Version: 2.1.2
* Requires PHP: 5.6
* Author: The WordPress Team
* Version: 2.1.6
* Requires PHP: 7.0
* Textdomain: sqlite-database-integration
*
* This feature plugin allows WordPress to use SQLite instead of MySQL as its database.
Expand Down
4 changes: 2 additions & 2 deletions includes/sqlite-database-integration/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Contributors: wordpressdotorg, aristath
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 5.6
Stable tag: 2.1.2
Stable tag: 2.1.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: performance, database

SQLite-integration plugin from the WordPress Performance Team.
SQLite integration plugin by the WordPress Team.

== Description ==

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function select( $db, $dbh = null ) {
*
* @return string escaped
*/
function _real_escape( $str ) {
public function _real_escape( $str ) {
return addslashes( $str );
}

Expand Down Expand Up @@ -278,7 +278,7 @@ public function query( $query ) {
}

$this->result = $this->dbh->query( $query );
$this->num_queries++;
++$this->num_queries;

if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );
Expand Down Expand Up @@ -349,7 +349,7 @@ public function has_cap( $db_cap ) {
* @see wpdb::db_version()
*/
public function db_version() {
return '5.5';
return '8.0';
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* This file is a port of the Lexer & Tokens_List classes from the PHPMyAdmin/sql-parser library.
* This file is a port of the Lexer & TokensList classes from the PHPMyAdmin/sql-parser library.
*
* @package wp-sqlite-integration
* @see https://github.com/phpmyadmin/sql-parser
Expand Down Expand Up @@ -33,7 +33,7 @@ class WP_SQLite_Lexer {
*
* @var string[]
*/
public static $parser_methods = array(
protected const PARSER_METHODS = array(
// It is best to put the parsers in order of their complexity
// (ascending) and their occurrence rate (descending).
//
Expand Down Expand Up @@ -77,7 +77,7 @@ class WP_SQLite_Lexer {
*
* @var string[]
*/
public $keyword_name_indicators = array(
protected const KEYWORD_NAME_INDICATORS = array(
'FROM',
'SET',
'WHERE',
Expand All @@ -89,7 +89,7 @@ class WP_SQLite_Lexer {
*
* @var string[]
*/
public $operator_name_indicators = array(
protected const OPERATOR_NAME_INDICATORS = array(
',',
'.',
);
Expand Down Expand Up @@ -1486,7 +1486,7 @@ public function lex() {
*/
$token = null;

foreach ( static::$parser_methods as $method ) {
foreach ( self::PARSER_METHODS as $method ) {
$token = $this->$method();

if ( $token ) {
Expand Down Expand Up @@ -1668,10 +1668,10 @@ private function solve_ambiguity_on_function_keywords() {
$next = $this->tokens_get_next();
if (
( WP_SQLite_Token::TYPE_KEYWORD !== $next->type
|| ! in_array( $next->value, $this->keyword_name_indicators, true )
|| ! in_array( $next->value, self::KEYWORD_NAME_INDICATORS, true )
)
&& ( WP_SQLite_Token::TYPE_OPERATOR !== $next->type
|| ! in_array( $next->value, $this->operator_name_indicators, true )
|| ! in_array( $next->value, self::OPERATOR_NAME_INDICATORS, true )
)
&& ( null !== $next->value )
) {
Expand Down Expand Up @@ -2068,7 +2068,7 @@ public function parse_number() {
} elseif (
$this->last + 1 < $this->string_length
&& '0' === $this->str[ $this->last ]
&& ( 'x' === $this->str[ $this->last + 1 ] || 'X' === $this->str[ $this->last + 1 ] )
&& 'x' === $this->str[ $this->last + 1 ]
) {
$token .= $this->str[ $this->last++ ];
$state = 2;
Expand Down Expand Up @@ -2260,7 +2260,7 @@ public function parse_symbol() {
if ( null === $str ) {
$str = $this->parse_unknown();

if ( null === $str ) {
if ( null === $str && ! ( $flags & WP_SQLite_Token::FLAG_SYMBOL_PARAMETER ) ) {
$this->error( 'Variable name was expected.', $this->str[ $this->last ], $this->last );
}
}
Expand Down Expand Up @@ -2288,7 +2288,7 @@ public function parse_unknown() {
$token .= $this->str[ $this->last ];

// Test if end of token equals the current delimiter. If so, remove it from the token.
if ( substr_compare($token, $this->delimiter, -strlen($this->delimiter)) === 0 ) {
if ( str_ends_with( $token, $this->delimiter ) ) {
$token = substr( $token, 0, -$this->delimiter_length );
$this->last -= $this->delimiter_length - 1;
break;
Expand Down Expand Up @@ -2514,15 +2514,10 @@ public static function is_separator( $str ) {
* Constructor.
*
* @param stdClass[] $tokens The initial array of tokens.
* @param int $count The count of tokens in the initial array.
*/
public function tokens( array $tokens = array(), $count = -1 ) {
if ( empty( $tokens ) ) {
return;
}

public function tokens( array $tokens = array() ) {
$this->tokens = $tokens;
$this->tokens_count = -1 === $count ? count( $tokens ) : $count;
$this->tokens_count = count( $tokens );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function month( $field ) {
* From https://www.php.net/manual/en/datetime.format.php:
*
* n - Numeric representation of a month, without leading zeros.
* 1 through 12
* 1 through 12
*/
return intval( gmdate( 'n', strtotime( $field ) ) );
}
Expand Down Expand Up @@ -446,14 +446,14 @@ public function isnull( $field ) {
*
* As 'IF' is a reserved word for PHP, function name must be changed.
*
* @param mixed $expression the statement to be evaluated as true or false.
* @param mixed $true statement or value returned if $expression is true.
* @param mixed $false statement or value returned if $expression is false.
* @param mixed $expression The statement to be evaluated as true or false.
* @param mixed $truthy Statement or value returned if $expression is true.
* @param mixed $falsy Statement or value returned if $expression is false.
*
* @return mixed
*/
public function _if( $expression, $true, $false ) {
return ( true === $expression ) ? $true : $false;
public function _if( $expression, $truthy, $falsy ) {
return ( true === $expression ) ? $truthy : $falsy;
}

/**
Expand Down
Loading