Skip to content

Commit

Permalink
Add additional check to copy MySQL behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Zodiac1978 committed Jun 13, 2024
1 parent f521f5a commit cfb123c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/WP_SQLite_Translator_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ public function testRegexpReplace() {

$this->assertQuery( "SELECT * FROM _options WHERE REGEXP_REPLACE(option_name, '(-ignore|-remove)', '') = 'test'" );
$this->assertCount( 2, $this->engine->get_query_results() );

$this->assertQuery( 'SELECT REGEXP_REPLACE( null, 'a', 'x') as result' );
$results = $this->engine->get_query_results();
$this->assertEquals( null, $results[0]->result );

$this->assertQuery( 'SELECT REGEXP_REPLACE( 'abc', null, 'x') as result' );
$results = $this->engine->get_query_results();
$this->assertEquals( null, $results[0]->result );

$this->assertQuery( 'SELECT REGEXP_REPLACE( 'abc', 'a', null) as result' );
$results = $this->engine->get_query_results();
$this->assertEquals( null, $results[0]->result );
}

public function testInsertDateNow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ public function regexp_replace( $field, $pattern, $replacement ) {
* be reasonably safe since PHP does not allow null bytes in
* regular expressions anyway.
*/

Check failure on line 521 in wp-includes/sqlite/class-wp-sqlite-pdo-user-defined-functions.php

View workflow job for this annotation

GitHub Actions / Check code style

Whitespace found at end of line
/* Return null if one of the required parameter is null */
if ( is_null( $field ) || is_null( $pattern ) || is_null( $replacement ) ) {
return null;
}

if ( "\x00" === $pattern[0] ) {
$pattern = substr( $pattern, 1 );
$flags = '';
Expand Down

0 comments on commit cfb123c

Please sign in to comment.