Patching Drupal Views 6.X-2.16 to work with PHP 5.4.X

Submitted by Jochus on Wed, 29/10/2014 - 21:23 | Posted in: Drupal
Posted in

My webhosting recently upgraded to PHP 5.4.X - my website is currently running on an old installation of Drupal 6 (version 33). I was suffering a lot of PHP warnings when browsing through some of my webpages. An interesting patch could be found at, which actually cleared all warnings.

Thanks Peter Bowey!

Installing Trac 1.0.1 on Windows 8.1 + configuring Subversion repository

Submitted by Jochus on Sun, 03/08/2014 - 00:02 | Posted in: Windows
Posted in


To install Trac 1.0.1 on a Windows 8.1 installation, I used the following dependencies:

Apache HTTPD 2.2.25 (32bit)
Python 2.7.8 (32bit)
setuptools 5.4.1
mod_wsgi 3.5.ap22.win32-py2.7 (32 bit)
Subversion 1.8.9 (r1591380)
Python Subversion bindings svn-win32-1.8.9
  • Be sure to keep the same architecture (32 or 64 bit) for all components. Don't mix them up, as you will get conflicts. In this tutorial, I used 32 bit installers.
  • I assumed Subversion is already installed, and your repository is located on the same machine of the Trac server (repository created in C:\SVN). Authentication is performed based on HTTPD Basic auth file (file located at C:\SVN\conf\svn-auth-file)

Installing Python

  • Python is required to startup Trac as Trac is built on top of Python
  • Download from:
  • Choose version: 2.7.8 - 32 bit
  • When installing, make sure you select: Install for all users, and not the current user. If you don't do this, the Apache service will not be able to access Python eggs
  • When installing, also check Add python.exe to Path
  • After installation, restart your machine so the new system variable Path will be in memory. Otherwise, you cannot use the python.exe command from whatever folder you're currently working in

Installing setuptools

  • setuptools is required to install a Python package like Trac. setuptools will have a look at the dependencies, and will automatically download/install the dependencies for you (e.g.: Genshi)
  • Download from:
  • Choose version: 5.4.2 - Windows 7
  • Download the file
  • When downloaded, double click the file to install setuptools
  • Add C:\Python27\Scripts to Path variable
  • After installation, restart your machine so the new system variable Path will be in memory. Otherwise, you cannot use the easy_install.exe command from whatever folder you're currently working in (and also later on trac-admin.exe)

Installing trac

  • Open command prompt and type: $ easy_install trac
  • The command prompt will install Trac and its dependencies. At the end, a message Congratulations! will be visible in the command prompt

Create trac environment

  • Open command prompt and type: $ trac-admin C:\Trac initenv
  • Follow steps to create your project

Configuring mod_wsgi

  • mod_wsgi is used to connect Trac with Apache HTTPD. In this case, you won't need to run Trac on a specific port like 8000
  • Download from
  • Choose version: mod_wsgi‑3.5.ap22.win32‑
  • Unzip and move contents to C:/Program Files/Apache Software Foundation/Apache2.2/modules/. Make sure the Apache service can read this .so file
  • Create Apache HTTPD directories by executing the command: $ trac-admin C:\Trac deploy C:\Temp
  • Copy C:\Temp\cgi-bin and C:\Temp\htdocs to C:\Trac
  • Enable module in Apache HTTPD by adding the following the line in the load modules section: LoadModule wsgi_module modules/
  • Add the following configuration at the bottom of the httpd.conf file
    WSGIScriptAlias /trac C:\Trac\cgi-bin\trac.wsgi               # Process Trac requets
    Alias /trac/chrome/common C:\Trac\htdocs\common               # Serve static content directly from disk (don't send to .cgi script)
    Alias /trac/chrome/site C:\Trac\htdocs\site                   # Serve static content directly from disk (don't send to .cgi script)
    <Directory C:\Trac\cgi-bin>
        WSGIApplicationGroup %{GLOBAL}
        Order allow,deny
        Allow from all
    <Directory C:\Trac\htdocs>
      Order allow,deny
      Allow from all
    <Location "/trac/login">
      AuthType Basic
      AuthName "Trac"
      AuthUserFile C:\SVN\conf\svn-auth-file
      Require valid-user
  • Restart Apache HTTPD and check if you can access: http://localhost/trac/
Remark on choosing the version of mod_wsgi. Don't use the ap24 version. I cannot explain why, but it gave me the following exception when starting up Apache HTTD. By downgrading to ap22, the exception disappeared:

Cannot load C:/Program Files/Apache Software Foundation/Apache2.2/modules/ into server: The specified module could not be found

Providing a user admin permissions

  • It would be better to create groups, but for this simple tutorial, I use a command to make 1 user admin: $ trac-admin C:\Trac permission add #USERNAME# TRAC_ADMIN

Configuring Subversion as a repository (browser)

  • To be able to let Trac communicate with Subversion, you need the Python SVN bindings
  • Download from:
  • Choose version:
  • Extract contents of ZIP file to C:\Python27\Lib\site-packages
  • Create a components section add the following lines to enable the SVN bindings:
    tracopt.versioncontrol.svn.* = enabled
  • Login to Trac with an admin account and go to Admin > Repositories and add your SVN repository
  • Open a command prompt and execute the following command to resync previous changesets: $ trac-admin C:\Trac repository resync #REPOSITORYNAME# (required for Timeline)
  • You should also set up a post-commit hook on the repository to keep Trac in sync with your Subversion repository (required for Timeline). Go to C:\SVN\hooks and create a file post-commit.bat (copy it from the existing template). Add the following line at the bottom of the script: trac-admin C:\Trac changeset added #REPOSITORYNAME# $REV. File should look like:
    trac-admin C:\Trac changeset added #REPOSITORYNAME# $REV
  • When you now click Browse source in Trac, you should be able to see your source code. The timeline will also be updated every time you make a commit

Fixing slow queries running on SQL server using JPA (Hibernate) and jTDS

Submitted by Jochus on Thu, 01/05/2014 - 07:40 | Posted in: Java
Posted in

Some JPA queries, especially the ones with a LIKE operator, can run very slow on a SQL server using jTDS.

The issue is in the way the jTDS drivers send the parameter strings to the SQL server. Apparently Java will attempt to send the parameters Unicode by default, and SQL server will translate it to ASCII. It can take some seconds because it changes each column value to Unicode before comparing against your parameter. This means it can't take full advantage of any index on the field leading to much slower performance.

If you add the following parameter sendStringParametersAsUnicode=false to your connection string in the datasource, this conversion step can be skipped and it can speed up the performance of your queries: