From 5edaa4cc9858004ee32a1986e3099505b836c985 Mon Sep 17 00:00:00 2001 From: Alexander Schneider Date: Tue, 15 Feb 2022 11:06:26 +0100 Subject: [PATCH] Bump version 2.2.17 --- composer.json | 2 +- package.json | 2 +- readme.txt | 4 +++- src/Controller/Frontend/RedirectController.php | 9 ++++++++- src/UserAccessManager.php | 2 +- .../Controller/Frontend/RedirectControllerTest.php | 11 ++++++----- user-access-manager.php | 2 +- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index f09c2947..b606fb06 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.16", + "version": "2.2.17", "authors": [ { "name": "Alexander Schneider", diff --git a/package.json b/package.json index cb39a14f..7eed841c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "user-access-manager", - "version": "2.2.16", + "version": "2.2.17", "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 219c827c..5abab326 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.9 -Stable tag: 2.2.16 +Stable tag: 2.2.17 With the "User Access Manager"-plugin you can manage the access to your posts, pages and files. @@ -59,6 +59,8 @@ Here you found the changes in each version. Version Date Changes + 2.2.17 2022/02/15 Fix issue with big picture handling. #350 + 2.2.16 2022/01/25 Check compatibility for Wordpress 5.9. 2.2.15 2021/06/07 Fix possible type issues. diff --git a/src/Controller/Frontend/RedirectController.php b/src/Controller/Frontend/RedirectController.php index 50d70275..40f4c1f6 100644 --- a/src/Controller/Frontend/RedirectController.php +++ b/src/Controller/Frontend/RedirectController.php @@ -147,7 +147,14 @@ public function getPostIdByUrl(string $url): int $newUrl = (count($newUrlPieces) === 2) ? $newUrlPieces[0] . $newUrlPieces[1] : $newUrlPieces[0]; $newUrl = preg_replace('/-pdf\.jpg$/', '.pdf', $newUrl); - $postUrls[$url] = $this->wordpress->attachmentUrlToPostId($newUrl); + $postId = $this->wordpress->attachmentUrlToPostId($newUrl); + + if ($postId === 0) { + $newUrl = preg_replace('/(\\.[^.\\s]{3,4})$/', '-scaled$1', $newUrl); + $postId = $this->wordpress->attachmentUrlToPostId($newUrl); + } + + $postUrls[$url] = $postId; $this->cache->addToRuntimeCache(self::POST_URL_CACHE_KEY, $postUrls); return $postUrls[$url]; diff --git a/src/UserAccessManager.php b/src/UserAccessManager.php index 115a1a72..612bb517 100644 --- a/src/UserAccessManager.php +++ b/src/UserAccessManager.php @@ -50,7 +50,7 @@ */ class UserAccessManager { - const VERSION = '2.2.16'; + const VERSION = '2.2.17'; const DB_VERSION = '1.6.1'; /** diff --git a/tests/Unit/Controller/Frontend/RedirectControllerTest.php b/tests/Unit/Controller/Frontend/RedirectControllerTest.php index 72f16595..dcab0a64 100644 --- a/tests/Unit/Controller/Frontend/RedirectControllerTest.php +++ b/tests/Unit/Controller/Frontend/RedirectControllerTest.php @@ -146,17 +146,18 @@ public function testGetPostIdByUrl() { $wordpress = $this->getWordpress(); - $wordpress->expects($this->exactly(6)) + $wordpress->expects($this->exactly(7)) ->method('attachmentUrlToPostId') ->withConsecutive( - ['url/part'], + ['url/part.ext'], + ['url/part-scaled.ext'], ['url/part'], ['url-e123/part'], ['url/part'], ['url-e123/part'], ['url/part.pdf'] ) - ->will($this->onConsecutiveCalls(0, 1, 2, 3, 4, 5, 1)); + ->will($this->onConsecutiveCalls(0, 0, 1, 2, 3, 4, 5, 1)); $cache = $this->getCache(); @@ -176,7 +177,7 @@ public function testGetPostIdByUrl() $cache->expects($this->exactly(6)) ->method('addToRuntimeCache') ->withConsecutive( - [RedirectController::POST_URL_CACHE_KEY, ['url/part' => 0]], + [RedirectController::POST_URL_CACHE_KEY, ['url/part.ext' => 0]], [RedirectController::POST_URL_CACHE_KEY, ['url/part' => 1]], [RedirectController::POST_URL_CACHE_KEY, ['url-e123/part' => 2]], [RedirectController::POST_URL_CACHE_KEY, ['url-123x321_z/part' => 3]], @@ -198,7 +199,7 @@ public function testGetPostIdByUrl() $this->getFileObjectFactory() ); - self::assertEquals(0, $frontendRedirectController->getPostIdByUrl('url/part')); + self::assertEquals(0, $frontendRedirectController->getPostIdByUrl('url/part.ext')); self::assertEquals(1, $frontendRedirectController->getPostIdByUrl('url/part')); self::assertEquals(2, $frontendRedirectController->getPostIdByUrl('url-e123/part')); self::assertEquals(3, $frontendRedirectController->getPostIdByUrl('url-123x321_z/part')); diff --git a/user-access-manager.php b/user-access-manager.php index ea80d864..616cd6b9 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.16 + * Version: 2.2.17 * Requires PHP: 7.2 * Author: Alexander Schneider * Description: Manage the access to your posts, pages, categories and files.