Adventures upgrading eZ Publish to 4.0.1

Some weeks ago we upgraded our CMS, eZ Publish, to the latest version in that moment, 4.0.1, with the intention of leaving behind PHP4 and switching to PHP5, the only one supported by the 4.x series. And although there is nice documentation about the process in ez.no, you’ll probably find some little problems which aren’t documented there.

With the aim of helping those who could have similar problems to mine, I’ll list and explain them a bit. 🙂

Switching to UTF-8

There’s a script to convert all the data in the DB to UTF-8, but when I tried it I found some problems; most of the data were corrupted after running it. In that moment, I found a related entry in eZ Publish bug tracker (#13674) where there was a patch which worked for me, but it very likely you won’t have this problem any more; the bug is closed and it says the patch has already been merged to stable (in fact, now the latest version is 4.0.3. These guys work really hard! 😉 ).

Moving templates to the correct place

Once the server was upgraded and running again, we noticed some template files weren’t rendered. I discovered that you have to place new template files in the directory design/plain/templates by imperative in eZ 4, but in previous versions you could place them in design/plain/override/templates although there wasn’t any override. I had a lot of auxiliary files stored in override which were original files, not overrides, so I had to move them.

For example, I have a template file show_comments.tpl which I include from news.tpl and article.tpl. I had it stored in design/plain/override/templates with the latter two files. But show_comments.tpl is, obviously, an original file, not overridden (there isn’t any entry in settings/override.php for it), so I had to move it to design/plain/templates, while news.tpl and article.tpl stay in the override directory.

So, if you made the same mistake as me when writing template files, now it’s the time to amend it 🙂 .

eZ Archive cronjob script not working anymore

We have the archive cronjob script installed in our server, with some customization, to move old content to an archive. After the upgrade it broke due to differences between eZ 3.x and eZ 4.x APIs. This was the error message:

Fatal error: Using $this when not in object context in /var/www/ez/kernel/classes/ezcontentobjecttreenode.php on line 1954

The solution is changing this line in the file extension/archive/cronjobs/archive.php:

39c39
<     $nodes =& eZContentObjectTreeNode::subTree( array( 'ClassFilterType' => 'include',
---
>     $nodes =& eZContentObjectTreeNode::subTreeByNodeIde( array( 'ClassFilterType' => 'include',

Image files don’t appear

Finally, a quite stupid mistake from my part: I just forgot to set the correct permissions to the eZ directory. Because of that, the program couldn’t write the temporary files it uses when resizing images and images in the page didn’t load. So remember your good friends chown and chmod.

Bonus: Online Editor v5

eZ Publish 4.1.0 adds some nice features, but it’s still in a beta state and we prefer a stable release in our server. Anyway, we’ve managed to install the latest Online Editor in the current version of eZ.

To do it, we just took the Online Editor files from the eZ Publish 4.1.0beta release (directory extension/ezoe), copied it to eZ 4.0.1 and activated the new extension modifying the file settings/override/site.ini.append.php:

< ActiveExtensions[]=ezhtml
> ActiveExtensions[]=ezoe

Depending on the rewrite rules you have in your apache server, you could have to make this small change:

< RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L]
> RewriteRule ^/var/[^/]+/cache/(texttoimage|public)/.* - [L]

Massive mail application in PHP

Since we have to to send e-mail notifications every now and then, I developed a small PHP page to build the e-mail and send it to all recipients individually, I mean, in a way that the To field doesn’t contain a huge list of e-mail addresses (doing that can be even illegal due to personal data protection laws, and is very ugly too ;)). The application grew and it currently does quite a bit of things, so I think it’s worth uploading its sources here.

What it does:

  • Sends mail individually, so each recipient doesn’t know the addresses of the other ones.
  • Parses the text in the To text entry, extracting only e-mail addresses.
  • Sends mail with plain text or HTML.
  • Can attach files.
  • Can attach an image in the body of the e-mail.

What it doesn’t do (because I didn’t care when I wrote it :P):

  • It doesn’t support concurrency; if two people use the application at once, the attached files are mixed.
  • The attached files aren’t deleted automatically after sending the e-mail, but there’s a button to do it manually.
  • The on-screen texts are only in Spanish, and they aren’t i18n-able.

Download the files: Massive mail application in PHP.

PS: I forgot! You’ll need the library PHP Mailer. Download and install it in your web server together with this application.

Passage: a little surprise in intrepid repositories

Last week I was installing the latest Ubuntu (8.10 so far, time flies…) in a computer, for a relative of mine. Once I had finished, I took a look into the gnome-app-install application to look for new programs, and I was happy to found Passage in the games section. I knew about this game about a year ago; sources are available in the web page, as well as binaries for Windows and MacOS X, but I hadn’t found a user-friendly way (I mean, packages :P) to install it in GNU/Linux before.

Passage screenshot

Passage is a game about the flow of life and death. I think that it was born with the aim of demonstrating how a videogame can also be a work of art, in a classic way. Its graphics have the symbolism of a painting (built of huge pixels, of course), its gameplay has hidden meanings, just like poetry, and its crappy 8-bit music will stay in your head for ages. When the game ends and the screen fades off you stay for some seconds looking at that black screen, silent, shocked. I personally felt some kind of anxiety, and sadness.
I don’t want to reveal all the content of the game, so I recommend you to give it a try. A game lasts only five minutes, and installing it takes even less. After that, if you’re interested, you can read the creator’s statement to know everything he wanted to say in this game, and compare it with your ideas. Until I read it I couldn’t figure out why the punctuation system works as it does :S .
But at the end, I have noticed a curious contradiction: Passage is a game, but it isn’t fun. It’s all about feelings: you can play it once or twice, for some minutes, to try it and feel what it has to communicate. But, at the end, you won’t play it anymore. Don’t misunderstand me; it’s art, I have no doubt; but for me, Super Mario Bros. is also art for different reasons; and I still play with it every now and then 😉 .

A javascript calendar in your eZ Publish page

If you maintain a web site built on eZ Publish 3.x, maybe you miss having a calendar on your side bar, where you could mark special events on. Or at least, I did, so I searched a bit and read that a calendar was included in ezwebin, the new design that comes with eZ Publish 3.9. Unfortunately, its integration in an older eZ site looked like pain for me, but I found an alternative, a contribution called ezAgenda. It features a datatype to store events, and some templates to build a calendar and show events over it.

ezAgenda screenshot

I took its code and adapted it to my needs. In particular, I wanted the calendar to be integrated in a side bar, and show the name of the events in a pop-up when the mouse is over it. Something like this:

JS calendar screenshot

There are some other changes and improvements, which are explained in the readme file. You will also find there the installation instructions (basically, you have to place the files, create the datatype and add the overrides to activate the templates).

Download the files: agenda.tar

Plugins for WordPress-MU: ‘List all’ and ‘Recent Posts’

WordPress-MU is an official modification for WordPress able to manage multiple blogs with a single installation. I have used it to set up a platform for school newspapers, supported by the Council of Coruña.

I use the main page of the system as a summary of all the newspapers, showing the active blogs and the latest news produced on them. For that subject I found two useful plugins: List all and Most recent posts. As their name states, the first one lists the public blogs of the system and the second one extracts the latest news.

I needed a more complex behavior from them, so I made some modifications. Basically, I replaced the two parameters that wrapped the list with a format string as used in printf-like functions. Now the user can control all the content inside the list item, not only the beginning and the end.

Here are the files. Hope they’re useful for someone!