From 1e7ad6ed51d1f8e567b254706c7239930fd6de31 Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Fri, 24 Jun 2022 05:31:24 -0400 Subject: [PATCH] [PixivBridge] Remove backwards compatability hack (#2846) There is no need for this since the context is guessed if it's not provided. --- bridges/PixivBridge.php | 17 ++++++----------- tests/Bridges/BridgeImplementationTest.php | 6 +----- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/bridges/PixivBridge.php b/bridges/PixivBridge.php index 8b4ed13a..6a3fd573 100644 --- a/bridges/PixivBridge.php +++ b/bridges/PixivBridge.php @@ -28,8 +28,7 @@ class PixivBridge extends BridgeAbstract { 'Novels' => 'novels/') ), ), - // Backwards compatibility: Original bridge only had tags - '' => array( + 'Tag' => array( 'tag' => array( 'name' => 'Query to search', 'exampleValue' => 'オリジナル', @@ -47,7 +46,7 @@ class PixivBridge extends BridgeAbstract { // maps from URLs to json keys by context const JSON_KEY_MAP = array( - '' => array( + 'Tag' => array( 'illustrations/' => 'illust', 'manga/' => 'manga', 'novels/' => 'novel' @@ -64,8 +63,7 @@ class PixivBridge extends BridgeAbstract { public function getName() { switch($this->queriedContext) { - // Tags context - case '': + case 'Tag': $context = 'Tag'; $query = $this->getInput('tag'); break; @@ -83,8 +81,7 @@ class PixivBridge extends BridgeAbstract { public function getURI() { switch($this->queriedContext) { - // Tags context - case '': + case 'Tag': $uri = static::URI . 'tags/' . urlencode($this->getInput('tag') ?? ''); break; case 'User': @@ -101,8 +98,7 @@ class PixivBridge extends BridgeAbstract { private function getSearchURI($mode) { switch($this->queriedContext) { - // Tags context - case '': + case 'Tag': $query = urlencode($this->getInput('tag')); $uri = static::URI . 'ajax/search/top/' . $query; break; @@ -119,7 +115,7 @@ class PixivBridge extends BridgeAbstract { private function getDataFromJSON($json, $json_key) { $json = $json['body'][$json_key]; // Tags context contains subkey - if ($this->queriedContext == '') { + if ($this->queriedContext == 'Tag') { $json = $json['data']; } return $json; @@ -143,7 +139,6 @@ class PixivBridge extends BridgeAbstract { } public function collectData() { - $content = $this->collectWorksArray(); $content = array_filter($content, function($v, $k) { diff --git a/tests/Bridges/BridgeImplementationTest.php b/tests/Bridges/BridgeImplementationTest.php index 14fd3b33..e0e095a6 100644 --- a/tests/Bridges/BridgeImplementationTest.php +++ b/tests/Bridges/BridgeImplementationTest.php @@ -5,7 +5,6 @@ namespace RssBridge\Tests\Bridges; use BridgeAbstract; use BridgeInterface; use FeedExpander; -use PixivBridge; use PHPUnit\Framework\TestCase; class BridgeImplementationTest extends TestCase { @@ -74,10 +73,7 @@ class BridgeImplementationTest extends TestCase { if ($multiContexts) { $this->assertIsString($context, 'invalid context name'); - // Pixiv has a context that is the empty string, for BC. - if (! ($this->obj instanceof PixivBridge)) { - $this->assertNotEmpty($context, 'The context name cannot be empty'); - } + $this->assertNotEmpty($context, 'The context name cannot be empty'); } if (empty($params)) {