Translate: 
EnglishFrenchGermanItalianPolishPortugueseRussianSpanish

Drupal 7: Download HipHop for PHP’s compatible source codes!

As promised in a previous article I give you source codes of Drupal 7 which are compatible with HipHop for PHP source code transformer.

This version of the patch has been successfully tested on a minimum base installation of Drupal 7.0. At the moment I can not guarantee the correct operation of other versions of Drupal. Subsequent patches will add support for additional modules should they prove to be defective during the futher test process.

There is also a new version of patch which is compatible with Drupal 7.2, read this article for futher info.

Please report any patch issues in the comments to this story.

Attention!

Latest HipHop for PHP branches seems buggy and do not work with Drupal 7.x. In order to compile Drupal 7, you have to use earlier version of HipHop for PHP or wait for Facebook development team to fix this issue.

Download modified files

You can install this patch in two different ways. Either by patching the original Drupal 7.0 source code using this diff file or by downloading already patched Drupal 7 source code from this link.

Apply the patch

You can patch Drupal 7 using the following command:

cd ~drupal
patch -p1 < ../drupal-hiphop-2011-05-19-a.diff

Compile Drupal 7

Install the HipHop for PHP compiler (see this article for instructions on how to do this) and extract Drupal 7 source codes into the ~drupal home directory. Then use following commands to compile the application:

cd ~drupal
export MAKEOPTS=' -j4 '
find . \( -name "*.php" -o -name "*.engine" -o -name "*.inc" -o -name "*.info" -o -name "*.install" -o -name "*.module" -o -name "*.profile" -o -name "*.test" -o -name "*.theme" -o -name "*.tpl" \) > files.full.list
date && ~/hiphop/hiphop-php/src/hphp/hphp  --keep-tempdir=1\
 --log=3\
 --input-list=files.full.list\
 --include-path="." --force=1\
 --cluster-count=240\
 -v "AllDynamic=true"\
 -v "AllVolatile=true"\
 -o /tmp/drupal\
 --parse-on-demand=0\
 --sync-dir=/tmp/sync

I highly recommend using the distcc or ccache to speed up the entire build process (please read this article for details about this topic).

Launch Drupal 7

After succesful compilation you can start Drupal 7 by issuing the following command:

cd ~drupal
/tmp/drupal/program -m server -p 80\
 -v "Server.SourceRoot=`pwd`"\
 -v "Server.DefaultDocument=index.php"\
 -c $HPHP_HOME/bin/mime.hdf\
 -v "Log.File=/tmp/errors" &

This command starts Drupal 7 as a standalone HTTP server listening on a port 80.

Launch the installation wizard

After starting the HTTP server you can launch Drupal 7 installation wizard using your favourite web browser.

Please note: system’s configuration is stored in a php file which has to be compiled every time it changes. After setting the database configuration you will be forced to recompile your entire application in order to apply the changes commited by the installation wizard to settings.php file

In order to do so, you have to recreate the list of files to compile (to include newly created settings.php file) and rebuild Drupal 7:

cd ~drupal
find . \( -name "*.php" -o -name "*.engine" -o -name "*.inc" -o -name "*.info" -o -name "*.install" -o -name "*.module" -o -name "*.profile" -o -name "*.test" -o -name "*.theme" -o -name "*.tpl" \) > files.full.list
date && ~/hiphop/hiphop-php/src/hphp/hphp  --keep-tempdir=1\
 --log=3\
 --input-list=files.full.list\
 --include-path="." --force=1\
 --cluster-count=240\
 -v "AllDynamic=true"\
 -v "AllVolatile=true"\
 -o /tmp/drupal\
 --parse-on-demand=0\
 --sync-dir=/tmp/sync

After compilation you may continue the installation process.

You can bypass this inconvenience if you install Drupal 7 using the regular PHP mode and then compile the application.


Patch technical details:

Modified source codes are 100% compatible with the original Drupal 7.0 and its modules.

Changes in the code

  1. [spl_autoload_register] – HipHop for PHP falls into an infinite loop while the autoloader handler tests whether a given class exists. Class and interface checking has been turned off in the compiled application.
  2. [traversable] – HipHop for PHP does not support the Traversable interface in a class that handles the PDO statements. Foreach loops have been modified to use the fetchAll() method.
  3. [filter] – HipHop does not support the filter module. filter_var() function has been replaced by regular expressions.
  4. [streams] – HipHop for PHP does not support the stream_get_wrappers() function. In compiled version Drupal returns an array containing only two fixed values​​: file, http.
  5. [foreach/reset] – Added reset() clause after few foreach loops. HipHop for PHP does not like mixing next()/current()/each() functions with arrays that have been already iterated by the foreach loop
  6. [func_get_args()] – some versions of HipHop for PHP fail to compile Drupal 7 when calling func_get_args() function with a reference operator on the left (ie $x = &func_get_args()). The reference operator has been removed from the source code.

Issues found so far

  1. [php_eval ()] – Drupal uses this function to support PHP in HTML templates. This is not a problem until a HTML block containing dynamically loaded PHP code is created.
  2. [databases] – HipHop for PHP supports only the MySQL database.

Other articles about HipHop for PHP


Tags: , , ,

Leave a Reply