Skip to content

Commit

Permalink
Merge pull request #138 from johngodley/fix/3.0.1
Browse files Browse the repository at this point in the history
Fix 3.0.1
  • Loading branch information
johngodley authored Jul 26, 2022
2 parents aa07d75 + 9c51e97 commit 17c83f4
Show file tree
Hide file tree
Showing 31 changed files with 270 additions and 206 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"sirbrillig/phpcs-variable-analysis": "^2.11",
"sirbrillig/phpcs-no-get-current-user": "^1.1",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"phpcompatibility/php-compatibility": "*"
},
"scripts": {
"pot": "wp i18n make-pot . languages/search-regex.pot --ignore-domain --exclude=build/search-regex-strings.php",
"pot": "wp i18n make-pot . languages/search-regex.pot --ignore-domain --exclude=build/search-regex-strings.php --exclude=build/search-regex.js",
"json": "wp i18n make-json languages --purge",
"test": "./vendor/bin/phpunit"
"test": "./vendor/bin/phpunit",
"lint": "./vendor/bin/phpcs -s"
},
"config": {
"allow-plugins": {
Expand Down
195 changes: 130 additions & 65 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const SVN_SOURCE_FILES = [
'!tsconfig.json',
'!search-regex.js.LICENSE.txt',
'!jsconfig.json',
'!api-footer.md',
'!api-header.md',
'!*.zip',
'!src',
'!src/**'
];

function downloadLocale( locale, wpName, type ) {
Expand Down
6 changes: 3 additions & 3 deletions includes/action/class-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ abstract public function to_json();
/**
* Perform the action
*
* @param integer $row_id Row ID.
* @param array $row Data for row.
* @param Source\Source $source Source.
* @param integer $row_id Row ID.
* @param array $row Data for row.
* @param Source\Source $source Source.
* @param array<Search\Column> $columns Contexts.
* @return array<Search\Column>|\WP_Error
*/
Expand Down
16 changes: 8 additions & 8 deletions includes/api/class-route.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ public function validate_search_flags( $value, \WP_REST_Request $request, $param
/**
* Validate that the view columns are valid
*
* @param Array|String $value The value to validate.
* @param Array|String $value The value to validate.
* @param \WP_REST_Request $request The request.
* @param Array $param The array of parameters.
* @param Array $param The array of parameters.
* @return \WP_Error|Bool true or false
*/
public function validate_view( $value, \WP_REST_Request $request, $param ) {
Expand All @@ -328,9 +328,9 @@ public function validate_view( $value, \WP_REST_Request $request, $param ) {
/**
* Validate that the view columns are valid
*
* @param Array|String $value The value to validate.
* @param Array|String $value The value to validate.
* @param \WP_REST_Request $request The request.
* @param Array $param The array of parameters.
* @param Array $param The array of parameters.
* @return \WP_Error|Bool true or false
*/
public function validate_action( $value, \WP_REST_Request $request, $param ) {
Expand All @@ -344,9 +344,9 @@ public function validate_action( $value, \WP_REST_Request $request, $param ) {
/**
* Validate that the source is valid
*
* @param Array|String $value The value to validate.
* @param Array|String $value The value to validate.
* @param \WP_REST_Request $request The request.
* @param Array $param The array of parameters.
* @param Array $param The array of parameters.
* @return Bool|WP_Error true or false
*/
public function validate_source( $value, \WP_REST_Request $request, $param ) {
Expand All @@ -373,9 +373,9 @@ public function validate_source( $value, \WP_REST_Request $request, $param ) {
/**
* Validate supplied filters
*
* @param string|array $value Value.
* @param string|array $value Value.
* @param \WP_REST_Request $request Request.
* @param array $param Params.
* @param array $param Params.
* @return boolean
*/
public function validate_filters( $value, \WP_REST_Request $request, $param ) {
Expand Down
8 changes: 4 additions & 4 deletions includes/api/route/route-preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ public function route_list( \WP_REST_Request $request ) {
/**
* Validate that the locked params are valid
*
* @param Array|String $value The value to validate.
* @param Array|String $value The value to validate.
* @param \WP_REST_Request $request The request.
* @param Array $param The array of parameters.
* @param Array $param The array of parameters.
* @return \WP_Error|Bool true or false
*/
public function validate_locked( $value, \WP_REST_Request $request, $param ) {
Expand All @@ -348,9 +348,9 @@ public function validate_locked( $value, \WP_REST_Request $request, $param ) {
/**
* Validate that the tag params are valid
*
* @param Array|String $value The value to validate.
* @param Array|String $value The value to validate.
* @param \WP_REST_Request $request The request.
* @param Array $param The array of parameters.
* @param Array $param The array of parameters.
* @return \WP_Error|Bool true or false
*/
public function validate_tags( $value, \WP_REST_Request $request, $param ) {
Expand Down
8 changes: 4 additions & 4 deletions includes/api/route/route-source.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ public function __construct( $namespace ) {
/**
* Sanitize the source so it's a single source in an array, suitable for use with the search functions
*
* @param string|array $value Source name.
* @param string|array $value Source name.
* @param \WP_REST_Request $request Request object.
* @param string $param Param name.
* @param string $param Param name.
* @return string[]
*/
public function sanitize_row_source( $value, \WP_REST_Request $request, $param ) {
Expand All @@ -184,9 +184,9 @@ public function sanitize_row_source( $value, \WP_REST_Request $request, $param )
/**
* Validate the replacement.
*
* @param string|array $value Source name.
* @param string|array $value Source name.
* @param \WP_REST_Request $request Request object.
* @param string $param Param name.
* @param string $param Param name.
* @return true|WP_Error
*/
public function validate_replacement( $value, \WP_REST_Request $request, $param ) {
Expand Down
4 changes: 3 additions & 1 deletion includes/filter/class-global-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function get_items( Source\Source $source ) {
$items[] = new Type\Filter_String( $filter, $column );
}

return array_merge( $items, $this->items );
return array_merge( $items, array_filter( $this->items, function( $item ) use ( $source ) {
return $item->get_schema()->get_type() === $source->get_type();
} ) );
}

public function has_column( $column, Schema\Column $schema ) {
Expand Down
10 changes: 5 additions & 5 deletions includes/filter/class-search-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function add_item( Type\Filter_Type $item ) {
/**
* Create a Filter object
*
* @param array $json JSON data.
* @param array $json JSON data.
* @param Schema\Schema $schema Schema for filter.
* @return list<Filter>
*/
Expand Down Expand Up @@ -177,9 +177,9 @@ public function get_columns() {
* Get array of Search\Column objects that match this filter.
*
* @param array<Search\Column> $existing Existing array.
* @param Source\Source $source Source.
* @param array $row Raw data from the row.
* @param Action\Action $action Action.
* @param Source\Source $source Source.
* @param array $row Raw data from the row.
* @param Action\Action $action Action.
* @return array<Search\Column>
*/
public function get_matching_filter( array $existing, Source\Source $source, array $row, Action\Action $action ) {
Expand Down Expand Up @@ -243,7 +243,7 @@ public function get_query( Source\Source $source ) {
* Get an array of filters as SQL. Each filter is ANDed with the next
*
* @param array<Filter> $filters Filters.
* @param Source\Source $source Source.
* @param Source\Source $source Source.
* @return Sql\Query
*/
public static function get_as_query( array $filters, Source\Source $source ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/filter/filter-keyvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function get_column_data( $column, $value, Source\Source $source, Action\
* Get contexts for a value
*
* @param Source\Source $source Source.
* @param Action $action Action.
* @param Action\Action $action Action.
* @param string $column Column.
* @param string $label Label.
* @return array
Expand All @@ -282,7 +282,7 @@ private function get_value_context( Source\Source $source, Action\Action $action
* Get context for a keyvalue match
*
* @param Source\Source $source Source.
* @param Action\Action $action Action.
* @param Action\Action $action Action.
* @param string $logic Logic.
* @param string $match_value Value.
* @param Search\Flags $flags Flags.
Expand Down
3 changes: 2 additions & 1 deletion includes/filter/filter-string.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ public function get_column_data( $column, $value, Source\Source $source, Action\
* Match this filter against a string
*
* @param Source\Source $source Source.
* @param Action $action Action.
* @param Action\Action $action Action.
* @param string $logic Logic.
* @param string $original_value Original value.
* @param string $row_value Current value.
* @param Search\Flags $flags Flags.
* @param array $replacements Replacement array.
* @return list<Context\Context>
*/
public function get_match( Source\Source $source, Action\Action $action, $logic, $original_value, $row_value, Search\Flags $flags, $replacements = [] ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/modifier/class-modifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function to_json() {
* @param integer $row_id Row ID.
* @param string $row_value Row value.
* @param Source\Source $source Source.
* @param Search\Column $column Column.
* @param Search\Column $column Column.
* @param array $raw Raw database data.
* @param boolean $save_mode Is the save mode enabled.
* @return Search\Column
Expand Down
4 changes: 1 addition & 3 deletions includes/modifier/modifier-member.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,13 @@ function( $context ) {
}

// Replace existing contexts with the new ones
/** @psalm-suppress all */
$contexts = array_merge(
$this->get_contexts( $source, $same, '\SearchRegex\Context\Type\Value' ),
$this->get_contexts( $source, $add, '\SearchRegex\Context\Type\Add' ),
$this->get_contexts( $source, $delete, '\SearchRegex\Context\Type\Delete' ),
$updated,
$updated
);

/** @psalm-suppress ArgumentTypeCoercion */
$column->set_contexts( $contexts );
return $column;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/search-regex-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct() {
register_uninstall_hook( SEARCHREGEX_FILE, [ '\SearchRegex\Admin\Admin', 'plugin_uninstall' ] );
}

/**
/*
* Massage the Search Regex WP translations.
*/
public function load_script_translation_file( $file, $handle, $domain ) {
Expand Down
3 changes: 0 additions & 3 deletions includes/search-regex-cli.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<?php

namespace SearchRegex\Cli;

if ( defined( 'WP_CLI' ) && WP_CLI ) {
}
6 changes: 3 additions & 3 deletions includes/search/class-match-column.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class Column {
/**
* Create a Match Column, which contains an array of Context\Type\Text items for a particular database column.
*
* @param string $column_id Column ID.
* @param string $column_label Descriptive column label, shown to the user.
* @param string $column_id Column ID.
* @param string $column_label Descriptive column label, shown to the user.
* @param array<Context\Context> $contexts Contexts.
* @param array $raw Raw data.
* @param array $raw Raw data.
*/
public function __construct( $column_id, $column_label, array $contexts, array $raw ) {
$this->match_count = 0;
Expand Down
2 changes: 1 addition & 1 deletion includes/search/class-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function get_search_data( $absolute_offset, $limit, Totals $totals ) {
* Convert database rows into Result objects
*
* @internal
* @param array $source_results Array of row data.
* @param array $source_results Array of row data.
* @param Action\Action $action Action\Action object.
* @return Result[]|\WP_Error Array of results
*/
Expand Down
2 changes: 2 additions & 0 deletions includes/source/plugin/source-redirection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SearchRegex\Source\Plugin;

// phpcs:disable

use SearchRegex\Source;
use SearchRegex\Search;
use SearchRegex\Sql;
Expand Down
2 changes: 1 addition & 1 deletion includes/sql/where/class-where.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Where {
/**
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param string|integer|array $value Value.
*/
Expand Down
4 changes: 2 additions & 2 deletions includes/sql/where/where-date.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Where_Date extends Where {
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param integer $value Value.
* @param string $logic Logic.
* @param integer $value Value.
*/
public function __construct( Sql\Select\Select $column, $logic, $value ) {
$map = [
Expand Down
4 changes: 2 additions & 2 deletions includes/sql/where/where-in.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Where_In extends Where {
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param array $value Value.
* @param string $logic Logic.
* @param array $value Value.
*/
public function __construct( Sql\Select\Select $column, $logic, $value ) {
$logic_sql = 'IN';
Expand Down
4 changes: 2 additions & 2 deletions includes/sql/where/where-integer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Where_Integer extends Where {
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param integer $value Value.
* @param string $logic Logic.
* @param integer $value Value.
*/
public function __construct( Sql\Select\Select $column, $logic, $value ) {
$map = [
Expand Down
2 changes: 1 addition & 1 deletion includes/sql/where/where-null.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Where_Null extends Where {
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param string $logic Logic.
*/
public function __construct( Sql\Select\Select $column, $logic ) {
$logic_sql = 'IS';
Expand Down
8 changes: 4 additions & 4 deletions includes/sql/where/where-string.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class Where_String extends Where {
/**
* Constructor
*
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param string $value Value.
* @param Search\Flags $flags Search flags.
* @param Sql\Select\Select $column Column.
* @param string $logic Logic.
* @param string $value Value.
* @param Search\Flags $flags Search flags.
*/
public function __construct( Sql\Select\Select $column, $logic, $value, Search\Flags $flags = null ) {
if ( $flags === null ) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "search-regex",
"version": "3.0.0",
"version": "3.0.1",
"description": "Adds search and replace functionality across posts, pages, comments, and meta-data, with full regular expression support",
"main": "search-regex.php",
"sideEffects": true,
Expand All @@ -9,7 +9,7 @@
"check-engines": "wp-scripts check-engines",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:php": "phpcs -s",
"lint:php": "composer run-script lint",
"lint:psalm": "./vendor/vimeo/psalm/psalm --show-info=true",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"packages-update": "wp-scripts packages-update",
Expand Down Expand Up @@ -60,7 +60,7 @@
"node-fetch": "2",
"path": "^0.12.7",
"prettier": "npm:[email protected]",
"release-it": "^15.1.3",
"release-it": "^15.2.0",
"request": "^2.88.2",
"through": "^2.3.8",
"through2": "^4.0.2",
Expand Down Expand Up @@ -92,7 +92,7 @@
"redux-thunk": "^2.4.1",
"typescript": "^4.7.4",
"url": "^0.11.0",
"use-debounce": "^8.0.2"
"use-debounce": "^8.0.3"
},
"apidoc": {
"name": "Search Regex REST API",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset name="WordPress Coding Standards for Gutenberg Plugin">
<description>Coding standard for Search Regex plugin. Based on WordPress coding standards, but without the annoying Yoda and alignment options</description>

<config name="testVersion" value="5.5-"/>
<config name="testVersion" value="5.6-"/>

<rule ref="WordPress-Core">
<!-- these I dont like -->
Expand Down
Loading

0 comments on commit 17c83f4

Please sign in to comment.