Example #1
0
 /**
  * Fetches statuses of the previous updates
  */
 private function fetchStatusBefore()
 {
     $this->stateBefore = new \ArrayObject();
     $this->fetchMysqlStatusBefore('adodb');
     if (\Scalr::getContainer()->analytics->enabled) {
         try {
             $this->fetchMysqlStatusBefore('cadb');
         } catch (\Exception $e) {
             if (preg_match('~connect|upgrades. doesn.t exist~i', $e->getMessage())) {
                 //Database may not exist because of creating from some update
             } else {
                 throw $e;
             }
         }
     }
     //Loads updates of FileSystem type
     self::checkFilesystemStorage();
     //Loads performed updates of Filesystem type
     foreach (new FilesystemStorageIterator(self::FS_STORAGE_PATH) as $fileInfo) {
         /* @var $fileInfo \SplFileInfo */
         if (!$fileInfo->isReadable()) {
             throw new Exception\UpgradeException(sprintf('Could not read from file "%s". Lack of access permissions.', $fileInfo->getFilename()));
         }
         $entity = new FilesystemUpgradeEntity();
         $obj = unserialize(file_get_contents($fileInfo->getPathname()));
         if (!is_object($obj)) {
             throw new Exception\UpgradeException(sprintf('There was error while trying to load record from filesystem storage "%s". Object is expected, %s given', $fileInfo->getPathname(), gettype($obj)));
         }
         $entity->load($obj);
         $this->stateBefore[$entity->uuid] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
         unset($obj);
     }
 }
Example #2
0
 /**
  * Fetches statuses of the previous updates
  */
 private function fetchStatusBefore()
 {
     $this->stateBefore = new \ArrayObject();
     //Loads performed updates of MYSQL type
     $rs = $this->db->Execute("\n            SELECT LOWER(HEX(u.`uuid`)) `uuid`, u.`released`, u.`appears`, u.`applied`, u.`status`, LOWER(HEX(u.`hash`)) `hash`\n            FROM `" . self::DB_TABLE_UPGRADES . "` u\n        ");
     while ($rec = $rs->FetchRow()) {
         $entity = new MysqlUpgradeEntity();
         $entity->load($rec);
         $this->stateBefore[$rec['uuid']] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
     }
     //Loads updates of FileSystem type
     self::checkFilesystemStorage();
     //Loads performed updates of Filesystem type
     foreach (new FilesystemStorageIterator(self::FS_STORAGE_PATH) as $fileInfo) {
         /* @var $fileInfo \SplFileInfo */
         if (!$fileInfo->isReadable()) {
             throw new Exception\UpgradeException(sprintf('Could not read from file "%s". Lack of access permissions.', $fileInfo->getFilename()));
         }
         $entity = new FilesystemUpgradeEntity();
         $obj = unserialize(file_get_contents($fileInfo->getPathname()));
         if (!is_object($obj)) {
             throw new Exception\UpgradeException(sprintf('There was error while trying to load record from filesystem storage "%s". Object is expected, %s given', $fileInfo->getPathname(), gettype($obj)));
         }
         $entity->load($obj);
         $this->stateBefore[$entity->uuid] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
         unset($obj);
     }
 }