public static function onError($number, $message, $file, $line)
 {
     if (error_reporting() === 0) {
         return;
     }
     $msg = $message . ' at ' . $file . '#' . $line;
     self::$logger->warning($msg, array('app' => 'PHP'));
 }
Example #2
0
 /**
  * @param JobList $jobList
  * @param \OC\Log $logger
  */
 public function execute($jobList, $logger = null)
 {
     $jobList->setLastRun($this);
     try {
         $this->run($this->argument);
     } catch (\Exception $e) {
         if ($logger) {
             $logger->error('Error while running background job: ' . $e->getMessage());
         }
         $jobList->remove($this, $this->argument);
     }
 }
Example #3
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @return bool true if the operation succeeded, false otherwise
  */
 public function upgrade()
 {
     $logLevel = \OC_Config::getValue('loglevel', \OCP\Util::WARN);
     $this->emit('\\OC\\Updater', 'setDebugLogLevel', array($logLevel, $this->logLevelNames[$logLevel]));
     \OC_Config::setValue('loglevel', \OCP\Util::DEBUG);
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     $success = true;
     try {
         $this->doUpgrade($currentVersion, $installedVersion);
     } catch (\Exception $exception) {
         \OCP\Util::logException('update', $exception);
         $this->emit('\\OC\\Updater', 'failure', array(get_class($exception) . ': ' . $exception->getMessage()));
         $success = false;
     }
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
     $this->emit('\\OC\\Updater', 'updateEnd', array($success));
     $this->emit('\\OC\\Updater', 'resetLogLevel', array($logLevel, $this->logLevelNames[$logLevel]));
     \OC_Config::setValue('loglevel', $logLevel);
     return $success;
 }
Example #4
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  */
 public function upgrade()
 {
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     try {
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // do a file cache upgrade for users with files
         // this can take loooooooooooooooooooooooong
         $this->upgradeFileCache();
     } catch (\Exception $exception) {
         $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage()));
     }
     \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     \OC_App::checkAppsRequirements();
     // load all apps to also upgrade enabled apps
     \OC_App::loadApps();
     $repair = new Repair();
     $repair->run();
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
 }
Example #5
0
 protected function cleanFiles($files)
 {
     foreach ($files as $file) {
         if (file_exists($file)) {
             try {
                 \OC_Helper::rmdirr($file);
             } catch (\UnexpectedValueException $ex) {
                 $this->log->warning("Error deleting temporary file/folder: {file} - Reason: {error}", array('file' => $file, 'error' => $ex->getMessage()));
             }
         }
     }
 }
Example #6
0
 /**
  * read encryption module needed to read/write the file located at $path
  *
  * @param string $path
  * @return null|\OCP\Encryption\IEncryptionModule
  * @throws ModuleDoesNotExistsException
  * @throws \Exception
  */
 protected function getEncryptionModule($path)
 {
     $encryptionModule = null;
     $header = $this->getHeader($path);
     $encryptionModuleId = $this->util->getEncryptionModuleId($header);
     if (!empty($encryptionModuleId)) {
         try {
             $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId);
         } catch (ModuleDoesNotExistsException $e) {
             $this->logger->critical('Encryption module defined in "' . $path . '" not loaded!');
             throw $e;
         }
     }
     return $encryptionModule;
 }
Example #7
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @return bool true if the operation succeeded, false otherwise
  */
 public function upgrade()
 {
     $this->config->setSystemValue('maintenance', true);
     $installedVersion = $this->config->getSystemValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     try {
         $this->doUpgrade($currentVersion, $installedVersion);
     } catch (\Exception $exception) {
         $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage()));
     }
     $this->config->setSystemValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
 }
Example #8
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  */
 public function upgrade()
 {
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.00.4', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     try {
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // do a file cache upgrade for users with files
         // this can take loooooooooooooooooooooooong
         $this->upgradeFileCache();
     } catch (\Exception $exception) {
         $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage()));
     }
     \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     \OC_App::checkAppsRequirements();
     // load all apps to also upgrade enabled apps
     \OC_App::loadApps();
     $repair = new Repair();
     $repair->run();
     //Invalidate update feed
     \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
 }
Example #9
0
 public static function onAll($number, $message, $file, $line)
 {
     $msg = $message . ' at ' . $file . '#' . $line;
     self::$logger->debug(self::removePassword($msg), array('app' => 'PHP'));
 }