HipHop

Running MediaWiki under HipHop
HipHop is an open source PHP to C++ translator developed by Facebook.

HipHop support in MediaWiki is currently at an early stage of development. It should not be used by anyone except for developers wishing to improve the HipHop support.

For information on installing HipHop, see the HipHop wiki. To compile MediaWiki with HipHop:

cd /path/to/wiki/maintenance/hiphop hphpi -f make

This will create a compiled binary at build/persistent/mediawiki-hphp. To run a test server, use:

./run-server

This will start an HTTP server which listens on port 8080. MediaWiki will be accessible at http://localhost:8080/index.php.

To run a maintenance script:

build/persistent/mediawiki-hphp -f maintenance/&lt;SCRIPT_NAME&gt;.php

Currently, to reduce build time, only a small subset of MediaWiki files are compiled by default.

Interpreter
HipHop has both a compiler and an interpreter. For the maximum speedup, we want as much code to be compiled as possible. However, the build process is slow (~30 minutes), so it seems reasonable to interpret the configuration files.

It's possible to interpret arbitrary code with eval or include called from a compiled program. In fact, this is how the hphpi binary works -- it is written in PHP.

File level code can be compiled like any other code. To execute compiled files, use:

require( MWInit::compiledPath( 'path/to/File.php' ) );

where the path is relative to $IP. To cause a file to be executed in interpreted mode, use:

require( MWInit::interpretedPath( 'path/to/File.php' ) );

Both of these forms will work in Zend.php.

Declarations
The following entities are available from the startup of the compiled binary:


 * Class declarations
 * Function declarations
 * Constants created with define with a name and value easily determined at compile time

It's not possible to put code which you wish to execute at runtime in the file level of the same file that contains such declarations. Because the class or function already exists at startup, including the file leads to a duplicate definition error.

Although all classes are available from startup, calling class_exists on them will return false. This is a HipHop bug. To work around it, use MWInit::classExists instead. This works by using the Reflection extension.

Differences compared with Zend PHP

 * Many extensions have only "stub" implementations, which apparently means that they have classes with the right methods, but the methods do nothing.
 * MySQL is the only supported DBMS.
 * Some functions have incomplete implementations:
 * error_log: The message type is ignored, the string is just sent to the server log
 * method_exists: The first parameter must be an object. Checking for static methods is not possible.
 * Most php.ini settings are gone. ini_get and ini_set only work for a few selected settings:
 * error_reporting
 * memory_limit
 * max_execution_time
 * hphp.build_id
 * arg_separator.output
 * upload_max_filesize
 * log_errors
 * error_log
 * notice_frequency
 * warning_frequency
 * include_path

Some other differences are listed in the inconsistencies file in the HipHop source.