From d39741c29677e50acf618db1f43562cd8863f939 Mon Sep 17 00:00:00 2001 From: somini Date: Wed, 26 Feb 2020 21:15:50 +0000 Subject: [PATCH] [GithubIssueBridgeIssue] Fix bridge (#1453) * fix bridge according to website evolution --- bridges/GithubIssueBridge.php | 51 +++++++++++++++-------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 2eddeb2e..29a336bd 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -82,18 +82,21 @@ class GithubIssueBridge extends BridgeAbstract { $uri = $this->buildGitHubIssueCommentUri($issueNbr, $comment->id); - $author = $comment->find('.author', 0)->plaintext; - - $title .= ' / ' . trim($comment->plaintext); - - $content = $title; - if (null !== $comment->nextSibling()) { - $content = $comment->nextSibling()->innertext; - if ($comment->nextSibling()->nodeName() === 'span') { - $content = $comment->nextSibling()->nextSibling()->innertext; - } + $author = $comment->find('.author', 0); + if ($author) { + $author = $author->plaintext; + } else { + $author = ''; } + $title .= ' / ' + . trim(str_replace( + array('octicon','-'), array(''), + $comment->find('.octicon', 0)->getAttribute('class') + )); + + $content = $comment->plaintext; + $item = array(); $item['author'] = $author; $item['uri'] = $uri; @@ -135,32 +138,20 @@ class GithubIssueBridge extends BridgeAbstract { substr($issue->find('.gh-header-number', 0)->plaintext, 1) ); - $comments = $issue->find(' - [id^="issue-"] > .comment, - [id^="issuecomment-"] > .comment, - [id^="event-"], - [id^="ref-"] - '); + $comments = $issue->find( + '.comment, .TimelineItem-badge' + ); + foreach($comments as $comment) { - - if (!$comment->hasChildNodes()) { - continue; - } - - if (!$comment->hasClass('discussion-item-header')) { + if ($comment->hasClass('comment')) { + $comment = $comment->parent; $item = $this->extractIssueComment($issueNbr, $title, $comment); $items[] = $item; continue; - } - - while ($comment->hasClass('discussion-item-header')) { + } else { + $comment = $comment->parent; $item = $this->extractIssueEvent($issueNbr, $title, $comment); $items[] = $item; - $comment = $comment->nextSibling(); - if (null == $comment) { - break; - } - $classes = explode(' ', $comment->getAttribute('class')); } }