PHP 4.3.x And Really Large Files

Today I found out that PHP 4.3.x suffers from a problem, many scripting languages have: per default, it will work with file pointers that are 32 bit only, thus truncating the usable length of a file to 2 GByte. To fix this and allow for much larger files, you have to change the string used to configure the sources. Instead of

./configure <whatever options you use>

you’ll have to use

CFLAGS=”-D_FILE_OFFSET_BITS=64″ ./configure <whatever options you use>

Comes in handy when fixing up broken web server logs ;-)

Incoming search terms:

This entry was posted in Misc. Bookmark the permalink.

4 Responses to PHP 4.3.x And Really Large Files

  1. Or better: get rid of PHP ;-)

    SCNR,
    /k

  2. Well said. Now, I may just have overlooked it, but I’d like to hear about alternatives that aren’t affected by the very same problem ;-) PERL? Same problem. Python? Same problem. Shell scripts? Nah!

  3. Hmmm Python, ja.

    Uralt Python 2.1.3 auf FreeBSD (aus den Ports ohne Spezielle Options):

    Python 2.1.3 (#1, Mar 12 2003, 17:22:27)
    [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
    Type “copyright”, “credits” or “license” for more information.
    >>> fp = open(“test”,”w”)
    >>> fp.tell()
    0L

    Python 2.4 (Fink) auf OS 10.3.7:

    Python 2.4 (#1, Jan 21 2005, 01:34:54)
    [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> fp = open(“test”,”w”)
    >>> fp.tell()
    0L

    Python 2.3 auf OS 10.3.7 (Apple Originalversion):

    Python 2.3 (#1, Sep 13 2003, 00:49:11)
    [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> fp = open(“test”,”w”)
    >>> fp.tell()
    0L

    Wenn BFD Support da ist gibt tell() einen long int zurück (0L). Ohne BFD Support bekommt man einen einfachen int (0). Alle drei genannten Kompilate verfügen standardmäßig über BFD Support. Ehrlich gesagt, Deine Antwort hat mich das erste Mal seit Jahren darüber nachdenken lassen. In the Py-Welt setzt Du solche Dinge irgendwann einfach voraus — wir leben ja auchnicht mehr in den 70ern.

    Gruss,
    /k

  4. Jetzt wollte ich das gerade mal auf den Servern nachvollziehen, musste aber feststellen, dass da gar kein Python installiert ist ;-)

    Wobei: Selbst wenn, dann wäre es mir glaube ich schwer gefallen, meinen Kunden davon zu überzeugen, seine PHP-Applikation nochmal neu in Python zu erstellen. Mein Motto ist es eigentlich, Probleme zu lösen, nicht neue zu erzeugen.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>