diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 0c3c0471..345d1148 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -200,11 +200,14 @@ class GithubIssueBridge extends BridgeAbstract $this->items = $this->extractIssueComments($html); break; case static::BRIDGE_OPTIONS[0]: // Project Issues + // PRs $issues = $html->find('.js-active-navigation-container .js-navigation-item'); - $issues = $html->find('.IssueRow-module__row--XmR1f'); - foreach ($issues as $issue) { - $info = $issue->find('.issue-item-module__authorCreatedLink--wFZvk', 0); + if (!$issues) { + // Issues + $issues = $html->find('.IssueRow-module__row--XmR1f'); + } + foreach ($issues as $issue) { preg_match('/\/([0-9]+)$/', $issue->find('a', 0)->href, $match); $issueNbr = $match[1]; @@ -214,6 +217,7 @@ class GithubIssueBridge extends BridgeAbstract if ($this->getInput('c')) { $uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/' . static::URL_PATH . '/' . $issueNbr; + $issue = getSimpleHTMLDOMCached($uri, static::CACHE_TIMEOUT); if ($issue) { $this->items = array_merge( @@ -226,15 +230,25 @@ class GithubIssueBridge extends BridgeAbstract } $item['author'] = $issue->find('a', 1)->plaintext; - $item['timestamp'] = strtotime( - $issue->find('relative-time', 0)->getAttribute('datetime') - ); - $item['title'] = html_entity_decode( - $issue->find('h3', 0)->plaintext, - ENT_QUOTES, - 'UTF-8' - ); + $time = $issue->find('relative-time', 0); + $datetime = $time->getAttribute('datetime'); + if ($datetime) { + $item['timestamp'] = strtotime($datetime); + } + + $item['title'] = ''; + + # Works for PRs + $title = $issue->find('a.Link--primary', 0); + if ($title) { + $item['title'] = html_entity_decode($title->plaintext, ENT_QUOTES, 'UTF-8'); + } + + $title2 = $issue->find('h3 a', 0); + if ($title2) { + $item['title'] = html_entity_decode($title2->plaintext, ENT_QUOTES, 'UTF-8'); + } //$comment_count = 0; //if ($span = $issue->find('a[aria-label*="comment"] span', 0)) { // $comment_count = $span->plaintext;