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

v4 update includes #721

Merged
merged 5 commits into from
May 13, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased] Unreleased

### Changed

- Updated `sqlite-integration-plugin` and Core PHPUnit suite files.

## [4.1.7] 2024-04-12;

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"lucatume/codeception-snapshot-assertions": "^1.0.0",
"gumlet/php-image-resize": "^1.6",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/phpstan": "*",
"phpstan/phpstan": "1.10.56",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-symfony": "^1.3",
"squizlabs/php_codesniffer": "^3.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/includes/core-phpunit/includes/testcase-rest-api.php b/includes/core-phpunit/includes/testcase-rest-api.php
index 54644f13..670a2cd1 100644
index 27349809..2107abfc 100644
--- a/includes/core-phpunit/includes/testcase-rest-api.php
+++ b/includes/core-phpunit/includes/testcase-rest-api.php
@@ -1,6 +1,8 @@
Expand All @@ -9,6 +9,6 @@ index 54644f13..670a2cd1 100644
+namespace lucatume\WPBrowser\TestCase;
+
+abstract class WPRestApiTestCase extends WPTestCase {
protected function assertErrorResponse( $code, $response, $status = null ) {

if ( $response instanceof WP_REST_Response ) {
/**
* Asserts that the REST API response has the specified error.
4 changes: 2 additions & 2 deletions config/patches/sqlite-database-integration/load.php.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/includes/sqlite-database-integration/load.php b/includes/sqlite-database-integration/load.php
index 3af80903..ddc5a9b6 100644
index bd6d875b..c80dcdd7 100644
--- a/includes/sqlite-database-integration/load.php
+++ b/includes/sqlite-database-integration/load.php
@@ -12,7 +12,9 @@
Expand All @@ -11,5 +11,5 @@ index 3af80903..ddc5a9b6 100644
+ define('SQLITE_MAIN_FILE', __FILE__);
+}

require_once __DIR__ . '/php-polyfills.php';
require_once __DIR__ . '/admin-page.php';
require_once __DIR__ . '/activate.php';
2 changes: 1 addition & 1 deletion includes/core-phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ protected function update_post_modified( $post_id, $date ) {
/**
* Touches the given file and its directory if it doesn't already exist.
*
* This can be used to ensure a file that is implictly relied on in a test exists
* This can be used to ensure a file that is implicitly relied on in a test exists
* without it having to be built.
*
* @param string $file The file name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function create_many( $count, $args = array(), $generation_definitions =
* @param array|null $callbacks Optional. Array with callbacks to apply on the fields.
* Default null.
*
* @return array|WP_Error Combined array on success. WP_Error when default value is incorrent.
* @return array|WP_Error Combined array on success. WP_Error when default value is incorrect.
*/
public function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) {
$callbacks = array();
Expand Down
8 changes: 4 additions & 4 deletions includes/core-phpunit/includes/normalize-xml.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Normalize an XML document to make it easier to compare whether 2 documents will
be seen as "equal" to an XML processor.

The normalization is similiar, in spirit, to {@link https://www.w3.org/TR/xml-c14n11/ Canonical XML},
The normalization is similar, in spirit, to {@link https://www.w3.org/TR/xml-c14n11/ Canonical XML},
but without some aspects of C14N that make the kinds of assertions we need difficult.

For example, the following XML documents will be interpreted the same by an XML processor,
Expand All @@ -23,7 +23,7 @@
>

<!--
Output UTF-8 XML, no indendation and all CDATA sections replaced with their character content.
Output UTF-8 XML, no indentation and all CDATA sections replaced with their character content.
-->
<xsl:output
method='xml'
Expand Down Expand Up @@ -61,12 +61,12 @@
</xsl:template>

<!--
Strip comments.
Strip comments.
-->
<xsl:template match='comment()' priority='10' />

<!--
Pass all other nodes through unchanged.
Pass all other nodes through unchanged.
-->
<xsl:template match='node()'>
<xsl:copy>
Expand Down
4 changes: 2 additions & 2 deletions includes/core-phpunit/includes/testcase-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function set_up_before_class() {
/**
* Sets up the test fixture.
*
* Overrides wp_die(), pretends to be Ajax, and suppresses E_WARNINGs.
* Overrides wp_die(), pretends to be Ajax, and suppresses warnings.
*/
public function set_up() {
parent::set_up();
Expand Down Expand Up @@ -164,7 +164,7 @@ public function tear_down() {
$_GET = array();
unset( $GLOBALS['post'] );
unset( $GLOBALS['comment'] );
remove_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
remove_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1 );
remove_action( 'clear_auth_cookie', array( $this, 'logout' ) );
error_reporting( $this->_error_level );
set_current_screen( 'front' );
Expand Down
22 changes: 17 additions & 5 deletions includes/core-phpunit/includes/testcase-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@
namespace lucatume\WPBrowser\TestCase;

abstract class WPRestApiTestCase extends WPTestCase {
protected function assertErrorResponse( $code, $response, $status = null ) {

/**
* Asserts that the REST API response has the specified error.
*
* @since 4.4.0
* @since 6.6.0 Added the `$message` parameter.
*
* @param string|int $code Expected error code.
* @param WP_REST_Response|WP_Error $response REST API response.
* @param int $status Optional. Status code.
* @param string $message Optional. Message to display when the assertion fails.
*/
protected function assertErrorResponse( $code, $response, $status = null, $message = '' ) {

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

$this->assertWPError( $response );
$this->assertSame( $code, $response->get_error_code() );
$this->assertWPError( $response, $message . ' Passed $response is not a WP_Error object.' );
$this->assertSame( $code, $response->get_error_code(), $message . ' The expected error code does not match.' );

if ( null !== $status ) {
$data = $response->get_error_data();
$this->assertArrayHasKey( 'status', $data );
$this->assertSame( $status, $data['status'] );
$this->assertArrayHasKey( 'status', $data, $message . ' Passed $response does not include a status code.' );
$this->assertSame( $status, $data['status'], $message . ' The expected status code does not match.' );
}
}
}
26 changes: 13 additions & 13 deletions includes/sqlite-database-integration/admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ function sqlite_integration_admin_screen() {
<?php elseif ( file_exists( WP_CONTENT_DIR . '/db.php' ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) ) : ?>
<?php if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) : ?>
<div class="notice notice-warning">
<p>
<p>
<?php
printf(
/* translators: %s: db.php drop-in path */
esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ),
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
);
?>
</p>
</div>
<a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>">
<?php
printf(
/* translators: %s: db.php drop-in path */
esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ),
esc_html__( 'Update %s file', 'sqlite-database-integration' ),
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
);
?>
</p>
</div>
<a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>">
<?php
printf(
/* translators: %s: db.php drop-in path */
esc_html__( 'Update %s file', 'sqlite-database-integration' ),
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
);
?>
</a>
</a>
<?php else : ?>
<div class="notice notice-error">
<p>
Expand Down
3 changes: 2 additions & 1 deletion includes/sqlite-database-integration/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: SQLite Database Integration
* Description: SQLite database driver drop-in.
* Author: The WordPress Team
* Version: 2.1.7
* Version: 2.1.10
* Requires PHP: 7.0
* Textdomain: sqlite-database-integration
*
Expand All @@ -16,6 +16,7 @@
define('SQLITE_MAIN_FILE', __FILE__);
}

require_once __DIR__ . '/php-polyfills.php';
require_once __DIR__ . '/admin-page.php';
require_once __DIR__ . '/activate.php';
require_once __DIR__ . '/deactivate.php';
Expand Down
54 changes: 54 additions & 0 deletions includes/sqlite-database-integration/php-polyfills.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* Polyfills for php 7 & 8 functions
*
* @package wp-sqlite-integration
*/

if ( ! function_exists( 'str_starts_with' ) ) {
/**
* Check if a string starts with a specific substring.
*
* @param string $haystack The string to search in.
* @param string $needle The string to search for.
*
* @see https://www.php.net/manual/en/function.str-starts-with
*
* @return bool
*/
function str_starts_with( string $haystack, string $needle ) {
return empty( $needle ) || 0 === strpos( $haystack, $needle );
}
}

if ( ! function_exists( 'str_contains' ) ) {
/**
* Check if a string contains a specific substring.
*
* @param string $haystack The string to search in.
* @param string $needle The string to search for.
*
* @see https://www.php.net/manual/en/function.str-contains
*
* @return bool
*/
function str_contains( string $haystack, string $needle ) {
return empty( $needle ) || false !== strpos( $haystack, $needle );
}
}

if ( ! function_exists( 'str_ends_with' ) ) {
/**
* Check if a string ends with a specific substring.
*
* @param string $haystack The string to search in.
* @param string $needle The string to search for.
*
* @see https://www.php.net/manual/en/function.str-ends-with
*
* @return bool
*/
function str_ends_with( string $haystack, string $needle ) {
return empty( $needle ) || substr( $haystack, -strlen( $needle ) === $needle );
}
}
2 changes: 1 addition & 1 deletion includes/sqlite-database-integration/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: wordpressdotorg, aristath
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 5.6
Stable tag: 2.1.7
Stable tag: 2.1.10
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: performance, database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function __construct( $pdo ) {
'release_lock' => 'release_lock',
'ucase' => 'ucase',
'lcase' => 'lcase',
'unhex' => 'unhex',
'inet_ntoa' => 'inet_ntoa',
'inet_aton' => 'inet_aton',
'datediff' => 'datediff',
Expand Down Expand Up @@ -633,6 +634,21 @@ public function lcase( $content ) {
return "lower($content)";
}

/**
* Method to emulate MySQL UNHEX() function.
*
* For a string argument str, UNHEX(str) interprets each pair of characters
* in the argument as a hexadecimal number and converts it to the byte represented
* by the number. The return value is a binary string.
*
* @param string $number Number to be unhexed.
*
* @return string Binary string
*/
public function unhex( $number ) {
return pack( 'H*', $number );
}

/**
* Method to emulate MySQL INET_NTOA() function.
*
Expand Down
Loading
Loading