From 5ed161943cb7e6f17459ba3eb39f50a7ae810b43 Mon Sep 17 00:00:00 2001 From: JimDog546 <32178686+JimDog546@users.noreply.github.com> Date: Sun, 10 Jan 2021 03:14:58 -0500 Subject: [PATCH] [InstagramBridge] Remove redundant data collection for sidecar and video (#1920) getInstagramSidecarData and getInstagramVideoData were unnecessarily calling getSinglePostData to retrieve data already present in collectData's call of getInstagramJSON. getSinglePostData sometimes doesn't retrieve data properly resulting in incomplete post information. Since the information needed is already present, pass it from collectData instead, eliminating the redundant data collection and improving reliability. --- bridges/InstagramBridge.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 5e9783fd..bf2999b4 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -131,7 +131,7 @@ class InstagramBridge extends BridgeAbstract { switch($media->__typename) { case 'GraphSidecar': - $data = $this->getInstagramSidecarData($item['uri'], $item['title']); + $data = $this->getInstagramSidecarData($item['uri'], $item['title'], $media, $textContent); $item['content'] = $data[0]; $item['enclosures'] = $data[1]; break; @@ -142,7 +142,7 @@ class InstagramBridge extends BridgeAbstract { $item['enclosures'] = array($mediaURI); break; case 'GraphVideo': - $data = $this->getInstagramVideoData($item['uri'], $mediaURI); + $data = $this->getInstagramVideoData($item['uri'], $mediaURI, $media, $textContent); $item['content'] = $data[0]; if($directLink) { $item['enclosures'] = $data[1]; @@ -160,11 +160,7 @@ class InstagramBridge extends BridgeAbstract { } // returns Sidecar(a post which has multiple media)'s contents and enclosures - protected function getInstagramSidecarData($uri, $postTitle) { - $mediaInfo = $this->getSinglePostData($uri); - - $textContent = $this->getTextContent($mediaInfo); - + protected function getInstagramSidecarData($uri, $postTitle, $mediaInfo, $textContent) { $enclosures = array(); $content = ''; foreach($mediaInfo->edge_sidecar_to_children->edges as $singleMedia) { @@ -187,10 +183,7 @@ class InstagramBridge extends BridgeAbstract { } // returns Video post's contents and enclosures - protected function getInstagramVideoData($uri, $mediaURI) { - $mediaInfo = $this->getSinglePostData($uri); - - $textContent = $this->getTextContent($mediaInfo); + protected function getInstagramVideoData($uri, $mediaURI, $mediaInfo, $textContent) { $content = '