Pimcore\Update::executeScript PHP Method

executeScript() public static method

public static executeScript ( $revision, $type ) : array
$revision
$type
return array
    public static function executeScript($revision, $type)
    {
        $script = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update/" . $revision . "/scripts/" . $type . ".php";
        $maxExecutionTime = 900;
        @ini_set("max_execution_time", $maxExecutionTime);
        set_time_limit($maxExecutionTime);
        Cache::disable();
        // it's important to disable the cache here eg. db-schemas, ...
        $outputMessage = "";
        if (is_file($script)) {
            ob_start();
            try {
                if (!self::$dryRun) {
                    include $script;
                }
            } catch (\Exception $e) {
                Logger::error($e);
                $outputMessage .= "EXCEPTION: " . $e->getMessage();
                $outputMessage .= "<br>For details please have a look into debug.log<br>";
            }
            $outputMessage .= ob_get_clean();
        }
        self::clearOPCaches();
        return ["message" => $outputMessage, "success" => true];
    }

Usage Example

 public function jobProceduralAction()
 {
     $status = array("success" => true);
     if ($this->getParam("type") == "files") {
         Update::installData($this->getParam("revision"));
     } else {
         if ($this->getParam("type") == "clearcache") {
             \Pimcore\Cache::clearAll();
         } else {
             if ($this->getParam("type") == "preupdate") {
                 $status = Update::executeScript($this->getParam("revision"), "preupdate");
             } else {
                 if ($this->getParam("type") == "postupdate") {
                     $status = Update::executeScript($this->getParam("revision"), "postupdate");
                 } else {
                     if ($this->getParam("type") == "cleanup") {
                         Update::cleanup();
                     }
                 }
             }
         }
     }
     // we use pure PHP here, otherwise this can cause issues with dependencies that changed during the update
     header("Content-type: application/json");
     echo json_encode($status);
     exit;
 }
All Usage Examples Of Pimcore\Update::executeScript