From 55f04622a41cfe9354fb393f5bbb4120b4649389 Mon Sep 17 00:00:00 2001 From: Alexander Schneider Date: Sun, 21 Feb 2021 21:07:46 +0100 Subject: [PATCH] Bump version 2.2.8 --- composer.json | 2 +- package.json | 2 +- readme.txt | 6 +++++- src/Cache/FileSystemCacheProvider.php | 2 -- src/Controller/BaseControllerTrait.php | 2 +- src/Controller/Frontend/ShortCodeController.php | 4 ++-- src/Controller/Frontend/TermController.php | 1 - src/User/UserHandler.php | 2 +- src/UserAccessManager.php | 2 +- src/UserGroup/UserGroupHandler.php | 7 +------ src/Wrapper/Php.php | 2 -- tests/Unit/UserGroup/UserGroupHandlerTest.php | 1 - user-access-manager.php | 2 +- 13 files changed, 14 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 777acdad..a020ff80 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "User Access Manager plugin for Wordpress", "type": "wordpress-plugin", "license": "GPL-2.0", - "version": "2.2.7", + "version": "2.2.8", "authors": [ { "name": "Alexander Schneider", diff --git a/package.json b/package.json index 42d5f638..97e0fdce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "user-access-manager", - "version": "2.2.7", + "version": "2.2.8", "description": "[![Build Status](https://travis-ci.org/GM-Alex/user-access-manager.svg)](https://travis-ci.org/GM-Alex/user-access-manager)", "main": "index.js", "directories": { diff --git a/readme.txt b/readme.txt index c98392dc..9522d13e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: admin, access, member area, members, member, member access, page, pages, post, posts, private, privacy, restrict, user, user access manager, user management Requires at least: 4.7 Tested up to: 5.6 -Stable tag: 2.2.7 +Stable tag: 2.2.8 With the "User Access Manager"-plugin you can manage the access to your posts, pages and files. @@ -59,6 +59,10 @@ Here you found the changes in each version. Version Date Changes + 2.2.8 2021/02/21 Some cleanup. + Type fixes for the short controller. + Fix some possible php notices and warnings. + 2.2.7 2021/02/14 Fix issue with isAdmin. 2.2.6 2021/02/14 Fix more possible type errors. diff --git a/src/Cache/FileSystemCacheProvider.php b/src/Cache/FileSystemCacheProvider.php index bb56f16c..34743393 100644 --- a/src/Cache/FileSystemCacheProvider.php +++ b/src/Cache/FileSystemCacheProvider.php @@ -229,7 +229,6 @@ public function add(string $key, $value) if ($method === self::METHOD_SERIALIZE) { $this->php->filePutContents($cacheFile, base64_encode(serialize($value)), LOCK_EX); } elseif ($method === self::METHOD_IGBINARY) { - /** @noinspection PhpUndefinedFunctionInspection */ $this->php->filePutContents($cacheFile, $this->php->igbinarySerialize($value), LOCK_EX); } elseif ($method === self::METHOD_JSON) { $this->php->filePutContents($cacheFile, json_encode($value), LOCK_EX); @@ -257,7 +256,6 @@ public function get(string $key) if ($method === self::METHOD_SERIALIZE) { return unserialize(base64_decode(file_get_contents($cacheFile))); } elseif ($method === self::METHOD_IGBINARY) { - /** @noinspection PhpUndefinedFunctionInspection */ return $this->php->igbinaryUnserialize(file_get_contents($cacheFile)); } elseif ($method === self::METHOD_JSON) { return json_decode(file_get_contents($cacheFile), true); diff --git a/src/Controller/BaseControllerTrait.php b/src/Controller/BaseControllerTrait.php index 8f273759..a9e8b420 100644 --- a/src/Controller/BaseControllerTrait.php +++ b/src/Controller/BaseControllerTrait.php @@ -71,7 +71,7 @@ private function sanitizeValue($value) $value = $newValue; } elseif (is_string($value) === true) { - $value = preg_replace('/[\\\\]+(["|\']{1})/', '$1', $value); + $value = preg_replace('/[\\\\]+(["|\'])/', '$1', $value); $value = stripslashes($value); $value = htmlspecialchars($value); } diff --git a/src/Controller/Frontend/ShortCodeController.php b/src/Controller/Frontend/ShortCodeController.php index f13783b6..5b75bfc8 100644 --- a/src/Controller/Frontend/ShortCodeController.php +++ b/src/Controller/Frontend/ShortCodeController.php @@ -89,11 +89,11 @@ public function loginFormShortCode(): string /** * Handles the public short code. - * @param array $attributes + * @param string|array $attributes * @param string $content * @return string */ - public function publicShortCode(array $attributes, $content = ''): string + public function publicShortCode($attributes, $content = ''): string { return ($this->wordpress->isUserLoggedIn() === false) ? $this->wordpress->doShortCode($content) : ''; } diff --git a/src/Controller/Frontend/TermController.php b/src/Controller/Frontend/TermController.php index a063d116..a45b54ef 100644 --- a/src/Controller/Frontend/TermController.php +++ b/src/Controller/Frontend/TermController.php @@ -30,7 +30,6 @@ use UserAccessManager\Util\Util; use UserAccessManager\Wrapper\Php; use UserAccessManager\Wrapper\Wordpress; -use WP_Post; use WP_Term; /** diff --git a/src/User/UserHandler.php b/src/User/UserHandler.php index 96e01677..b365bec2 100644 --- a/src/User/UserHandler.php +++ b/src/User/UserHandler.php @@ -80,7 +80,7 @@ public function __construct( private function calculateIp(string $ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { - return base_convert(ip2long($ip), 10, 2); + return base_convert((string) ip2long($ip), 10, 2); } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { return false; } diff --git a/src/UserAccessManager.php b/src/UserAccessManager.php index dbf08dac..5541d7d4 100644 --- a/src/UserAccessManager.php +++ b/src/UserAccessManager.php @@ -50,7 +50,7 @@ */ class UserAccessManager { - const VERSION = '2.2.7'; + const VERSION = '2.2.8'; const DB_VERSION = '1.6.1'; /** diff --git a/src/UserGroup/UserGroupHandler.php b/src/UserGroup/UserGroupHandler.php index d1a37833..d639b139 100644 --- a/src/UserGroup/UserGroupHandler.php +++ b/src/UserGroup/UserGroupHandler.php @@ -72,11 +72,6 @@ class UserGroupHandler */ private $dynamicUserGroups = null; - /** - * @var null|UserGroup[] - */ - private $filteredUserGroups = null; - /** * @var null|AbstractUserGroup[] */ @@ -266,7 +261,7 @@ public function unsetUserGroupsForObject() */ private function checkUserGroupAccess(UserGroup $userGroup): bool { - $userIp = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $_SERVER['REMOTE_ADDR']; + $userIp = $_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? ''; return $this->userHandler->isIpInRange($userIp, $userGroup->getIpRangeArray()) || $this->wordpressConfig->atAdminPanel() === false && $userGroup->getReadAccess() === 'all' diff --git a/src/Wrapper/Php.php b/src/Wrapper/Php.php index 71c968a7..bde26174 100644 --- a/src/Wrapper/Php.php +++ b/src/Wrapper/Php.php @@ -144,7 +144,6 @@ public function filePutContents(string $filename, $data, $flags = 0, $context = */ public function igbinarySerialize($value): string { - /** @noinspection PhpUndefinedFunctionInspection */ return igbinary_serialize($value); } @@ -155,7 +154,6 @@ public function igbinarySerialize($value): string */ public function igbinaryUnserialize(string $key) { - /** @noinspection PhpUndefinedFunctionInspection */ return igbinary_unserialize($key); } diff --git a/tests/Unit/UserGroup/UserGroupHandlerTest.php b/tests/Unit/UserGroup/UserGroupHandlerTest.php index 143595f5..4871eca7 100644 --- a/tests/Unit/UserGroup/UserGroupHandlerTest.php +++ b/tests/Unit/UserGroup/UserGroupHandlerTest.php @@ -370,7 +370,6 @@ public function testDeleteUserGroups(UserGroupHandler $userGroupHandler) 4 => $this->getUserGroup(4) ]; - self::setValue($userGroupHandler, 'filteredUserGroups', []); self::assertFalse($userGroupHandler->deleteUserGroup(10)); self::assertFalse($userGroupHandler->deleteUserGroup(3)); diff --git a/user-access-manager.php b/user-access-manager.php index 137c2232..c37dcf0d 100644 --- a/user-access-manager.php +++ b/user-access-manager.php @@ -3,7 +3,7 @@ * Plugin Name: User Access Manager * Plugin URI: https://wordpress.org/plugins/user-access-manager/ * Author URI: https://twitter.com/GM_Alex - * Version: 2.2.7 + * Version: 2.2.8 * Author: Alexander Schneider * Description: Manage the access to your posts, pages, categories and files. * Text Domain: user-access-manager