Index: trunk/phase3/maintenance/userDupes.inc |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | * @access private |
176 | 176 | */ |
177 | 177 | function newSchema() { |
178 | | - return class_exists( 'Revision' ); |
| 178 | + return MWInit::classExists( 'Revision' ); |
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
Index: trunk/phase3/maintenance/hiphop/make |
— | — | @@ -4,7 +4,6 @@ |
5 | 5 | require( dirname( __FILE__ ) . '/../Maintenance.php' ); |
6 | 6 | |
7 | 7 | class MakeHipHop extends Maintenance { |
8 | | - |
9 | 8 | function execute() { |
10 | 9 | $startTime = time(); |
11 | 10 | |
— | — | @@ -63,13 +62,21 @@ |
64 | 63 | ' --parse-on-demand=false' . |
65 | 64 | ' --program=mediawiki-hphp' . |
66 | 65 | ' --output-dir=' . wfEscapeShellArg( $outDir ) . |
67 | | - ' --log=3' ); |
| 66 | + ' --log=3', $ret ); |
68 | 67 | |
| 68 | + if ( $ret ) { |
| 69 | + $this->error( "hphp hit an error. Stopping build.\n" ); |
| 70 | + exit( 1 ); |
| 71 | + } |
| 72 | + |
69 | 73 | # Sanity check, quickly make sure we've got an output directory |
70 | 74 | if( !is_dir( $outDir ) ) { |
71 | 75 | $this->error( "No output directory", true ); |
72 | 76 | } |
73 | 77 | |
| 78 | + # Warn about volatile classes |
| 79 | + $this->checkVolatileClasses( $outDir ); |
| 80 | + |
74 | 81 | # Copy the generated C++ files into the source directory for cmake |
75 | 82 | $iter = new RecursiveIteratorIterator( |
76 | 83 | new RecursiveDirectoryIterator( $outDir ), |
— | — | @@ -140,7 +147,7 @@ |
141 | 148 | } |
142 | 149 | |
143 | 150 | $cmd = 'cmake' . |
144 | | - ' -D CMAKE_BUILD_TYPE:string=Debug' . |
| 151 | + " -D CMAKE_BUILD_TYPE:string=" . wfEscapeShellArg( $GLOBALS['wgHipHopBuildType'] ) . |
145 | 152 | ' -D PROGRAM_NAME:string=mediawiki-hphp'; |
146 | 153 | |
147 | 154 | if ( file_exists( '/usr/bin/ccache' ) ) { |
— | — | @@ -155,19 +162,7 @@ |
156 | 163 | |
157 | 164 | # Determine appropriate make concurrency |
158 | 165 | # Compilation can take a lot of memory, let's assume that that is limiting. |
159 | | - $mem = false; |
160 | | - foreach ( file( '/proc/meminfo' ) as $line ) { |
161 | | - if ( preg_match( '/^MemTotal:\s+(\d+)\s+kB/', $line, $m ) ) { |
162 | | - $mem = intval( $m[1] ); |
163 | | - break; |
164 | | - } |
165 | | - } |
166 | | - if ( $mem ) { |
167 | | - $procs = floor( $mem / 1000000 ); |
168 | | - $procs = $procs >= 1 ? $procs : 1; // No less than 1 |
169 | | - } else { |
170 | | - $procs = 1; |
171 | | - } |
| 166 | + $procs = $this->getNumProcs(); |
172 | 167 | |
173 | 168 | # Run make. This is the slow step. |
174 | 169 | passthru( 'make -j' . wfEscapeShellArg( $procs ) ); |
— | — | @@ -188,6 +183,47 @@ |
189 | 184 | echo $elapsed . "s\n"; |
190 | 185 | echo "The MediaWiki executable is at build/persistent/mediawiki-hphp\n"; |
191 | 186 | } |
| 187 | + |
| 188 | + function checkVolatileClasses( $dir ) { |
| 189 | + $lines = file( "$dir/sys/dynamic_table_class.cpp" ); |
| 190 | + $classes = array(); |
| 191 | + foreach ( $lines as $line ) { |
| 192 | + if ( preg_match( '/^\s+\(const char \*\)"([^"]*)", \(const char \*\)-1/', $line, $m ) ) { |
| 193 | + $classes[] = $m[1]; |
| 194 | + } |
| 195 | + } |
| 196 | + if ( !count( $classes ) ) { |
| 197 | + print "No volatile classes found\n"; |
| 198 | + return; |
| 199 | + } |
| 200 | + sort( $classes ); |
| 201 | + $classes = array_unique( $classes ); |
| 202 | + print "WARNING: The following classes are volatile: " . implode( ', ', $classes ) . "\n"; |
| 203 | + } |
| 204 | + |
| 205 | + function getNumProcs() { |
| 206 | + global $wgHipHopCompilerProcs; |
| 207 | + if ( $wgHipHopCompilerProcs !== 'detect' ) { |
| 208 | + return intval( $wgHipHopCompilerProcs ); |
| 209 | + } |
| 210 | + |
| 211 | + if ( !file_exists( '/proc/meminfo' ) ) { |
| 212 | + return 1; |
| 213 | + } |
| 214 | + $mem = false; |
| 215 | + foreach ( file( '/proc/meminfo' ) as $line ) { |
| 216 | + if ( preg_match( '/^MemTotal:\s+(\d+)\s+kB/', $line, $m ) ) { |
| 217 | + $mem = intval( $m[1] ); |
| 218 | + break; |
| 219 | + } |
| 220 | + } |
| 221 | + if ( $mem ) { |
| 222 | + // At least one process |
| 223 | + return max( 1, floor( $mem / 1000000 ) ); |
| 224 | + } else { |
| 225 | + return 1; |
| 226 | + } |
| 227 | + } |
192 | 228 | } |
193 | 229 | |
194 | 230 | $maintClass = 'MakeHipHop'; |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | } |
77 | 77 | |
78 | 78 | # Check php's file_uploads setting |
79 | | - if( !wfIniGetBool( 'file_uploads' ) ) { |
| 79 | + if( !wfIsHipHop() && !wfIniGetBool( 'file_uploads' ) ) { |
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | return true; |
Index: trunk/phase3/includes/parser/Parser_LinkHooks.php |
— | — | @@ -254,8 +254,8 @@ |
255 | 255 | } |
256 | 256 | if( $return === true ) { |
257 | 257 | # True (treat as plain link) was returned, call the defaultLinkHook |
258 | | - $args = array( $parser, $holders, $markers, $title, $titleText, &$paramText, &$leadingColon ); |
259 | | - $return = call_user_func_array( array( 'CoreLinkFunctions', 'defaultLinkHook' ), $args ); |
| 258 | + $return = CoreLinkFunctions::defaultLinkHook( $parser, $holders, $markers, $title, |
| 259 | + $titleText, $paramText, $leadingColon ); |
260 | 260 | } |
261 | 261 | if( $return === false ) { |
262 | 262 | # False (no link) was returned, output plain wikitext |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -337,9 +337,9 @@ |
338 | 338 | require_once( "$IP/includes/Hooks.php" ); |
339 | 339 | require_once( "$IP/includes/ProxyTools.php" ); |
340 | 340 | require_once( "$IP/includes/ImageFunctions.php" ); |
| 341 | + require_once( "$IP/includes/normal/UtfNormalDefines.php" ); |
341 | 342 | wfProfileOut( $fname . '-includes' ); |
342 | 343 | } |
343 | | -require_once( MWInit::compiledPath( 'includes/normal/UtfNormalDefines.php' ) ); |
344 | 344 | |
345 | 345 | wfProfileIn( $fname . '-misc1' ); |
346 | 346 | |
Index: trunk/phase3/includes/Init.php |
— | — | @@ -90,4 +90,13 @@ |
91 | 91 | } |
92 | 92 | return $r !== false; |
93 | 93 | } |
| 94 | + |
| 95 | + /** |
| 96 | + * Call a static method of a class with variable arguments without causing |
| 97 | + * it to become volatile. |
| 98 | + */ |
| 99 | + static function callStaticMethod( $className, $methodName, $args ) { |
| 100 | + $r = new ReflectionMethod( $className, $methodName ); |
| 101 | + return $r->invokeArgs( null, $args ); |
| 102 | + } |
94 | 103 | } |
Index: trunk/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -606,7 +606,7 @@ |
607 | 607 | function newFatal( $message /*, parameters...*/ ) { |
608 | 608 | $params = func_get_args(); |
609 | 609 | array_unshift( $params, $this ); |
610 | | - return call_user_func_array( array( 'FileRepoStatus', 'newFatal' ), $params ); |
| 610 | + return MWInit::callStaticMethod( 'FileRepoStatus', 'newFatal', $params ); |
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -5309,6 +5309,25 @@ |
5310 | 5310 | /** @} */ # End job queue } |
5311 | 5311 | |
5312 | 5312 | /************************************************************************//** |
| 5313 | + * @name HipHop compilation |
| 5314 | + * @{ |
| 5315 | + */ |
| 5316 | + |
| 5317 | +/** |
| 5318 | + * The HipHop build type. Can be either "Debug" or "Release". |
| 5319 | + */ |
| 5320 | +$wgHipHopBuildType = 'Debug'; |
| 5321 | + |
| 5322 | +/** |
| 5323 | + * Number of parallel processes to use during HipHop compilation, or "detect" |
| 5324 | + * to guess from system properties. |
| 5325 | + */ |
| 5326 | +$wgHipHopCompilerProcs = 'detect'; |
| 5327 | + |
| 5328 | +/** @} */ # End of HipHop compilation } |
| 5329 | + |
| 5330 | + |
| 5331 | +/************************************************************************//** |
5313 | 5332 | * @name Miscellaneous |
5314 | 5333 | * @{ |
5315 | 5334 | */ |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -863,9 +863,13 @@ |
864 | 864 | ); |
865 | 865 | } |
866 | 866 | |
867 | | - $this->mMaxUploadSize['file'] = min( |
868 | | - wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ), |
869 | | - UploadBase::getMaxUploadSize( 'file' ) ); |
| 867 | + $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize( 'file' ); |
| 868 | + # Limit to upload_max_filesize unless we are running under HipHop and |
| 869 | + # that setting doesn't exist |
| 870 | + if ( !wfIsHipHop() ) { |
| 871 | + $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'], |
| 872 | + wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) ); |
| 873 | + } |
870 | 874 | |
871 | 875 | $descriptor['UploadFile'] = array( |
872 | 876 | 'class' => 'UploadSourceField', |
Index: trunk/phase3/index.php |
— | — | @@ -66,7 +66,11 @@ |
67 | 67 | # does *not* load $wgTitle |
68 | 68 | require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |
69 | 69 | |
70 | | -wfIndexMain(); |
| 70 | +try { |
| 71 | + wfIndexMain(); |
| 72 | +} catch ( Exception $e ) { |
| 73 | + wfExceptionHandler( $e ); |
| 74 | +} |
71 | 75 | |
72 | 76 | function wfIndexMain() { |
73 | 77 | global $wgRequest, $wgShowHostnames, $mediaWiki, $wgTitle, $wgUseAjax, $wgUseFileCache; |