示例#1
0
 public function testDelete()
 {
     // empty table, expect false (i.e., not found)
     $this->assertFalse(Option::get('anonymous_defaultReport'));
     $this->assertFalse(Option::get('admin_defaultReport'));
     // populate table, expect '1'
     Option::set('anonymous_defaultReport', '1', true);
     Option::delete('_defaultReport');
     $this->assertSame('1', Option::get('anonymous_defaultReport'));
     // populate table, expect '2'
     Option::set('admin_defaultReport', '2', false);
     Option::delete('_defaultReport');
     $this->assertSame('2', Option::get('admin_defaultReport'));
     // delete with non-matching value, expect '1'
     Option::delete('anonymous_defaultReport', '2');
     $this->assertSame('1', Option::get('anonymous_defaultReport'));
     // delete with matching value, expect false
     Option::delete('anonymous_defaultReport', '1');
     $this->assertFalse(Option::get('anonymous_defaultReport'));
     // this shouldn't have been deleted, expect '2'
     $this->assertSame('2', Option::get('admin_defaultReport'));
     // deleted, expect false
     Option::delete('admin_defaultReport');
     $this->assertFalse(Option::get('admin_defaultReport'));
 }
示例#2
0
文件: 2.0-a13.php 项目: piwik/piwik
 public function doUpdate(Updater $updater)
 {
     // delete schema version_
     Option::delete('version_Referers');
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     // old plugins deleted in 2.0-a17 update file
 }
示例#3
0
 public function testWebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
         $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
         $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
         $this->markTestSkipped($message);
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertContains('Starting Piwik reports archiving...', $output);
     $this->assertContains('Archived website id = 1', $output);
     $this->assertContains('Done archiving!', $output);
     $this->compareArchivePhpOutputAgainstExpected($output);
 }
示例#4
0
 public function setSiteIdsToArchive($siteIds)
 {
     if (!empty($siteIds)) {
         Option::set($this->optionName, implode(',', $siteIds));
     } else {
         Option::delete($this->optionName);
     }
 }
示例#5
0
 public function setSiteIdsToArchive($siteIds)
 {
     if (!empty($siteIds)) {
         Option::set('SharedSiteIdsToArchive', implode(',', $siteIds));
     } else {
         Option::delete('SharedSiteIdsToArchive');
     }
 }
 /**
  * @test
  */
 public function should_load_spammer_list_from_options_if_exists()
 {
     // We store google.com in the spammer blacklist
     $list = serialize(array('google.com'));
     Option::set(ReferrerSpamFilter::OPTION_STORAGE_NAME, $list);
     $request = new Request(array('urlref' => 'semalt.com'));
     $this->assertFalse($this->filter->isSpam($request));
     // Now Google is blacklisted
     $request = new Request(array('urlref' => 'google.com'));
     $this->assertTrue($this->filter->isSpam($request));
     Option::delete(ReferrerSpamFilter::OPTION_STORAGE_NAME);
 }
示例#7
0
 public function setUp()
 {
     parent::setUp();
     Fixture::createWebsite('2014-02-04');
     $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironmentVariables();
     $testingEnvironment->testCaseClass = null;
     $testingEnvironment->addFailingScheduledTask = false;
     $testingEnvironment->addScheduledTask = false;
     $testingEnvironment->save();
     Option::delete(self::TASKS_STARTED_OPTION_NAME);
     Option::delete(self::TASKS_FINISHED_OPTION_NAME);
     Option::delete(Timetable::TIMETABLE_OPTION_STRING);
     SettingsPiwik::overwritePiwikUrl(self::$fixture->getRootUrl() . "tests/PHPUnit/proxy");
 }
示例#8
0
 public function doUpdate(Updater $updater)
 {
     // delete schema version_
     Option::delete('version_Referers');
     $updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
     // old plugins deleted in 2.0-a17 update file
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('Referrers');
     } catch (\Exception $e) {
     }
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('ScheduledReports');
     } catch (\Exception $e) {
     }
 }
示例#9
0
 public static function update()
 {
     // delete schema version_
     Option::delete('version_Referers');
     Updater::updateDatabase(__FILE__, self::getSql());
     // old plugins deleted in 2.0-a17 update file
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('Referrers');
     } catch (\Exception $e) {
     }
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('ScheduledReports');
     } catch (\Exception $e) {
     }
 }
示例#10
0
 public function test_WebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $this->fail("archive web failed: " . $output . "\n\nurl used: {$url}");
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertWebArchivingDone($output);
 }
示例#11
0
 /**
  * @internal
  */
 public function forgetRememberedArchivedReportsToInvalidate($idSite, Date $date)
 {
     $id = $this->buildRememberArchivedReportId($idSite, $date->toString());
     Option::delete($id);
 }
