Exemplo n.º 1
0
 public static function clearUserViewDataTableParameters($userLogin)
 {
     Option::deleteLike('viewDataTableParameters_' . $userLogin . '_%');
 }
Exemplo n.º 2
0
 /**
  * Delete user preferences associated with a particular site
  */
 public function deleteSite($idSite)
 {
     Option::deleteLike('%\\_' . API::PREFERENCE_DEFAULT_REPORT, $idSite);
 }
Exemplo n.º 3
0
 public function forgetRememberedArchivedReportsToInvalidateForSite($idSite)
 {
     $id = $this->buildRememberArchivedReportIdForSite($idSite) . '_%';
     Option::deleteLike($id);
 }
Exemplo n.º 4
0
 public static function updateDatabase($force = false)
 {
     Cache::deleteTrackerCache();
     Option::clearCache();
     if ($force) {
         // remove version options to force update
         Option::deleteLike('version%');
         Option::set('version_core', '0.0');
     }
     $updater = new Updater();
     $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
     if (empty($componentsWithUpdateFile)) {
         return false;
     }
     $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile);
     if (!empty($result['coreError']) || !empty($result['warnings']) || !empty($result['errors'])) {
         throw new \Exception("Failed to update database (errors or warnings found): " . print_r($result, true));
     }
     return $result;
 }
Exemplo n.º 5
0
 /**
  * @group Core
  */
 public function testDeleteLike()
 {
     // empty table, expect false (i.e., not found)
     $this->assertFalse(Option::get('anonymous_defaultReport'));
     $this->assertFalse(Option::get('admin_defaultReport'));
     $this->assertFalse(Option::get('visitor_defaultReport'));
     // insert guard - to test unescaped underscore
     Option::set('adefaultReport', '0', true);
     $this->assertTrue(Option::get('adefaultReport') === '0');
     // populate table, expect '1'
     Option::set('anonymous_defaultReport', '1', true);
     Option::deleteLike('\\_defaultReport');
     $this->assertSame('1', Option::get('anonymous_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // populate table, expect '2'
     Option::set('admin_defaultReport', '2', false);
     Option::deleteLike('\\_defaultReport');
     $this->assertSame('2', Option::get('admin_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // populate table, expect '3'
     Option::set('visitor_defaultReport', '3', false);
     Option::deleteLike('\\_defaultReport');
     $this->assertSame('3', Option::get('visitor_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // delete with non-matching value, expect '1'
     Option::deleteLike('%\\_defaultReport', '4');
     $this->assertSame('1', Option::get('anonymous_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // delete with matching pattern, expect false
     Option::deleteLike('%\\_defaultReport', '1');
     $this->assertFalse(Option::get('anonymous_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // this shouldn't have been deleted, expect '2' and '3'
     $this->assertSame('2', Option::get('admin_defaultReport'));
     $this->assertSame('3', Option::get('visitor_defaultReport'));
     $this->assertSame('0', Option::get('adefaultReport'));
     // deleted, expect false (except for the guard)
     Option::deleteLike('%\\_defaultReport');
     $this->assertFalse(Option::get('admin_defaultReport'));
     $this->assertFalse(Option::get('visitor_defaultReport'));
     // unescaped backslash (single quotes)
     Option::deleteLike('%\\_defaultReport');
     $this->assertSame('0', Option::get('adefaultReport'));
     // escaped backslash (single quotes)
     Option::deleteLike('%\\_defaultReport');
     $this->assertSame('0', Option::get('adefaultReport'));
     // unescaped backslash (double quotes)
     Option::deleteLike("%\\_defaultReport");
     $this->assertSame('0', Option::get('adefaultReport'));
     // escaped backslash (double quotes)
     Option::deleteLike("%\\_defaultReport");
     $this->assertSame('0', Option::get('adefaultReport'));
 }