Jan 29, 2010

No thumbnails in TYPO3? Check ImageMagick!

I upgraded my server to a newer version of Linux in December. Today I suddenly noticed that I see "No image generated" yellow banner across all images in the TYPO3 backend.
Normal steps in such cases would be to go and check ImageMagick installation using the TYPO3 Install tool:


Jan 21, 2010

How to repair a broken YaST online update in SuSE 11.2

One of the last YaST2-ncurses packages renders YaST2 online update and software management in SuSE Linux 11.2 unusable. Online update just exists back into the menu. If you want to fix it, follow these instructions:

  • Mount your install DVD. In my case it looks like:
    mkdir /mnt.dist
    mount -o loop /mnt/distro/opensuse-11.2-x86_64.iso /mnt/dist
  • Change path to RPM packages location. In my case:
    cd /mnt/dist/suse/x86_64
  • Restore original packages. In my case:
    rpm -Uvh --force yast2-ncurses-pkg-2.18.4-2.9.x86_64.rpm
    rpm -Uvh --force yast2-ncurses-2.18.10-2.1.x86_64.rpm

That's all. Now you can use online update. It will propose you yast2-ncurses fix, which you should install.

Avoid your personal "Aurora operation"

I am not a Microsoft Windows user. I was quite indifferent to the latest Microsoft Internet Explorer scandal that causes break in to Google, Adobe and many other major companies (the “Aurora operation”). However posts and articles about this event pop up so often, that they are very hard to ignore.
Yesterday I read a phrase that made me think a lot about the way how we develop software. The source was not in English and it is hard to make a precise translation. The phrase sounds like this: “Software will be always vulnerable while it is written by humans”.
Why did this phrase caught me? For several reasons.
Firsts, I immediately remembered many extensions that I saw in the past with trivial security problems. It is so easy to avoid them and yet people still write it insecurely.

Jan 18, 2010

Using XDebug helper plugin with FireFox 3.5.7

Recently my FireFox automatically updated itself and disabled XDebug helper plugin, which I use to debug PHP scripts with Komodo IDE. While it is possible to start debugging by adding XDEBUG_START_DEBUG=1 to the URL, it is not very convenient when debugging such framed applications as TYPO3 Backend.

There is no update for this plugin. Even worse: it is disappeared from the list of FireFox plugins. Fortunately I have it locally and managed to cheat FireFox to recognize this plugin as valid.

It is quite simple. Firsts, you need to shutdown FireFox. Next you need to go to the extensions/ subdirectory of your FireFox profile. On Mac it is in ~/Library/Application Support/Firefox/Profiles/ff3.default. In the extensions/ you will see xdebughelper@mail.ru and install.rdf inside it. Open this file in the text editor. You need to change two values there:

  • set em:maxVersion to 3.*
  • increase em:version

Start FireFox and you have XDebug icons in FireFox again!

Jan 6, 2010

Komodo IDE, XDebug and superglobals

If you, like me, prefer Komodo IDE for PHP development, you may have noticed that superglobals ($_GET, $_POST, etc) are absent from "Superglobals" tab in debug window. If you have this problem, update to the latest PECL version of XDebug:
sudo pecl update xdebug
Superglobal will magically appear. Do not forget to restart Apache:
sudo apachectl restart

Jan 4, 2010

Extracting text from HTML body

Do you know how to extract text from the HTML <body> tag with one regular expression? Here it is:
function extractBody($htmlContent) {
    $result = '';
    $regExp = '/.*<body[^>]*>(.*)<\/body>.*/is';
    if (preg_match($regExp, $htmlContent)) {
       $result = trim(preg_replace($regExp, '\1', $htmlContent));
    }
    return $result;
}
Note that you have to use "i" and "s" modifiers, otherwise this regular expression will not work in all cases. "i" modifier helps to detected <body> tag in mixed or upper case. "s" modifier forces regular expression to work correctly with new line characters.

Small performance enhancement tip

Do you have your own server? Does TYPO3 run slow? Would you like to try a simple step to improve the speed? Here it is.
Check if you have NSCD installed. NSCD is a caching daemon for DNS lookups. Even if you have HostnameLookups off in the Apache configuration, Apache still does look ups from time to time for internal reasons. If you do not have NSCD, it may take lots of seconds (especially if host does not exist). With properly configured NSCD it will be much faster.
Here is my NSCD configuration regarding DNS lookups: