3 require __DIR__ .
'/../Maintenance.php';
8 $this->
addDescription(
'Compile PHP sources for this MediaWiki instance, ' .
9 'and generate an HHVM bytecode file to be used with HHVM\'s ' .
10 'RepoAuthoritative mode. The MediaWiki core installation path and ' .
11 'all registered extensions are automatically searched for the file ' .
12 'extensions *.php, *.inc, *.php5 and *.phtml.' );
13 $this->
addOption(
'output',
'Output filename',
true,
true,
'o' );
14 $this->
addOption(
'input-dir',
'Add an input directory. ' .
15 'This can be specified multiple times.',
false,
true,
'd',
true );
16 $this->
addOption(
'exclude-dir',
'Directory to exclude. ' .
17 'This can be specified multiple times.',
false,
true,
false,
true );
18 $this->
addOption(
'extension',
'Extra file extension',
false,
true,
false,
true );
19 $this->
addOption(
'hhvm',
'Location of HHVM binary',
false,
true );
20 $this->
addOption(
'base-dir',
'The root of all source files. ' .
21 'This must match hhvm.server.source_root in the server\'s configuration file. ' .
22 'By default, the MW core install path will be used.',
24 $this->
addOption(
'verbose',
'Log level 0-3',
false,
true,
'v' );
27 private static function startsWith( $subject, $search ) {
28 return substr( $subject, 0, strlen( $search ) === $search );
38 if ( isset( $extension[
'path'] )
39 && !self::startsWith( $extension[
'path'], $IP )
41 $dirs[] = dirname( $extension[
'path'] );
54 array_flip( $this->
getOption(
'extension', [] ) );
58 $baseDir = $this->
getOption(
'base-dir', $IP );
59 $excludeDirs = array_map(
'realpath', $this->
getOption(
'exclude-dir', [] ) );
61 if ( $baseDir !==
'' && substr( $baseDir, -1 ) !==
'/' ) {
65 $unfilteredFiles = [
"$IP/LocalSettings.php" ];
67 $this->
appendDir( $unfilteredFiles, $dir );
71 foreach ( $unfilteredFiles
as $file ) {
72 $dotPos = strrpos( $file,
'.' );
73 $slashPos = strrpos( $file,
'/' );
74 if ( $dotPos ===
false || $slashPos ===
false || $dotPos < $slashPos ) {
77 $extension = substr( $file, $dotPos + 1 );
78 if ( !isset( $fileExts[$extension] ) ) {
81 $canonical = realpath( $file );
82 foreach ( $excludeDirs
as $excluded ) {
83 if ( self::startsWith( $canonical, $excluded ) ) {
87 if ( self::startsWith( $file, $baseDir ) ) {
88 $file = substr( $file, strlen( $baseDir ) );
96 count(
$dirs ) .
" directories\n";
98 $tmpDir =
wfTempDir() .
'/mw-make-repo' . mt_rand( 0, 1<<31 );
99 if ( !mkdir( $tmpDir ) ) {
100 $this->
error(
'Unable to create temporary directory', 1 );
102 file_put_contents(
"$tmpDir/file-list", implode(
"\n",
$files ) );
104 $hhvm = $this->
getOption(
'hhvm',
'hhvm' );
105 $verbose = $this->
getOption(
'verbose', 3 );
110 '--format',
'binary',
112 '--keep-tempdir',
'1',
114 '-v',
'AllVolatile=true',
115 '--input-dir', $baseDir,
116 '--input-list',
"$tmpDir/file-list",
117 '--output-dir', $tmpDir );
119 passthru( $cmd,
$ret );
122 $this->
error(
"Error: HHVM returned error code $ret", 1 );
124 if ( !rename(
"$tmpDir/hhvm.hhbc", $this->
getOption(
'output' ) ) ) {
126 $this->
error(
"Error: unable to rename output file", 1 );
133 if ( file_exists(
"$tmpDir/hhvm.hhbc" ) ) {
134 unlink(
"$tmpDir/hhvm.hhbc" );
136 if ( file_exists(
"$tmpDir/Stats.js" ) ) {
137 unlink(
"$tmpDir/Stats.js" );
140 unlink(
"$tmpDir/file-list" );
145 $iter =
new RecursiveIteratorIterator(
146 new RecursiveDirectoryIterator(
148 FilesystemIterator::UNIX_PATHS
150 RecursiveIteratorIterator::LEAVES_ONLY
152 foreach ( $iter
as $file => $fileInfo ) {
153 if ( $fileInfo->isFile() ) {
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
require_once RUN_MAINTENANCE_IF_MAIN
when a variable name is used in a it is silently declared as a new local masking the global
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
addOption($name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
wfTempDir()
Tries to get the system directory for temporary files.
addDescription($text)
Set the description text.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getOption($name, $default=null)
Get an option, or return the default.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static startsWith($subject, $search)
error($err, $die=0)
Throw an error to the user.
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type