Mike Gerwitz web developer and administrator of GNU/Linux systems, focusing on the development of online communities (e.g. MyCustomBB). Mike is also a freelance web developer and can be found on RentACoder, and is a strong supporter of free software.
Through the Eyes of a Web & Software Developer
15 May
Ubuntu 8.04 LTS was recently released. So I upgraded a couple of my computers (that I’m far too lazy and have no time to maintain Gentoo on) to this new release to find that my wireless PCMCIA card did not work on my laptop. Okay - that’s fine. I’ve had this problem since I began using Linux years ago. However, unlike the previous release, Hardy Heron didn’t seem to list the driver for it in the restricted drivers. Granted, you need an internet connection to download the drivers either way, it would have been nice for it to say “Hey, we’ve got you covered!” So I was worried that it was for some reason removed from this release.
So, for those of you who have this problem - start by plugging it into a wired connection and updating your repositories (sudo apt-get update). Then in System -> Administration -> Hardware Drivers, the driver for your wireless device should be listed. Simply install it and restart and you should be good to go.
1 May
Well; after several wasted hours looking into what I believed to be a bug within the PHP core, I have figured it out. I want to post this in the hope that you, the reader, do not have to go through the stress I went through in attempting to resolve this issue (and almost restorting to a standards-defiant workaround).
I speak of creating a stream wrapper (I’m creating the datapack wrapper for the MyCustomBB project). When you call ftell() on the handle to the stream, the PHP core calls the stream_tell() function within the class defined for that wrapper (in this case, datapack::stream_tell). However, PHP only seems to call this function after you use fseek() on your stream. Until then, it caches the file pointer position itself. Okay, seems reasonable. However, unless your stream_seek() function returns a value of TRUE (or any non-false value), PHP ignores the fact that the function was called, and continues to cache it itself.
Okay, so what’s the problem? If you check the PHP documentation for the fseek() function, you will see the following quote for the return value:
Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error.
Okay; to be complaint with this standard, my stream_seek() function returned a value of zero upon success, and -1 upon failure. Rather, it simply returned the value that was returned by fseek() (return fseek( $this->handle, $seek_pos);). However, 0 = FALSE. Therefore, PHP ignored it and would not call stream_tell() until I had stream_seek() return a value of TRUE upon success:
return ( fseek( $this->handle, $seek_pos ) == -1 ) ? FALSE : TRUE;
Then, it worked. You can imagine my irritation. However, in the PHP documentation, which I did overlook, it states that stream_seek() should indeed return TRUE on success. My bad, but very stupid of the PHP developers to do.
And just to think; I almost had to return the position via fseek() and use fseek( $handle, 0, SEEK_CUR ) in place of ftell().
Recent Comments