Fix Mantis corrupt attachment files

After upgrading to the latest Mantis version, I had a problem with zip attachments being corrupted when downloaded from Mantis. Turns out his error message is added to the files:

SYSTEM WARNING: ‘finfo::finfo() [finfo.finfo]: Failed to load magic database at ‘/etc/magic’.’ in ‘/srv/sites/mantis.progi-media.com/htdocs/core/utility_api.php’ line 273

To fix the problem I had to manually configure the proper path to the magic file on the server.

First I located the magic database file through the man page for magic


# man magic

MAGIC(5)
NAME
magic – file command’s magic number file

DESCRIPTION
This manual page documents the format of the magic file as used by the file(1) command, version 4.17. The file command identifies the type of a file using, among other tests, a test for whether the file begins with a certain magic number. The file /usr/share/file/magic specifies what magic numbers are to be tested for, what message to print if a particular magic number is found, and additional information to extract from the file.

Then I added a new configuration entry to the Mantis configuration file: config_inc.php. This file is located at the root of the Mantis folder and can be edited by any text editors such as nano, pico or vi.

$g_fileinfo_magic_db_file = '/usr/share/file/magic'

Updating Magento code to be compatible with PHP 5.3

Even tough PHP 5.3 has been out for quite a while, there is still lots of old code out there that will not run correctly when moved from 5.2 to 5.3. In my case I had to move a 2 year old Magento website to a new server and ran into problems as the default version of PHP on the new server was setup as PHP 5.3. Altough PHP 5.3 is a “minor” version, there is quite a few “deprecated” core functions and severak little things that just dont work the same anymore. So in this post I will explain specifically what functions I had to update and a couple of examples of how I did it in each case.

Continue reading “Updating Magento code to be compatible with PHP 5.3”

Fix Mantis Captcha Image open_basedir Error

I recently installed the lastest version of Mantis Bug Tracker. Sadly when I tried to signup for the first time, the captcha used in the signup form didn’t show up. Opening the generated jpeg file reveals several errors related to my server’s PHP security settings.

SYSTEM WARNING: ‘file_exists(): open_basedir restriction in effect. File(/usr/share/fonts/corefonts/) is not within the allowed path(s)

mantis/core/utility_api.phpin utility_api.php’ line 253
mantis/core/utility_api.phputility_api.php’ line 255
mantis/core/utility_api.php line 257
mantis/make_captcha_img.php line 124

To fix the problem I added a fonts folder within my Mantis installation root, added the ARIAL.TTF font file inside that folder and then added a $g_system_font_folder variable to the mantis configuration file config_inc.php to point to the fonts folder.

Step by step guide

Continue reading “Fix Mantis Captcha Image open_basedir Error”

Netbeans Preparing Commit

If you ever tried to SVN commit a big project using Netbeans (Magento?) you have most likely seen that “Preparing Commit” message doing seemingly absolutely nothing for several minutes. Apparently the commit takes forever because Netbeans is scanning the entire projet to localize any changes done by external applications before committing. This is not really an issue in 99% of my usual work days thus I had to find a way to disable this.

Seems that adding

-J-Dnetbeans.subversion.commit.deepStatusRefresh=false

To he netbeans configuration file will disable the automatic scan during the commit preparation phase. If for whatever reason  you end up changing a file outside Netbeans (external text editor, adding new pictures…) you cam simply go to the “Files” tab and right-click your projet and hit “Refresh Folder” to let it scan everything.

See http://wiki.netbeans.org/FaqNetbeansConf for information on how to change the netbeans configuration file.