Archive for November, 2007

Zend platform

November 29, 2007

Had a look at the Zend platform’s demo videos today. Here’s the main gist of what it does:

  • improves performance through code acceleration, caching of dynamic pages and output compression
  • keeps track of events (such as php errors and, interestingly, slow-running scripts) that occur in your code, alerts you about them if you like, and allows you to debug files that are causing them – you can actually find the line that’s triggering the event, and then run the script in debug mode in your copy of Zend studio
  • some other enterprise-level things, like allowing you to cluster sessions across servers, serve downloads without using the webserver, queue long-running processes and produce reports

At first I was sceptical – you can do the same thing, performance-wise, by installing a code accelerator, using Pear’s Cache_Lite for caching and ob_gzhandler to compress your output. And if you’re testing your applications well you shouldn’t be getting php errors

… but of course most applications aren’t written from scratch. I spend most of my time working on applications containing code contributions from any number of people, and because I don’t necessarily know the code inside out I can miss code paths that might cause errors. And wouldn’t it be nice to have an automated process compress everything for you, and find slow scripts for you and allow you to cache them – all without going near the source code? It would. I think I’ll investigate their pricing.

Image upload and resize problems

November 28, 2007

Came across a problem in an application where 6 large photos were being uploaded and resized simultaneously. I suspected it was a memory problem, as it’s been working fine for a long time. I increased  upload_max_filesize in php.ini, which half-worked – I could now upload 2 large images, but not 6 like I needed to. Turned out I needed to increased post_max_size too (again in php.ini).

Note that if upload_max_filesize is exceeded then [‘tmp_name’] fields in $_FILES will be blank.

One other thing worth mentioning that I came across when working on the same application a while ago is I found I also had to increase memory_limit (in php.ini) way beyond its default to allow php enough memory to resize big image files.

How elgg works

November 23, 2007

Ok I’ve finished with elgg now, and I managed to get it do everything I needed to do. Although it is quite a good system from the perspective of its functionality, my previous criticisms of the code still stand – functionality and display aren’t separated as well as they might be, and the general structure of the code is a little obscure. Another demonstration that MVC is very hard to beat when it comes to web applications.

That’s not to say you shouldn’t use it, of course, like I said it’s doing what I need now. Here’s some information on the structure of it that might be helpful if you’re using it:

  • “modules” are in /mod/ … it’s hard to know exactly is meant by a module, because there’s a profile/ directory in /mod/ but also in /units/, and also there’s a /profile/ directory … but anyway, each module is initialised by a function called <modulename>_pagesetup() in /mod/<modulename>/index.php
  • Menus are stored in $PAGE. The main menu is intialised in /lib/displaylib.php, and added to in the initialisations of individual modules (in the <modulename>_pagesetup() functions)
  • Lots of the functionality is executed by a function called run() in /units/engine/library.php … this works by including particular files (indicated by the function params) whose filenames are contained in the array $function which is populated by the <modulename>_pagesetup() functions. If you want to see the code called by run(“search:display”) just do a full-project search for $function[‘search:display’][] and see what file it refers to.

Note that the code doesn’t stick to the php convention of capitalising constants, and be sure and use an IDE with “search all files” and “go to declaration”, you’ll get lost if you’re just using notepad or vi

Local version of a site not working

November 20, 2007

Was putting a local version of a (joomla) site on a laptop yesterday for a customer, and it just wouldn’t work. I scratched my head for hours, and finally discovered that short_open_tag was off (i.e. short_open_tag = Off in php.ini) – which meant that any code enclosed with <? ?> or <?= ?> was just sent to the browser rather than parsed as php. Turned on short_open_tag and hey presto it worked

I had just downloaded and installed the latest version wamp server (5.1.7.4), so short_open_tag must be off by default when you install it – something to watch out for.

Joomla – this site is temporaily unavailable

November 20, 2007

“This site is temporarily unavailable. Please notify the System Administrator”

Got this message out of the blue last night on a joomla site. At first I thought the site had been deliberately taken offline, but the offline error message is different, this is a “system error” message. Tracked the problem down to includes/database.php – the application was unable to connect to the database. Checked configuration.php, and it seemed fine, so I echoed the output from mysql_error() and got ” Could not connect Host ‘xxxxx’ is blocked because of many connection errors. Unblock with ‘mysqladmin flush-hosts'”.

So I ssh-ed into the server and typed “mysqladmin flush-hosts” and everything worked again. According to spikesource.com this is what happened:

This means that mysqld has gotten a lot of connect requests from the host `hostname’ that have been interrupted in the middle. After max_connect_errors failed requests, mysqld assumes that something is wrong (like an attack from a cracker), and blocks the site from further connections until someone executes the command mysqladmin flush-hosts.

Didn’t win that award

November 16, 2007

Boo

At the event they had little video pieces they had taken of the shortlistees on a loop showing up on the big screen at the back, with quotes in text beside it. Everyone else was very stationary and serious, whereas I was throwing back my head and laughing, moving out of the frame, wiggling my eyebrows, and my quote said “it’s great for my mother to have something to tell my aunts, all my cousins are such high achievers”.

I must try not to appear like such a nut in public

iia net visionary awards tonight

November 15, 2007

I’ve been shortlisted for a “Web developer excellence” award at the Irish Internet Association awards, and they’re on tonight. Would be very lucky to win it, the agency I work for is a relatively small fish … we’ll see anyway, it’s a nice feather in my cap to be shortlisted anyway.

iia net visionary awards shortlistee badge

And here’s another thing

November 13, 2007

When you’re writing a complicated php application, please don’t have links all leading to different <somethings>/index.php – if you do, it’ll mean that some poor coder will have about 18 index.php files open in his IDE and will have to click through them all to find the one he wants

More on elgg

November 13, 2007

Oh dear, elgg is turning out to be quite hard to manipulate. Display and functionality aren’t as well separated as they might be, and the structure of the code is hard to figure out. I know, I know, it’s very hard to construct code in such a way as to be instantly figurable-outable – I’m not sniping at the developers, I’m just under pressure and struggling

For example, the “search” form that appears by default up in the top left isnt’ really suitable for using in the main content of a page, which is what I want. I tried to use the “browser” page instead, but there’s a inner join in the sql between the friends and the users table which means only users with friends are displayed. Crap. I was hoping this would be easier

The 100% Easy-2-Read Standard

November 12, 2007

Came across this page today, it’s about putting ease-of-reading foremost in web design. It’s kinda self-evident to me, now I think about it, as a programmer I’ve always been fairly take-it-or-leave-it about the design end of things, though at times along the way I’ve become dazzled by cool-looking sites – who hasn’t? This is a well-written article though, will give you mental ballast to prevent a designer colleague sweeping you away with their beautiful images

http://www.informationarchitects.jp/100e2r