public function actionRequirementsCheck()
 {
     // Run the requirements checker
     $reqCheck = new RequirementsChecker();
     $reqCheck->run();
     if ($reqCheck->getResult() == InstallStatus::Failure) {
         // Coming from Updater.php
         if (craft()->request->isAjaxRequest()) {
             $message = '<br /><br />';
             foreach ($reqCheck->getRequirements() as $req) {
                 if ($req->result == 'failed') {
                     $message .= $req->notes . '<br />';
                 }
             }
             throw new Exception(Craft::t('The update can’t be installed. :( {message}', array('message' => $message)));
         } else {
             $this->_render('_special/cantrun', array('reqCheck' => $reqCheck));
             craft()->end();
         }
     } else {
         // Cache the app path.
         craft()->fileCache->set('appPath', craft()->path->getAppPath());
     }
 }
示例#2
0
 /**
  * @param string $unzipFolder
  *
  * @throws Exception
  * @return array
  */
 private function _validateNewRequirements($unzipFolder)
 {
     $requirementsFolderPath = $unzipFolder . '/app/etc/requirements/';
     $requirementsFile = $requirementsFolderPath . 'Requirements.php';
     $errors = array();
     if (!IOHelper::fileExists($requirementsFile)) {
         throw new Exception(Craft::t('The Requirements file is required and it does not exist at {path}.', array('path' => $requirementsFile)));
     }
     // Make sure we can write to craft/app/requirements
     if (!IOHelper::isWritable(craft()->path->getAppPath() . 'etc/requirements/')) {
         throw new Exception(StringHelper::parseMarkdown(Craft::t('Craft CMS needs to be able to write to your craft/app/etc/requirements folder and cannot. Please check your [permissions]({url}).', array('url' => 'http://craftcms.com/docs/updating#one-click-updating'))));
     }
     $tempFileName = StringHelper::UUID() . '.php';
     // Make a dupe of the requirements file and give it a random file name.
     IOHelper::copyFile($requirementsFile, $requirementsFolderPath . $tempFileName);
     $newTempFilePath = craft()->path->getAppPath() . 'etc/requirements/' . $tempFileName;
     // Copy the random file name requirements to the requirements folder.
     // We don't want to execute any PHP from the storage folder.
     IOHelper::copyFile($requirementsFolderPath . $tempFileName, $newTempFilePath);
     require_once $newTempFilePath;
     $checker = new RequirementsChecker();
     $checker->run();
     if ($checker->getResult() == RequirementResult::Failed) {
         foreach ($checker->getRequirements() as $requirement) {
             if ($requirement->getResult() == InstallStatus::Failed) {
                 Craft::log('Requirement "' . $requirement->getName() . '" failed with the message: ' . $requirement->getNotes(), LogLevel::Error, true);
                 $errors[] = $requirement->getNotes();
             }
         }
     }
     // Cleanup
     IOHelper::deleteFile($newTempFilePath);
     return $errors;
 }