Friday, February 29, 2008

Using Git with eZ Publish projects

In my spare time I've been hanging out with a bunch of Ruby/Rails people. They are a fun bunch however they don't seem to like it when you point out that MVC existed well before Rails. One thing that have put me onto is Git.

Git is a distributed revision control / software configuration management project. You may have heard of it, Linus Torvalds (that clever guy behind Linux) wrote it to manage kernel development. There is plenty to read about it on Wikipedia

So why Git?

This week I've been working on an eZ Publish 4.0 project that needed the ezApprove2 workflow extension. The version in the contribs says it has 3.7 support...the eZ projects site says it work with 4.0 except in the subversion repository on the projects site!

So I check it out svn co to investigate if it meets the requirements.

As part of this process I notice some bugs and being a good open source user I fix them, however I can't commit them back to the repository as I'm not a member of the project (I've applied). I've got other things to do and probably won't remember to commit the changes when and if my membership is approved. I've posted most the the patches to the forums in case anyone is looking at using it.

Git allows for distributed revision control, effectively I can have a local repository and make local commits. git-svn also allows for the sync a local git repository with a subversion one.

Here is what I've done so far...I'm new to this so any git experts out there I'm happy to hear any pointers from you!

Install git

I use kubuntu so installation was pretty painless
sudo apt-get install git-core git-svn git-gui

Create a directory for the repository

$ cd /var/www/ezpublish-4.0.0/extension/
$ mkdir ezapprove2
$ cd ezapprove2

Find the revision I want to check out from the subversion repository

$ svn log | head
r2500 | tw | 2008-01-15 02:15:14 +1000 (Tue, 15 Jan 2008) | 1 line

- Fixed missing static in ezinfo.php
r2487 | tw | 2008-01-12 01:02:47 +1000 (Sat, 12 Jan 2008) | 1 line

- Added eZ Approve 2 for eZ Publish 4 (PHP5 port)

Initialise the git repository

$ git svn init
Initialized empty Git repository in .git/

Check out the revision I want from subversion

$ git-svn fetch -r2500
A sql/mysql/schema.sql
A ezinfo.php
A settings/module.ini.append.php
A settings/collaboration.ini.append.php
A settings/design.ini.append.php
A settings/extendedattributefilter.ini.append.php
A settings/workflow.ini.append.php
A settings/ezapprove2.ini.append.php
A settings/site.ini.append.php
A translations/ger-DE/translation.ts
A translations/nor-NO/translation.ts
A doc/upgrade/UPGRADE_0.1-0.2
A doc/upgrade/UPGRADE_0.2-0.3
A doc/upgrade/UPGRADE_0.3-0.4
A doc/upgrade/UPGRADE_0.4-0.5
A doc/upgrade/UPGRADE_0.5-0.6
A doc/upgrade/UPGRADE_0.6-0.7
A doc/upgrade/UPGRADE_0.7-0.8
A doc/changelogs/CHANGELOG_0.1-0.2
A doc/changelogs/CHANGELOG_0.2-0.3
A doc/changelogs/CHANGELOG_0.3-0.4
A doc/changelogs/CHANGELOG_0.4-0.5
A doc/changelogs/CHANGELOG_0.5-0.6
A doc/changelogs/CHANGELOG_0.6-0.7
A doc/changelogs/CHANGELOG_0.7-0.8
A eventtypes/event/ezapprove2/ezapprove2type.php
A collaboration/ezapprove2/ezapprove2collaborationhandler.php
A modules/ezapprove2/ezapprovefunctioncollection.php
A modules/ezapprove2/function_definition.php
A modules/ezapprove2/select_approver.php
A modules/ezapprove2/view_approve_list.php
A modules/ezapprove2/module.php
A modules/ezapprove2/add_approver.php
A design/standard/templates/notification/handler/ezcollaboration/view/ezapprove2/author.tpl
A design/standard/templates/notification/handler/ezcollaboration/view/ezapprove2/approve.tpl
A design/standard/templates/collaboration/handlers/view/full/ezapprove2.tpl
A design/standard/templates/collaboration/handlers/view/line/ezapprove2.tpl
A design/standard/templates/collaboration/message/view/element/ezapprove2_comment.tpl
A design/standard/templates/workflow/eventtype/edit/event_ezapprove2.tpl
A design/standard/templates/workflow/eventtype/view/event_ezapprove2.tpl
A design/standard/templates/workflow/eventtype/ezapprove2/view_approve_list.tpl
A design/standard/templates/workflow/eventtype/ezapprove2/add_approver.tpl
A design/standard/templates/workflow/eventtype/ezapprove2/select_approver.tpl
A classes/ezapprove2event.php
A classes/ezapproveextendedfilter.php
A classes/ezxapprovestatususerlink.php
A classes/ezxapprovestatus.php
r2500 = 2528a77b6478e87833cc59e376965dbc03b5d775 (git-svn)

Checked out HEAD: r2500

Now I want to create a local branch so I can distinguish which are my changes

$ git status
# On branch master
nothing to commit (working directory clean)
$ git checkout -b code_review
Switched to a new branch "code_review"
$ git status
# On branch code_review
nothing to commit (working directory clean)

Now I can fix the bugs add new files and commit locally

There was an issue in the default node plain view template which is used by the collaboration preview. To fix this I added a file ( design/standard/templates/node/view/plain.tpl ) to the extension that fixes the issue.

$ mkdir -p design/standard/templates/node/view
$ vi design/standard/templates/node/view/plain.tpl
$ git status
# On branch code_review
# Untracked files:
# (use "git add >file<..." to include in what will be committed)
# design/standard/templates/node/
nothing added to commit but untracked files present (use "git add" to track)

Like with subversion I had to add the new directory before I can make the commit to the git repository.

$ git add design/standard/templates/node
$ git status
# On branch code_review
# Changes to be committed:
# (use "git reset HEAD >file<..." to unstage)
# new file: design/standard/templates/node/view/plain.tpl
$ git commit -m'fixed "Placed in:" for items previously unpublished' design/standard/templates/node/view/plain.tpl
Created commit 0cc675c: fixed "Placed in:" for items previously unpublished
1 files changed, 45 insertions(+), 0 deletions(-)
create mode 100644 design/standard/templates/node/view/plain.tpl

So now we have made the change and have a local commit. I can go ahead and fix the bugs that I find, making local commits as I go. I can see the changes by checking the git log.

$ git log
commit e910175452f6d9b43331798926628e7bf0528d5c
Author: Bruce Morrison
Date: Fri Feb 29 16:42:57 2008 +1000

fixed "Placed in:" for items previously unpublished

commit d4f3036b90377b8c69d84dacaafff8e50680d61c
Author: Bruce Morrison
Date: Fri Feb 29 14:20:28 2008 +1000

Typo in const

commit cb0f79dc7da4ac86288c1c9e1fa06202b39c5ff1
Author: Bruce Morrison
Date: Fri Feb 29 14:19:44 2008 +1000

Fix for placement of a previously unpublished object that is edited

commit 842c439ce9ebe5f987c7807bf1d394306eafe681
Author: Bruce Morrison
Date: Fri Feb 29 14:17:31 2008 +1000

Fixed method definitions to match eZCollaborationItemHandler to stop strict messages

commit 4d7e93900c54feb7d91fb3d42cf94112aa3b7cbc
Author: Bruce Morrison
Date: Fri Feb 29 14:09:24 2008 +1000

Corrected typo in const

commit 2528a77b6478e87833cc59e376965dbc03b5d775
Author: tw
Date: Mon Jan 14 16:15:14 2008 +0000

- Fixed missing static in ezinfo.php

git-svn-id: b9bbbbba-8235-4206-939b-838bdeb4db37

If I'm granted write access to the subversion repository I can simply run

$ git-svn dcommit

and each local commit is transformed into an svn one.

I can update my working copy from the svn repository by running

$ git-svn rebase

Not only can I make local commits I can do so offline, syncing the changes when I have access to the repository.

The following sites greatly assisted this process:

Tuesday, February 26, 2008

New rating extension for eZ Publish

I've just uploaded a rating module to the contribution section on the eZ site. The Star Rating module introduces a datatype that can be added to any content classes to allow it to be rated. While I haven't checked the datatype has been designed so it should be possible to add multiple ratings to a single content class.

The extension has been designed with accessibility in mind and will function without javascript, images or CSS.

The catalyst for the extension was CSS star rating from Komodo Media and the extension contains CSS and images from this project.

To add some web 2.0 goodness, if the xajax extension is enabled and the user has access ratings will be done via ajax calls. The xajax component requires newer versions (0.5+) of the xajax library so it must be downloaded from the projects site an not from the contributions section of the eZ site.

View caching & dynamic content

One of the issues I came across is that by making the rating a datatype, is that the display gets "captured" in the view cache. This is not not good for a dynamic component. To prevent caching I tried setting the cache_ttl to zero in the datatype view, however this has no effect. It appears that this template setting only works when used in a view template...something to investigate.

An earlier strategy was to clear the view cache after each "vote" and while this works to some extent it fails with anonymous users. View caches are based on the user viewing the node, and because all non logged in users share the special anonymous user they also share the view caches. Once one anonymous user voted the page would be updated with the results and the voting disabled, however the next anonymous user to visit the page would see the cached page containing the result and be unable to vote.

A worthy addition to the eZ template system would be the ability to designate a block in any template as being dynamic and not cached.

The TODO list

Currently the TODO list stands at
  • Fetch most rated objects;
  • Set max rating in datatype (class or content?);
  • Ability to clear ratings from datatype;
  • Stats - An admin view of voting that displays an over view of the rated content. Allow filtering/ sorting by content type;
  • Options for vote uniqueness - currently per session only. This covers both Anonymous & logged in users. Could make it based on user_id or session so that logged in users can only vote once;
  • Ability to limit voting to logged in user;
  • Log IP addresses and add this in the mix of unique voting.
I'm not sure how quickly I'll get to these items, however the fetching of top rated items will be first cab off the rank.

If you find the extension useful, have any comments, or suggestions let me know via comments. Also if you use it in a public site drop me a line. Also nice to seeing ones creations in the wild!

eZ Publish xajax extension upgraded

Recently I've been playing about on the eZ Publish projects site
and have joined a couple of projects. One that I've previously has some involvement in is Kristof's xajax plugin.

I quite like xajax as it's takes care of most of the javascript and allows you to manipulate the browser DOM via PHP.

I've joined the project as a member, updated the xajax libraries to 0.5 beta 4 ( they were on beta 2) and created a download.

Initially I was going to upgrade the extension to work with eZ 4.0, however there was nothing to do. It works fine in eZ 4.0 and my changes are simply an upgrade to the xajax library.

Given the extension basically exposes the xajax libraries and is unlikely to change too much I wonder it it's worth linking the version of the extension to the xajax library version?

Happy xajaxing!

Friday, February 15, 2008

Is eZ Publish 4.0 like Microsoft Vista?

Disclaimers usually go at the bottom of a post but because this one is quite lengthy I've decided to put it at the top. Mostly the stuff I post here is of a technical nature, but this time I'm posting an option piece, and as such it is full of wild speculation, personal thoughts, suggestions and of course opinion, all of which may have no basis in any reality other than my own.

You are here - the current state of play

I've been using eZPublish 4.0 since the beginning of the year. It's not quite what I envisioned when the rumbling of version 4.0 first started, oh so long ago, actually it's nothing like what I imagined.

Hence the title of this post. Initially Vista (Longhorn) was slated as a "minor step" between Windows XP (Whistler) and Blackcomb. However it gradually took on many of the features slated for Blackcomb. People got excited, but it's release was delayed several times, the developers were given other priorities and finally development started afresh based on Windows 2003 server and a limited feature set.[1] When finally released the general consensus seems to be one of disappointment or at least significantly underwhelmed.

Over time there has been quite a bit of excitement of what a new version of our favourite CMS might provide. Given the quantum leap in functionality between eZ Publish 2.0 and 3.0 who knew what unimaginable ecstasy version 4.0 would bring! However time marched on, PHP4 end of life was announced and eZ Publish 4.0 became a port of eZ 3 to PHP5 (continuing the community effort by Paul and Kristof).

Now this is not a bad thing, on the contrary it's the best thing that happened to eZ Publish in recent times (including the Online Editor in the distribution would be a close second).

At the local PHP meetup I would get strange looks because I was still using PHP4. I could get people excited about eZ Publish but people soon lost interest when told that it required PHP4 and a specific version at that. No matter how good the product sounded it's was hard to get people interested about something that had "special requirements". "None of the other PHP CMS have those requirements" was the standard response. It was impossible to get a foot in the door. Hopefully now with PHP5 support more people will be willing to try eZ Publish.

PHP5 support also makes it easier to get eZ Publish into corporate environments. RedHat seems to be the Linux distribution of choice in the corporate world (at least here in Australia) and it's lack of support for php4.4 has meant that in situations where we were the "application provider" we either had to convince the systems people to install the newer unsupported (by RedHat) version of PHP or do it ourselves. Of course this just created a bunch of issues around support (of the custom PHP) and called into question the choice of eZ Publish as a CMS platform.

Oh yeah, eZ runs faster under PHP5 as well!

Three cheers for eZ4.0 on PHP5!

eZ Components to the rescue

I spend much of my time working with eZ Publish as a framework by coding extensions that merge existing data sources into a CMS managed environment as well as creating fully fledged applications that run parallel to the CMS. When I learned of the eZ Components project and that it would from the basis of the new eZ Publish version I was very happy.

There are a bunch of subsystems in the current version of eZ Publish that are tightly coupled with the main content module that makes them pretty difficult to reuse in custom modules. Two that come to mind are the Image system and the Rich Text/XML Block Datatype. It seems such a waste that these subsystems can't easily be reused outside of the content module.

From what I've seen of the eZ Components they will solve these type of issues. They will form the building blocks on which future versions of eZ publish are built. From what I can tell current version of eZ doesn't utilise components at all, although some of the components features have made their way into the eZ publish libraries. (Of course running under PHP5 allows the use of components in extensions).

New versions

Yesterday I was alerted to an update to the eZ Publish roadmap by a posting from Ɓukasz (eZ Fourm Guru) Serwatka. (I don't understand why eZ aren't talking about this themselves?)

The roadmap has the next point release, 4.1 (focusing on a new Online editor with support for IE7 for Vista) happening in Q1 2008. Given we are about half way through February that makes it due somewhere in the next month and a half.

Of more interest to me was version 4.5, with the focus points highlighting the integration of a new template & workflow engine based on eZ Components.

With a tentative release date of "Summer 2008" one would speculate that it is planned to be launched at the Summer conference. (Assuming that "Summer 2008" refers to a northern hemisphere summer, because we've in the middle of Summer, here down under. Come on eZ people, you're global!)

I do wonder what "Support for more runtime platforms" refers to?

Better, Faster, Shinyer or a Monster?

In terms of version numbers I'd like to see the version that incorporates eZ Components go up a major revision number and become eZ 5.0. This would signify the gravity of the change. We are not talking about some bug fixes and enhancements here, but replacing major components.

I'd even go so far to suggest that eZ4.0 goes into maintenance mode (feature freeze, whatever you want to call it) and eZ5.0 is written from scratch, built on eZ Components. I fear an eZ Publish that has it's underlying systems replaced bit by bit with eZ Component versions will quickly start to resemble a Frankenstein's monster.

The current system has been through ten major revisions and countless minor ones and is quite stable. I suspect there be teething problems if not major pain (but as the saying goes "no pain no gain") for many with this change. And of course the entire admin and various default user interface will have to be rewritten for to work with the new template syntax.

I suspect that given the current templating system is tied to the caching and translation systems (part of eZ Components 2008.1) that we'll also see those replaced with eZ Components ones as well.

Also of interest was Derick's post earlier this month about the eZ components 2008.1 roadmap. The majority of the listed new component and enhancements appear to have a specific eZ publish focus. These have tentative alpha & beta release dates in May 2008. This would make a tight squeeze if eZ 4.5 (eZ Components) was to utilise this eZ Components release. Does this mean that eZ 4.5 would not have Translation & Character set support?

So what do you think?
Is eZ publish 4.0 like Vista?
Do you want to see an eZ publish that is half components or a ground up rebuild?
Do you care? ;)

[1] Paraphrased from:

Friday, February 01, 2008

eZMail Debug updated for eZ publish 4.0.0

I realise that with the newish (introduced in version 3.9) "file" mail transport option can be used to debug mail, but in some cases it's easier if the system actually sends the mail (to me and not the intended precipitant). So I've updated the subversion repository of Kristof Coomans' eZMail Debug patch to work with eZ Publish 4.0.0

To use, simply download the patched ezmail.php from
and save it to lib/ezutils/classes/ezmail.php of your eZ Publish 4.0.0 install.

Remember that if you are using SMTP transport..."Due to a bug in eZ Publish 4.0.0, you need to download the updated version of the "ezsmtp" class and replace the corresponding file in your installation in order to use an SMTP relay server for mail delivery. This bug will be fixed in the upcoming eZ Publish 4.0.1 release." (From )