Skip to content

Commit

Permalink
fix domain age from archive.org (#13574)
Browse files Browse the repository at this point in the history
* fix domain age from archive.org

* fix test

* improve archive.org error handling
  • Loading branch information
Findus23 authored and sgiehl committed Nov 4, 2018
1 parent ef0a497 commit e589349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 5 additions & 9 deletions plugins/SEO/Metric/DomainAge.php
Expand Up @@ -74,16 +74,12 @@ public function getMetrics($domain)
*/
private function getAgeArchiveOrg($domain)
{
$data = $this->getUrl('https://wayback.archive.org/web/*/' . urlencode($domain));
preg_match('#<a href=\"([^>]*)' . preg_quote($domain) . '/\">([^<]*)<\/a>#', $data, $p);
if (!empty($p[2])) {
$value = strtotime($p[2]);
if ($value === false) {
return 0;
}
return $value;
$response = $this->getUrl('https://archive.org/wayback/available?timestamp=19900101&url=' . urlencode($domain));
$data = json_decode($response, true);
if (empty($data["archived_snapshots"]["closest"]["timestamp"])) {
return 0;
}
return 0;
return strtotime($data["archived_snapshots"]["closest"]["timestamp"]);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions plugins/SEO/tests/Integration/SEOTest.php
Expand Up @@ -55,11 +55,10 @@ public function test_API()
$renderer->setSerialize(false);
$ranks = $renderer->render($dataTable);
foreach ($ranks as $rank) {
$message = $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']';
if(empty($rank['rank'])) {
$this->markTestSkipped("Skipped to avoid random build failure: " . $message);
if ($rank["id"] == "alexa") { // alexa is broken at the moment
continue;
}
$this->assertNotEmpty($rank['rank'], $message);
$this->assertNotEmpty($rank['rank'], $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']');
}
}

Expand Down

0 comments on commit e589349

Please sign in to comment.