Changeset 379

Show
Ignore:
Timestamp:
07/29/08 16:02:41 (5 months ago)
Author:
mrook
Message:

#255 - Add Phing startup time to builtin properties

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/Phing.php

    r342 r379  
    128128         */ 
    129129        private static $isLogFileUsed = false; 
    130          
     130 
    131131        /** 
    132132         * Array to hold original ini settings that Phing changes (and needs 
     
    152152         */ 
    153153        public static function start($args, array $additionalUserProperties = null) { 
    154                  
     154 
    155155                try { 
    156156                        $m = new Phing(); 
     
    280280                self::$definedProps = new Properties(); 
    281281                $this->searchForThis = null; 
    282                  
     282 
    283283                // 1) First handle any options which should always 
    284284                // Note: The order in which these are executed is important (if multiple of these options are specified) 
    285                  
     285 
    286286                if (in_array('-help', $args) || in_array('-h', $args)) { 
    287287                        $this->printUsage(); 
    288288                        return; 
    289289                } 
    290                  
     290 
    291291                if (in_array('-version', $args) || in_array('-v', $args)) { 
    292292                        $this->printVersion(); 
    293293                        return; 
    294294                } 
    295                  
     295 
    296296                // 2) Next pull out stand-alone args. 
    297297                // Note: The order in which these are executed is important (if multiple of these options are specified) 
    298                  
     298 
    299299                if (false !== ($key = array_search('-quiet', $args, true))) { 
    300300                        self::$msgOutputLevel = Project::MSG_WARN; 
    301301                        unset($args[$key]); 
    302302                } 
    303                  
     303 
    304304                if (false !== ($key = array_search('-verbose', $args, true))) { 
    305305                        self::$msgOutputLevel = Project::MSG_VERBOSE; 
    306306                        unset($args[$key]); 
    307307                } 
    308                  
     308 
    309309                if (false !== ($key = array_search('-debug', $args, true))) { 
    310310                        self::$msgOutputLevel = Project::MSG_DEBUG; 
    311311                        unset($args[$key]); 
    312312                } 
    313                  
     313 
    314314                // 3) Finally, cycle through to parse remaining args 
    315                 //  
     315                // 
    316316                $keys = array_keys($args); // Use keys and iterate to max(keys) since there may be some gaps 
    317317                for($i=0, $max = max(array_keys($args)); $i <= $max; $i++) { 
    318                          
     318 
    319319                        if (!array_key_exists($i, $args)) { 
    320320                                // skip this argument, since it must have been removed above. 
    321321                                continue; 
    322322                        } 
    323                          
     323 
    324324                        $arg = $args[$i]; 
    325                          
     325 
    326326                        if ($arg == "-logfile") { 
    327327                                try { 
     
    590590                                throw new ConfigurationException($msg); 
    591591                        } 
    592                                  
     592 
    593593                        $listener = new $clz(); 
    594                                  
     594 
    595595                        if ($listener instanceof StreamRequiredBuildLogger) { 
    596596                                throw new ConfigurationException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)"); 
     
    697697 
    698698                        if (self::$phpErrorCapture) { 
    699                                          
     699 
    700700                                self::$capturedPhpErrors[] = array('message' => $message, 'level' => $level, 'line' => $line, 'file' => $file); 
    701701 
    702702                        } else { 
    703                                          
     703 
    704704                                $message = '[PHP Error] ' . $message; 
    705705                                $message .= ' [line ' . $line . ' of ' . $file . ']'; 
     
    949949                $dotClassname = basename($dotPath); 
    950950                $dotClassnamePos = strlen($dotPath) - strlen($dotClassname); 
    951                          
     951 
    952952                // 1- temporarily replace escaped '.' with another illegal char (#) 
    953953                $tmp = str_replace('\.', '##', $dotClassname); 
     
    10551055                        } 
    10561056                } else { 
    1057                         // We're not using PEAR, so do one additional check based on path of  
     1057                        // We're not using PEAR, so do one additional check based on path of 
    10581058                        // current file (Phing.php) 
    10591059                        $maybeHomeDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR  . '..'); 
    1060                         $testPath = $maybeHomeDir . DIRECTORY_SEPARATOR . $path;  
     1060                        $testPath = $maybeHomeDir . DIRECTORY_SEPARATOR . $path; 
    10611061                        if (file_exists($testPath)) { 
    10621062                                return $testPath; 
     
    11221122                self::setProperty('user.home', getenv('HOME')); 
    11231123                self::setProperty('application.startdir', getcwd()); 
     1124                self::setProperty('phing.startTime', gmdate('D, d M Y H:i:s', time()) . ' GMT'); 
    11241125 
    11251126                // try to detect machine dependent information 
     
    11351136                        $sysInfo['version'] = php_uname('v'); 
    11361137                } 
    1137                          
     1138 
    11381139 
    11391140                self::setProperty("host.name", isset($sysInfo['nodename']) ? $sysInfo['nodename'] : "unknown"); 
     
    12331234         */ 
    12341235        private static function setIni() { 
    1235                  
     1236 
    12361237                self::$origIniSettings['error_reporting'] = error_reporting(E_ALL); 
    1237                  
    1238                 // We won't bother storing original max_execution_time, since 1) the value in  
    1239                 // php.ini may be wrong (and there's no way to get the current value) and  
     1238 
     1239                // We won't bother storing original max_execution_time, since 1) the value in 
     1240                // php.ini may be wrong (and there's no way to get the current value) and 
    12401241                // 2) it would mean something very strange to set it to a value less than time script 
    12411242                // has already been running, which would be the likely change. 
    1242                  
     1243 
    12431244                set_time_limit(0); 
    1244                  
     1245 
    12451246                self::$origIniSettings['magic_quotes_gpc'] = ini_set('magic_quotes_gpc', 'off'); 
    12461247                self::$origIniSettings['short_open_tag'] = ini_set('short_open_tag', 'off'); 
     
    12491250                self::$origIniSettings['allow_call_time_pass_reference'] = ini_set('allow_call_time_pass_reference', 'on'); 
    12501251                self::$origIniSettings['track_errors'] = ini_set('track_errors', 1); 
    1251                  
     1252 
    12521253                // should return memory limit in MB 
    12531254                $mem_limit = (int) ini_get('memory_limit'); 
     
    12581259                } 
    12591260        } 
    1260          
     1261 
    12611262        /** 
    12621263         * Restores [most] PHP INI values to their pre-Phing state. 
    1263          *  
     1264         * 
    12641265         * Currently the following settings are not restored: 
    12651266         *      - max_execution_time (because getting current time limit is not possible) 
    12661267         *  - memory_limit (which may have been increased by Phing) 
    1267          *  
     1268         * 
    12681269         * @return void 
    12691270         */ 
     
    12971298         * Sets up the Phing environment but does not initiate the build process. 
    12981299         * @return void 
    1299          * @throws Exception - If the Phing environment cannot be initialized.  
     1300         * @throws Exception - If the Phing environment cannot be initialized. 
    13001301         */ 
    13011302        public static function startup() {