Skip to content

Commit

Permalink
Minor fixes for 5.4.1 (#3771)
Browse files Browse the repository at this point in the history
* Linting

* Bundle
  • Loading branch information
johngodley authored Jan 5, 2024
1 parent 2dca15c commit a0780ec
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 18 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"wp-cli/wp-cli-bundle": "*",
"humanmade/psalm-plugin-wordpress": "^1.0",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/extension-installer": "^1.3"
},
"scripts": {
"pot": "wp i18n make-pot . locale/redirection.pot --ignore-domain --exclude=redirection-strings.php",
Expand All @@ -15,7 +17,8 @@
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
}
}
155 changes: 154 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion models/log/log-redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function get_redirect_name( $agent ) {
/**
* Convert a log entry to JSON
*
* @return Array
* @return array
*/
public function to_json() {
return array_merge( parent::to_json(), [
Expand Down
13 changes: 9 additions & 4 deletions models/log/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function delete_all( array $params = [] ) {
/**
* Convert a log entry to JSON
*
* @return Array
* @return array
*/
public function to_json() {
return [
Expand All @@ -195,7 +195,7 @@ public function to_json() {
* Get filtered log entries
*
* @param array $params Filters.
* @return Array{items: Array, total: integer}
* @return array{items: Array, total: integer}
*/
public static function get_filtered( array $params ) {
global $wpdb;
Expand Down Expand Up @@ -234,7 +234,7 @@ public static function get_filtered( array $params ) {
*
* @param string $group Group type.
* @param array $params Filter params.
* @return Array{items: mixed, total: integer}
* @return array{items: mixed, total: integer}
*/
public static function get_grouped( $group, array $params ) {
global $wpdb;
Expand Down Expand Up @@ -280,7 +280,7 @@ public static function get_grouped( $group, array $params ) {
* Convert a set of filters to a SQL query.
*
* @param array $params Filters.
* @return Array{orderby: string, direction: string, limit: integer, offset: integer, where: string}
* @return array{orderby: string, direction: string, limit: integer, offset: integer, where: string}
*/
public static function get_query( array $params ) {
$query = [
Expand Down Expand Up @@ -390,6 +390,7 @@ protected static function get_query_filter( array $filter ) {
* @return array
*/
protected static function sanitize_create( $domain, $url, $ip, array $details = [] ) {
$url = urldecode( $url );
$insert = [
'url' => substr( sanitize_text_field( $url ), 0, self::MAX_URL_LENGTH ),
'domain' => substr( sanitize_text_field( $domain ), 0, self::MAX_DOMAIN_LENGTH ),
Expand Down Expand Up @@ -482,6 +483,10 @@ public static function export_to_csv() {

// phpcs:ignore
$stdout = fopen( 'php://output', 'w' );
if ( ! $stdout ) {
return;
}

fputcsv( $stdout, static::get_csv_header() );

global $wpdb;
Expand Down
1 change: 0 additions & 1 deletion models/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public static function get_ip() {
foreach ( $options['ip_headers'] as $header ) {
if ( isset( $_SERVER[ $header ] ) ) {
$ip = new Redirection_IP( $_SERVER[ $header ] );
error_log( $header . ' = ' . $ip->get() );
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/url/url-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function get_url_with_query( $url ) {
/**
* Get the query parameters
*
* @return Array
* @return array
*/
public function get() {
return $this->original_query;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redirection",
"version": "5.4",
"version": "5.4.1",
"description": "Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.",
"main": "redirection.php",
"browser": {
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ parameters:
- matches
- models
- modules
- redirection-settings.php
- redirection-admin.php
- redirection-cli.php
- redirection-capabilities.php
- redirection-front.php
phpVersion: 80127
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://redirection.me/donation/
Tags: redirect, htaccess, 301, 404, seo, permalink, apache, nginx, post, admin
Requires at least: 5.9
Tested up to: 6.4.2
Stable tag: 5.4
Stable tag: 5.4.1
Requires PHP: 5.6
License: GPLv3

Expand Down Expand Up @@ -184,6 +184,9 @@ The plugin works in a similar manner to how WordPress handles permalinks and sho

A x.1 version increase introduces new or updated features and can be considered to contain 'breaking' changes. A x.x.1 increase is purely a bug fix and introduces no new features, and can be considered as containing no breaking changes.

= 5.4.1 - 5th January 2024 =
* Fix problem with some international URLs not appearing in the 404 log

= 5.4 - 1st January 2024 =
* Don't encode negative lookaheads
* Remove port from server name
Expand Down
4 changes: 2 additions & 2 deletions redirection-version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

define( 'REDIRECTION_VERSION', '5.4' );
define( 'REDIRECTION_BUILD', 'b606c89b7105268adfc5842c492f91a0' );
define( 'REDIRECTION_VERSION', '5.4.1' );
define( 'REDIRECTION_BUILD', '4921947a93e8d2bdecfa002a29093c22' );
define( 'REDIRECTION_MIN_WP', '5.7' );
4 changes: 2 additions & 2 deletions redirection.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion redirection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Redirection
Plugin URI: https://redirection.me/
Description: Manage all your 301 redirects and monitor 404 errors
Version: 5.4
Version: 5.4.1
Author: John Godley
Text Domain: redirection
Domain Path: /locale
Expand Down
1 change: 0 additions & 1 deletion tests/api/test-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public function testExportApache() {
$result = $this->callApi( 'export/1/apache' );

$this->assertEquals( 1, $result->data['total'] );
print_r($result);
$this->assertTrue( strpos( $result->data['data'], 'RewriteRule (?i)^/1$' ) !== false );
}
}

0 comments on commit a0780ec

Please sign in to comment.