示例#12
0
 /**
  * Removes all settings for this plugin from the database. Useful when uninstalling
  * a plugin.
  */
 public function removeAllPluginSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     Option::delete($this->getOptionKey());
     $this->settingsValues = array();
 }
示例#13
0
 /**
  * Uninstalls a Plugin (deletes plugin files from the disk)
  * Only deactivated plugins can be uninstalled
  *
  * @param $pluginName
  * @throws \Exception
  * @return bool
  */
 public function uninstallPlugin($pluginName)
 {
     if ($this->isPluginLoaded($pluginName)) {
         throw new \Exception("To uninstall the plugin {$pluginName}, first disable it in Piwik > Settings > Plugins");
     }
     $this->returnLoadedPluginsInfo();
     \Piwik\Settings\Manager::cleanupPluginSettings($pluginName);
     $this->executePluginDeactivate($pluginName);
     $this->executePluginUninstall($pluginName);
     $this->removePluginFromPluginsInstalledConfig($pluginName);
     $this->unloadPluginFromMemory($pluginName);
     $this->removePluginFromConfig($pluginName);
     Option::delete('version_' . $pluginName);
     $this->clearCache($pluginName);
     self::deletePluginFromFilesystem($pluginName);
     if ($this->isPluginInFilesystem($pluginName)) {
         return false;
     }
     return true;
 }
示例#14
0
文件: Login.php 项目: a4tunado/piwik
 /**
  * Removes stored password reset info if it exists.
  *
  * @param string $login The user login to check for.
  */
 public static function removePasswordResetInfo($login)
 {
     $optionName = self::getPasswordResetInfoOptionName($login);
     Option::delete($optionName);
 }
示例#15
0
 /**
  * Marks a component as successfully uninstalled. Deletes an option
  * that looks like `"version_$componentName"`.
  *
  * @param string $name The component name. Eg, a plugin name, `'core'` or dimension column name.
  */
 public function markComponentSuccessfullyUninstalled($name)
 {
     try {
         Option::delete(self::getNameInOptionTable($name));
     } catch (\Exception $e) {
         // case when the option table is not yet created (before 0.2.10)
     }
 }
示例#16
0
 /**
  * Removes all settings for this plugin from the database. Useful when uninstalling
  * a plugin.
  */
 public function deleteAllValues()
 {
     Option::delete($this->getOptionKey());
     $this->settingsValues = array();
     $this->settingValuesLoaded = false;
 }
示例#17
0
 private function delete()
 {
     Option::delete('marketplace_license_key');
 }
示例#18
0
文件: Updater.php 项目: piwik/piwik
 /**
  * Marks a component as successfully uninstalled. Deletes an option
  * that looks like `"version_$componentName"`.
  *
  * @param string $name The component name. Eg, a plugin name, `'core'` or dimension column name.
  */
 public function markComponentSuccessfullyUninstalled($name)
 {
     try {
         Option::delete(self::getNameInOptionTable($name));
     } catch (\Exception $e) {
         // case when the option table is not yet created (before 0.2.10)
     }
     /**
      * Event triggered after a component has been uninstalled.
      *
      * @param string $name The component that has been uninstalled.
      */
     Piwik::postEvent('Updater.componentUninstalled', array($name));
 }
示例#19
0
 protected function deleteSettingsFromStorage()
 {
     Option::delete($this->getOptionKey());
 }
示例#20
0
 private function removeInstalledVersionFromOptionTable($version)
 {
     Option::delete('version_' . $version);
 }
示例#21
0
 /**
  * Uninstalls a Plugin (deletes plugin files from the disk)
  * Only deactivated plugins can be uninstalled
  *
  * @param $pluginName
  * @throws \Exception
  * @return bool
  */
 public function uninstallPlugin($pluginName)
 {
     if ($this->isPluginLoaded($pluginName)) {
         throw new \Exception("To uninstall the plugin {$pluginName}, first disable it in Piwik > Settings > Plugins");
     }
     $this->returnLoadedPluginsInfo();
     try {
         $plugin = $this->getLoadedPlugin($pluginName);
         $plugin->uninstall();
     } catch (\Exception $e) {
     }
     Option::delete('version_' . $pluginName);
     $this->removePluginFromPluginsConfig($pluginName);
     $this->removePluginFromPluginsInstalledConfig($pluginName);
     $this->removePluginFromTrackerConfig($pluginName);
     PiwikConfig::getInstance()->forceSave();
     \Piwik\Settings\Manager::cleanupPluginSettings($pluginName);
     $this->clearCache($pluginName);
     self::deletePluginFromFilesystem($pluginName);
     if ($this->isPluginInFilesystem($pluginName)) {
         return false;
     }
     return true;
 }