From 011b9f7445dac04008ec8aeab2df7aa191256cbb Mon Sep 17 00:00:00 2001 From: Ralph Asendeteufrer Date: Tue, 16 Oct 2012 10:17:25 -0400 Subject: [PATCH] BUG 9814 Proposal pivot skin: UNDER CONSTRUCTION PROBLEM There is not a page to show up if PM is under updating. SOLUTION Add a page to be displayed only if PM is updating. --- gulliver/system/class.g.php | 30 +++++++++++++++++++++++ workflow/engine/bin/tasks/cliUpgrade.php | 5 ++++ workflow/engine/classes/class.wsTools.php | 8 ------ workflow/public_html/sysGeneric.php | 9 ++----- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 6c0cca0ea..b68e58bda 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5491,6 +5491,36 @@ function getDirectorySize($path,$maxmtime=0) } return $text;//TODO: perhaps it shouls return an array to don't loose the original string text } + + /** + * isPMUnderUpdating, Used to set a file flag tio check if PM is upgrading. + * + * @setFlag Contains the flag to set or unset the temporary file: + * 0 to delete the temporary file flag + * 1 to set the temporary file flag. + * 2 or bigger to check if the temporary file exists. + * return true if the file exists, otherwise false. + */ + function isPMUnderUpdating($setFlag = 2) + { + $fileCheck = PATH_TRUNK."UPDATE.dat"; + if($setFlag == 0){ + if (file_exists($fileCheck)){ + unlink ($fileCheck); + } + } + else if($setFlag == 1){ + $fp = fopen($fileCheck,'w'); + $line = fputs($fp,"true"); + } + //checking temporary file + if($setFlag >= 1){ + if ( file_exists($fileCheck)){ + return true; + } + } + return false; + } } /** diff --git a/workflow/engine/bin/tasks/cliUpgrade.php b/workflow/engine/bin/tasks/cliUpgrade.php index 8fd785622..69f5d5b48 100755 --- a/workflow/engine/bin/tasks/cliUpgrade.php +++ b/workflow/engine/bin/tasks/cliUpgrade.php @@ -64,6 +64,9 @@ function run_upgrade($command, $args) { CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log"); CLI::logging("Checking files integrity...\n"); + //setting flag to true to check into sysGeneric.php + $flag = G::isPMUnderUpdating(1); + //start to upgrade $checksum = System::verifyChecksum(); if ($checksum === false) { CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n"); @@ -117,5 +120,7 @@ function run_upgrade($command, $args) } else { CLI::logging("Upgrade successful\n"); } + //setting flag to false + $flag = G::isPMUnderUpdating(0); } diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 0315124f8..3841b45ed 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -56,12 +56,6 @@ class workspaceTools { */ public function upgrade($first=false, $buildCacheView=false, $workSpace=SYS_SYS) { - //setting flag to true to check into sysGeneric.php by usign G::virtualURI - date_default_timezone_get(); - //$final = date('F d, Y h:i:s', mktime(date('h'), date('i')+3, date('s')+30,date("m"),date("d"),date("Y"))); - //$_SERVER['timeRemainUpdate'] = $final; - $_SERVER['Updating'] = true; - //updating $start = microtime(true); CLI::logging("> Updating database...\n"); $this->upgradeDatabase(); @@ -89,8 +83,6 @@ class workspaceTools { $stop = microtime(true); $final = $stop - $start; CLI::logging("<*> Process Updating cache view carried out in $final seconds.\n"); - //setting flag to false - $_SERVER['Updating'] = true; } /** diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index b23e62d71..3bca3ea7f 100755 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -258,11 +258,6 @@ if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page die; break; - case 'update': - header ("location: /update/updating.php"); - if ( DEBUG_TIME_LOG ) G::logTimeByPage(); - die; - break; default : if (substr($realPath, 0, 12) == 'rest-service') { $isRestRequest = true; @@ -278,13 +273,13 @@ // the request correspond to valid php page, now parse the URI G::parseURI(getenv("REQUEST_URI"), $isRestRequest); - if(isset($_SERVER['Updating']) && $_SERVER['Updating'] == true) + //if(isset($_SERVER['Updating']) && $_SERVER['Updating'] == true) + if(G::isPMUnderUpdating()) { header("location: /update/updating.php"); if ( DEBUG_TIME_LOG ) G::logTimeByPage(); die; } - // verify if index.html exists if (!file_exists(PATH_HTML . 'index.html')) { // if not, create it from template