diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-08-23 04:17:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-23 04:17:56 +0300 |
commit | aaed436a073bcb2f86019bbef222e5a1a994e635 (patch) | |
tree | 4d4b95ec02772383f644455f6c1713065f4d3ad7 | |
parent | 58d7fb3f8065eaee299396fc2347ecdb8f9bdc77 (diff) |
Fix fatal error when requesting RSS format (#10407)
* Fixes #10399
* add test reproducing issue #10399
* another health check
-rw-r--r-- | core/DataTable/Renderer/Rss.php | 8 | ||||
-rw-r--r-- | plugins/MultiSites/tests/Integration/MultiSitesTest.php | 25 |
2 files changed, 31 insertions, 2 deletions
diff --git a/core/DataTable/Renderer/Rss.php b/core/DataTable/Renderer/Rss.php index fd18b44371..3d821150fc 100644 --- a/core/DataTable/Renderer/Rss.php +++ b/core/DataTable/Renderer/Rss.php @@ -64,9 +64,13 @@ class Rss extends Renderer $pudDate = date('r', $timestamp); - $dateInSiteTimezone = Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d'); + $dateInSiteTimezone = Date::factory($timestamp); + if($site) { + $dateInSiteTimezone = $dateInSiteTimezone->setTimezone($site->getTimezone()); + } + $dateInSiteTimezone = $dateInSiteTimezone->toString('Y-m-d'); $thisPiwikUrl = Common::sanitizeInputValue($piwikUrl . "&date=$dateInSiteTimezone"); - $siteName = $site->getName(); + $siteName = $site ? $site->getName() : ''; $title = $siteName . " on " . $date; $out .= "\t<item> diff --git a/plugins/MultiSites/tests/Integration/MultiSitesTest.php b/plugins/MultiSites/tests/Integration/MultiSitesTest.php index 8b6d7924a7..b027bef0b7 100644 --- a/plugins/MultiSites/tests/Integration/MultiSitesTest.php +++ b/plugins/MultiSites/tests/Integration/MultiSitesTest.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\MultiSites\tests\Integration; use Piwik\Access; +use Piwik\FrontController; use Piwik\Plugins\MultiSites\API as APIMultiSites; use Piwik\Plugins\SitesManager\API as APISitesManager; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; @@ -49,4 +50,28 @@ class MultiSitesTest extends IntegrationTestCase // safety net $this->assertEquals(0, $dataTable->getFirstRow()->getColumn('nb_visits')); } + + /** + * Testing that getOne does not error out when format=rss, #10407 + * + * @group Plugins + */ + public function testWhenRssFormatGetOneDoesNotError() + { + $_GET = array( + 'method' => 'MultiSites.getOne', + 'idSite' => $this->idSiteAccess, + 'period' => 'month', + 'date' => 'last10', + 'format' => 'rss' + ); + + $output = FrontController::getInstance()->fetchDispatch('API'); + + $this->assertContains('<item>', $output); + $this->assertContains('</rss>', $output); + $this->assertNotContains('error', $output); + + $_GET = array(); + } } |