Showing posts with label MySource4. Show all posts
Showing posts with label MySource4. Show all posts

Wednesday, 17 December 2008

PHPUnit training at Squiz

Sebastian Bergmann was in Sydney last week and I took the opportunity to have him come in and do a day of PHPUnit training for the developers at Squiz. We also went through continuous integration software like phpUnderControl and Bamboo.

It was great to finally meet Sebastian and learn a lot about the tools we will be using in MySource4 to ensure the quality of our product.

If you are thinking of some in-house PHP training, Sebastian is great tutor on all things testing and comes pre-loaded with some funny and informative stories about his travels and PHP development in general.

Sunday, 5 October 2008

MySource Mini at the MMIUC 2008

I've been really quiet on this blog for a few months, and have even let some PHP_CodeSniffer bug reports go unfixed for several weeks. That's pretty unusual for me, but I've been both sick and very focused on the MySource Mini that will be presented at the MySource Matrix International User Conference 2008 in less than 2 weeks!

I can't say much about the Mini, but now that the agenda has been posted, I can at least use the name and confirm it has something to do with MySource4, which I've been babbling about on this blog for a while now.

I've gone a bit quiet about parts of MySource4 that we have been working on, but not because they are any less amazing than the features I have spoken about. Apart from our custom-built true inline WYSIWYG editor that I demonstrated last year, I'll be showing the caching system I've mentioned before, a versioning system to replace rollback that I've had to stop myself blogging about so I don't give away its secrets, and the most amazing context sensitive help system I've ever seen in any application. There will also be some systems available for conference attendees to play around with, and the whole MySource4 team (development, interface and documentation) will be there to answer all your questions.

Want to come along? Register here.

Monday, 4 February 2008

PHP_CodeSniffer 1.0.1 released

I've just uploaded PHP_CodeSniffer version 1.0.1, which contains 6 bug fixes and adds some new sniffs into the Squiz and MySource standards after some lobbying by the MySource4 team. The coding standard we use for MySource4 now has 94 different sniffs, each containing up to 5 different checks, so it is getting fairly strict. The code should be pretty enough to frame and stick on your wall!

One important change has been made to the PEAR standard in this release. A recent RFC that asked PEAR developers to vote on forcing protected member vars to be prefixed with an underscore got me looking for the relevant sniff in PHP_CodeSniffer. (I didn't see the call for votes, but I would have voted not to prefix protected vars with an underscore.) While PEAR decided against adding this new standard, I did realise that PHP_CodeSniffer was not currently enforcing the existing standard. The 1.0.1 release adds a new sniff to the PEAR standard to ensure only private members vars are prefixed with an underscore.

You can view the full changelog, and download the release, on the package download page.

Thursday, 17 January 2008

MySource4 caching and keywords - I think I'm in love!

Sometimes things just fall into place.

When designing the sub-systems for MySource4, even when designing seemingly basic copies of MySource Matrix functionality, I often find myself surprised by the way we've managed to make slight design changes (often forced by the MySource4 architecture) but come out with systems that are significantly better than they are in MySource Matrix. Sometimes, design decisions made months ago suddenly start to pay off in ways I don't expect. The caching and keyword systems are a perfect example; they are a match made in heaven and I'm deeply in love with both of them!

Caching was to be a fairly simple copy of the MySource Matrix caching system. One of the strengths of MySource4 is the ability to replace core systems (like caching) with a system that is better designed for a site's specific needs. Knowing this, we started thinking about a basic caching system that Matrix users could migrate to easily, with plans to write other caching systems and allow users to pick the one they wanted. What we ended up with is something I am very proud of. Not only because of the feature set, but also because of the way it fits so nicely into my MySource4 vision. This is why we designed MySource4 like we did, and it is really starting to pay off.

The MySource4 caching system is made possible by a simple but critical change to the way content is printed. In MySource Matrix, each asset type and design area grabs attribute values from the database and prints them when required. When designing the keyword system (very early on) we made a decision to always print keywords rather than real values. So instead of a menu printing asset names and links, it would print keywords that would later be replaced by the keyword system. This provides two immediate benefits; assets and design areas take less time to print and keywords can be batch replaced in a page. Both those are performance-based, but now that decision has enabled us to make a fantastic caching system.

By utilising the MySource4 channels architecture, the caching system is able to hook into the frontend painting code and cache a copy of the page after static keywords have been replaced and before dynamic keywords have been replaced. Dynamic keywords are things like the contents of a custom form or the name of the current user, and should not be cached. The next time around, the caching system can serve up a copy of the page with just the dynamic keywords left to be replaced. Note that this is a full page cache, unlike Matrix which constructs the page each time using small cache blocks. That means that the MySource4 caching system is already faster than the MySource Matrix caching system and we haven't even got to the bonus features!

One of the biggest problems with the Matrix caching system is that we can never really know which assets are cached on which URLs. For example, we know that the name of the "Contact Us" page has changed but we have no idea which asset listings to clear the cache of or which pages have the old page name in the menu. We can't know this in Matrix because we don't have a consistent way of printing data. That is solved in MySource4 because the keyword system forces us to print keywords rather than real data. The result is that the MySource4 caching system knows exactly which URLs the name of the "Contact Us" page appears on and it can clear them for you.

That is a very powerful feature. You can now go to any asset and see exactly what parts of the asset have been cached and which URLs they are cached on. You can make an informed decision about clearing the cache; do you really want to clear 400 URLs because the name of the "Home Page" has changed?

We also have some other statistics that we are trying to decide how to use best. We know how many times a page's cache has been served and how many times it was generated (cache hits and misses). We also know how long each page generation took (on average), the static keywords used on the page and the dynamic keywords used.

We can obviously calculate how much time was saved by the caching of a page by looking at the hits and misses. That is a nice figure to have available, but it's not going to really help you in any way. So we thought about looking through the cache data and showing you how much performance improvement can be gained by removing a dynamic keyword. For example, we could calculate the time saving gained by removing the name of the current user from the design. Those sort of figures can help you modify your content and designs to improve performance.

I'd love to hear any suggestions for other ways these statistics can be used. Please leave a comment if you have some ideas.

Monday, 7 January 2008

MySource Matrix 3.18.0 RC1 released with PHP5 support

MySource Matrix 3.18.0 RC1 was released today; the first release that supports PHP5. It's been quite tough moving such a large project from PHP4 to PHP5 for a couple of reasons.

Changes to reference handling has been a big one. We've been changing so many lines of code to fix E_STRICT reference errors that we inevitably end up with some variables being copied rather than passed by reference.

Moving from PEAR::DB to PDO has also been a big deal. Not only have we moved to PDO, but we've also moved to the MySource4 DB abstraction layer, called DAL. DAL gives us the ability to write a single XML-based query for both Oracle and PostgreSQL, and native support for bind variables (an often requested feature). Learning the differences in syntax between PEAR::DB and DAL took time, as did DAL changes that were required to support the more complex queries that Matrix contains. In the end, we have a better, faster and more flexible DB abstraction layer that will see Matrix through until the MySource4 release and beyond. We also get the added benefit of testing such a key component of MySource4 in the real world.

On a more personally note, the large number of changes and testing required for this release got me more involved in Matrix development than I have been in a few years. Instead of sitting back and watching, I had enough time to dig in and convert part of the core, some packages and the unit testing system.

Speaking of unit testing, I couldn't imagine going through a process like this without an extensive unit test suite and some dedicated testers. Day-to-day, it is easy to forget why you write tests as you rarely get failures if you are careful enough. During a large core change like this, using the failing tests as a todo list gives you some guidance and, of course, confidence in your changes.

Besides PHP5 support, 3.18 has a couple of new features and improvements, some from the feature bazaar at the MMIUC 07. Many of the improvements are performance-based, with HIPOs and paint layouts getting special attention. All performance improvements in 3.18 have been road-tested in MySource4 first, so even though MySource4 has not been released, MySource Matrix users can be confident that they are benefiting indirectly from the project even at this early stage.

MySource Matrix 3.18.0 RC1 is not ready for production, but you can download a copy of the GPL version to give it a test on PHP 5.1.6 and PostgreSQL. Grab it from the MySource Matrix download page.

Thursday, 8 November 2007

Unique lock tokens in MySource4

We've recently moved onto designing the new MySource4 locking system. My work on locking during the WebDAV development lead me to the idea of unique lock tokens, which I had not previously considered for the locking system. I never saw a real need for lock tokens to be unique each time a lock is acquired on a resource, but now I have.

In MySource Matrix, each lock you acquire has a unique system-wide lock token that comprises of the asset ID and a lock type (e.g., attributes or linking). Each time that lock is acquired, the same lock token is generated.

MySource4 uses an alternative system where the lock token is always unique over time by using a UUID. This means that when you acquire a lock, MySource4 will give you this lock token and you will need to supply it back to MySource4 when you save. These lock tokens are very random and cannot be guessed. This is the same way WebDAV clients work.

The real difference in these two systems is trust.

In MySource Matrix, if you are logged in as the same user that acquired the lock, you can use that lock to save content. You do not need to supply a lock token so you can log into two different browser sessions and happily lock and save content in each.

In MySource4, if you acquire a lock in one browser, you cannot reuse that lock in another. The editing interface (acting as the client here) has to send the unique lock token back to MySource4 to save the content. The editing interface in the second browser will not know the correct lock token, and so the save will fail.

That's really all behind the scenes, and users don't need to worry about that when they lock content. In fact, users never have to explicitly lock content in MySource4, so even though the locking system is more complicated, the end-user experience is greatly simplified. It does stop one important conflict from occurring though; two editors logged in as the same user overriding the content of the other.

Although it is highly discouraged, editors will sometimes log into the system using the same username and password. Even worse, this can happen with the root account. When this happens, the locking system has no way to differentiate between the two editors, and so the locks of one become the locks of the other. This can lead to a situation where both editors are editing the same content at once and the last one to save wins.

In MySource4, once the first editor locks a piece of content, the second editor will see the content as locked because they do not have the correct lock token. So even though these two editors are logged in as the same user, they are treated as different users by the locking system.

This small change will lead to less chance of editing conflicts, including any editing that might take place in a replicated editing environment.

Saturday, 13 October 2007

My Squiz Story

I read a question on LinkedIn about "Your Story". It got me thinking about what I have achieved so far, so I've decided to write it down. Some of the specifics might be a little off, but here is "My Story" so far.



I started at Squiz in December 2001 after 2 years of a computer science degree at UTS. That particular degree encourages students to work full-time during their third year and come back to complete the 3-year degree in their fourth year. I have to admit that I was pretty nervous about going out into "the industry" after only 2 years of computer experience, but it turned out to not only be a great career move, but also helped greatly during my final year at uni.

I had been playing around with a personal web site and loved the idea of working with/on the internet full-time, so the job description for Squiz was very appealing. Both my (now) wife Deb and I went for the 2 positions being offered by Squiz, as did a lot of other UTS students. After two interviews, I was offered a position. Deb missed out, but ended up getting a .NET job a couple of months later. Incidentally, she now works as a senior trainer and documentation writer at Squiz. The other position was given to Daphne Chong, a mate from uni, so that eased the nerves a little.

During my second interview I was introduced to "Agi", who I assumed (by the name) was a burly seasoned Eastern European development lead. Steve "Agi" Agland was actually a skinny young PHP developer still completing his computer science degree at UTS. Agi was to become someone I learned the trade from, a good friend, and eventually best man at my wedding.

At the time, Squiz was a small company of about 20 people. Everyone worked at "the church" on Jarret street and there was only one office; Sydney. I was one of about 6 developers who not only wrote the code for the CMS, but also did all the implementation and provided client support.

On my first day, I was given the task of cutting up a design (the first of many). That involved taking a PSD file, determining the table layout (it was the bad old days of table-based design), cutting out the individual images for the cells, and coding the HTML. I had one problem; I didn't know how to code a table in HTML.

My complete lack of HTML knowledge wasn't all; I had been "coding" in PHP for 2 weeks. I had done Perl before, but I was employed to work on a large PHP Content Management System (MySource) which involved writing a lot of PHP and HTML.

Luckily for me, I was paired with a great teacher; Blair Robertson. Blair had started at Squiz the year before, also during his 3rd year of a UTS computer science degree. I remember watching him show me how to cut up this design and thinking to myself "how can this guy be so good after just 12 months?".

Blair was certainly someone to look up to and I aspired to be as good as he was. When I finally got my hands on MySource, then still reporting a version number of 0.85, I tried my best to learn it inside-out. I went home (a 2 hour trip) and worked on it all night. My greatest achievement at the time was adding colspan support into the bodycopy. I remember porting the code to Matrix a couple of years later and still being challenged by the code.

I ended up doing a lot of work on MySource, and became a more senior developer at Squiz. Eventually, it was decided that our page-based CMS needed to be upgraded to an asset-based CMS, and as the most senior full-time developers (Blair had left to go back to uni part-time) Agi and I started work converting MySource. After a few weeks, we had files working as assets, but it had become clear that we needed to start from scratch.

A meeting at JP's apartment between Agi, Blair, JP and myself reached a conclusion that we needed to start work on a new asset-based product, which was to become MySource Matrix.

Blair came back to Squiz full-time in 2003 after completing his degree. He was tasked with creating MySource Matrix, and was the only developer assigned to the project initially. I had decided to stay at Squiz full-time and complete my degree part-time over the next couple of years. That decision turned out to be a good one. A couple of months later, I started writing the MySource Matrix WYSIWYG editor and eventually started working with Blair full-time on MySource Matrix, which was one of the best experiences I have had at Squiz.

On a side note, MySource Matrix was originally named Mortar (as in "bricks and mortar") by Blair. When I started on the project, we renamed it to Resolve (a name I still love). JP and the sales team decided that Matrix was the name we were to use, which didn't sit well with Blair and I. In fact, we hated it so much that we used "MySource" in all design area tags instead of "Matrix" (they were original "Resolve" tags) and changed the version tag to "MySource v0.1.1 (Matrix)". We put "Matrix" in brackets because we were treating it as a build name and decided that we would change it with each major release. That obviously didn't happen. Later, after renaming the product to Resolve FX (at Norton's pub one night, and in our head's only) we put a hidden code into the asset map that changed the MySource Matrix logo to a Resolve FX logo.

Eventually, our two-man team turned into four as we added Marc McIntyre and Dominic Wong to the team. Squiz was really starting to expand at this time, and we were shifted into the back-room of "the church", which is now the training room. Just before Blair left to move to the UK and help start the office there, we took a famous picture that marked the day we finally embraced our new product name. The picture depicts the four Matrix developers posing in dark glasses behind a backdrop of code from the Matrix movie. Each of us signed the picture with our favorite Matrix quote, except for Blair who couldn't help writing something about the pub. I've still got the framed picture on my desk.


From left to right: me, Blair, Marc, Dom
Click for larger image

Blair leaving moved me into the lead developer role at Squiz (Agi had left to work on the movie Happy Feet with Animal Logic). Squiz grew around the new product, starting our support and implementation teams, and eventually moving into other Australian states. The dev team moved to a new office on Elswick street, just down the road from "the church", which we quickly outgrew. We traded that office in for one on the other side of "the church", which is where the majority of Squiz staff in Sydney now work.

Just before leaving the Elswick street office, Marc and I started thinking about a new product; MySource4. We had a lot of great ideas based on the years of CMS experience we now had, and finally convinced JP to start a new project team.

We assembled a team of the four best Matrix developers and started work on MySource4. Marc was the team leader and I was the project lead. I worked with Marc on the system architecture but left the coding up to the other three. I was still leading the Matrix team, so I was pretty busy during that period. I was also unit head of the development team, so I had to start doing all those managerial tasks like approving leave, performing pay reviews, and hiring new developers. That was about the time I stopped doing any real PHP development.

I had started PHP at the end of 2001 and had stopped by 2006, only four years later. I was still going to be doing some work on development tools, like our unit testing and code sniffing software, but my full-time PHP role was over. It took some getting used to.

Everything kept ticking over until the present day. Squiz is going strong, MySource Matrix is going strong, and MySource4 is well on the way to becoming a revolutionary CMS (and PHP) product. I finally graduated from UTS in 2005 with a Bachelor of Science in Computing Science and 1st class honors. Marc and I started PHP_CodeSniffer, which was accepted into PEAR in 2006. I still work on PHP_CodeSniffer regularly to keep my PHP skills current, and do some work on MySource4 itself. I'm still the lead developer of MySource Matrix and am now Product Development Manager at Squiz. Deb and I got married in 2006 and are expecting our first child in January.

I'm looking forward to the future.

Friday, 5 October 2007

Implicit comparisons in PHP

Tobias Schlitt recently wrote a blog entry about the speed of PHP comparisons. In it, he mentions that using the === operator to compare types as well as values is faster than using the == operator to compare values only. This is something that has been known for a while and we've made it part of our coding standard for MySource4.

Yes, the performance improvement you get is minor, but even the smallest changes add up for a site with hundreds of thousands of page views a day. Think about how many comparisons would be done during a single page load and you'll see that even small improvements like this one start to become significant.

Something else he mentions is that comparing return values of functions is faster than using an implicit comparison. So, for example, this code:

if (isset($foo) === true) { ... }
is slightly faster than this code:
if (isset($foo)) { ... }

I'm not sure that the tests performed are accurate, but we don't use implicit comparisons in MySource4 either. Not because of performance but because the code is easier to read. Again, this is part of our coding standard and is enforced by the Squiz standard in PHP_CodeSniffer.

If you would also like to incorporate these simple changes into your coding standard, PHP_CodeSniffer is a great tool to help you enforce them and show you where you need to make modifications to your code. You can either use the included Squiz standard or incorporate the specific sniff, Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff, into your own custom standard.

Sunday, 30 September 2007

MySource 4.0 WebDAV update

In a previous post, I mentioned some WebDAV improvements that I was thinking of implementing in MySource4. I've finally got around to trying some of them out, with positive results. The improvement I'm currently making to MySource4's WebDAV server is the ability to add files and folders.

Adding this feature was a lot easier than I thought, but the functionality it provides is much more impressive. I'm now able to drag files from my local machine into the WebDAV folder. I can also drag entire folders and have them imported along with their sub-folders and files. This makes mass-importing of files and folders as easy as copy/paste and is going to be an important part of any document management system.

The files and folders that are imported exist only in WebDAV and are not imported into MySource4 because I can't trust most WebDAV requests. When an administration interface is added to MySource4, I'll put something into it that allows the changes made in WebDAV to be committed to the MySource4 system. For now though, all imported files and folders can be viewed and edited by all editors using the WebDAV interface, so it works sort of like a staging area.

As much pain as WebDAV has caused me in the past, I've fallen deeply in love with it again!

Friday, 28 September 2007

php|architect on PHP_CodeSniffer

The guys at php|architect have had a quick chat about PHP_CodeSniffer in their latest newscast, hosted by Sean Coates and Paul Reinheimer.

One of the things they mention is that it would be great if PHP_CodeSniffer could be integrated into common editors. At Squiz, the MySource4 team already has PHP_CodeSniffer integrated into JEdit using a web service and a JEdit plugin that we wrote, and into TextMate using their built-in script plugin. Integration with other editors is something I'd like to look into further after the first stable release.

Sunday, 16 September 2007

MySource Matrix User Conference 2007

I've just returned from the first MySource Matrix International User Conference, held on the Gold Coast. I presented two talks at the conference, including the first public preview of MySource4. Being the first conference, nobody was really sure what to expect, but overall I really enjoyed the conference and got a lot out of it.

Obviously, I was mostly focused on the preview of MySource4, which went pretty well. I was a bit worried that we wouldn't have enough to show, but the focus on the inline content editing interfaces, including our new WYSIWYG editor (Viper), was pretty much all I could get into the 45 minute presentation anyway. With the preview past me, I'm really looking forward to digging back into the product and shifting focus onto some new interfaces, including configuration screens and design editing.

The conference had a few case studies from MySource Matrix users, which was a really great thing to see. It's been over 3 years since I first started work on Matrix (it must be close to 4 now) and I've been removed from end-users for most of that time. I only really deal with the specification phase, clients that are having problems or clients with large amounts of development. It was great, really great, to see people who have used Matrix to improve their business, and to talk to people who really love it. I particularly liked reflecting on the Tourism Tropical North Queensland project (presented by Angus Sprott) and seeing the Australian Sports Commission system (presented by Pat Birgan) that I've only ever read about in emails.

The presentations I was really looking forward to were "Website Accessibility - Can you buy your own can of beans?" from Bruce Aylward and particularly "Access to websites - how design makes all the difference" from Neil Jarvis. Watching Neil use a screen reader to navigate websites was an eye-opener. You can't understand the reasons why you strive for accessibility without seeing how it affects the user, and that goes for application developers as well. I had a chat with Bruce after the presentation and spoke about the ways in which a JavaScript-rich web application like MySource4 can be made accessible. It's certainly possible, providing the development team is committed to the goal and understand what they are doing and why they are doing it. I'm very confident that MySource4 will be an accessible web application; one of very few.

Congratulations to everyone involved with the conference and thanks to everyone who attended and made it a great couple of days.

Thursday, 14 June 2007

MySource 4.0 internal demo

Today, I gave the first internal demonstration of MySource 4.0 to Squiz. At lot of people have been waiting a long time to get a look at our progress and it was great to finally be able to show them what we've been working on.

The first part of the demonstration was MySource 4.0 itself. I showed the installation process and created a simple five page website with an imported design. The inline content editing interfaces were shown with raw HTML text boxes only. Finally, I demonstrated MySource 4.0's WebDAV integration by editing a Word Document that was uploaded through the content editing interface.

The second part was a batch processing test. I added and deleted a web path and role to 135,000 pages that we had previously imported into a test system. Adding took around 26 seconds. Deleting took around 6 seconds. To compare that to MySource Matrix, we would be acting upon somewhere between 540,000 and 800,000 assets and both adding and deleting would take somewhere between 10 and 24 hours, depending on hardware and load.

The last part of the demonstration was a preview of Viper, the MySource 4.0 WYSIWYG editor. This was really exciting and drove home our goal of inline content editing. Unlike other WYWISYG editors, Viper is written in JavaScript but does not use the browser's built-in editable region. The result is an editor where we have complete control over how it works, how it looks and the HTML it produces.

We are now busy preparing features for the first public demonstration at the MySource Matrix International User Conference 2007 in September.

Saturday, 2 June 2007

MySource 4.0 public demo in September

The first MySource Matrix International User Conference will be held in September this year. It's a chance for MySource Matrix users to get together and discuss the product, their implementations of it and how it can improve the organisation and delivery of content. It's also a chance for MySource Matrix users to see a preview MySource 4.0.

MySource 4.0 is still a fair way from being feature complete, but the demonstration will still showcase some exciting improvements to our content creation and editing interfaces. It will also be a chance for us to describe where we are going with this product and the kinds of development that we will be able to do in the future.

The details of the conference are:

MySource Matrix International User Conference 2007

The conference is designed to bring our user community together on an annual basis to provide best practice advice in all areas of content management and web technology.

Squiz will coordinate a cutomised program delivering functional, practical solutions that maximise the benefits of your investment with MySource Matrix.

The agenda offers a broad range of presentations and case studies lead by recongnised industry leaders and current users. Held at the Radisson Hotel on the Gold Coast, the venue will be conducive to collaboration, innovation and learning.

Your registration also includes a seat at the Squiz Innovation Awards Dinner on Thursday night, 13th September. Prizes will be awarded for users, who demonstrate excellence in MySource Matrix implementation & website innovation.

Why you should attend:
  • To meet and liaise with industry leaders, topic experts and the user community
  • To broaden your skill set and knowledge base - delivering more relevance to the organisation
  • To gain efficiencies and best practice techniques in using MySource Matrix
  • To ensure you are up to date with the latest software developments
  • Be one of the first to see MySource version 4 to be released in 2008

Key Agenda Topics:
  • Designing usable Web 2.0 applications
  • Techniques to ensure maximum accessibility, usability and functionality
  • First public preview of the much anticipated MySource version 4
  • User oriented information architecture for effective web content management
  • What's happening with de-centralised publishing? Pros and Cons.
  • MySource Matrix Tips, Tricks, Shortcuts and more (Manual included)
  • User workshops

To register for the conference visit:
http://www.hotelnetwork.com.au/conferences/conferences#squiz7
For Further details please call 02 8507 9000

Wednesday, 25 April 2007

Screen capture with PHP: Useful for documentation

Pierre-Alain Joye has posted about a couple of new functions he has added to GD (to be released in 5.2.2) that will allow a script running on Windows to capture the entire screen or a single window. He includes some sample code to capture an IE window after navigating to a specific URL.

These new functions got me thinking about documentation for MySource 4.0. We've made it a priority to be able to customise a large number of interfaces in the system, as well as removing entire pieces of functionality all together. This obviously makes documentation hard as every user may be looking at a different interface with different functionality.

While we haven't sat down and tackled this problem yet (it's a bit too early at the moment) we have thought about possible solutions in the past. One of the things discussed was generating documentation by putting together different parts of manuals depending on what functionality is present in a system. We could also read XML files that define the interfaces to determine, for example, the creation wizards that are in use and what functionality they implement.

Even if we can get the words together to describe a system, we still only have a generic set of screenshots to use in a manual. I'm hoping that this new functionality in GD will allow us to generate custom screenshots, leading to customised manuals for each system or each standard configuration of MySource 4.0.

Friday, 30 March 2007

MySource 4.0 WebDAV ideas

I've been thinking about how to implement some new features and improvements into the MySource 4.0 WebDAV server. All these changes would go in after the alpha release and user feedback, but I thought I'd try and list them in one place so I don't forget about them.

Adding new files and folders
The problem with adding (and deleting) files and folders is actually editing. That sounds a bit weird, so let me explain.

When you edit files, the application or file system decides on the process it will use to save the file. Most applications don't make things easy by using a simple LOCK then PUT (a new version) then UNLOCK. Most applications I test with move the current file and create temp files and directories before finally renaming a temp file to replace the existing file we are editing. This means that I get a lot of DELETE, MOVE, PUT and MKCOL requests coming through. If I actually processed all of these requests in the CMS, assets would be moving all over the place, and often being replaced by new assets with the same name while they end up in the trash.

To solve this problem, I don't action any of these request when asked. Instead, I keep a record of where files and folders should be. This allows me to pretend that files have been moved, created or deleted without having to actually do it. Then when a temp file is moved to the location of an existing file, I update the file's contents in the CMS.

That is a lot of background to basically say that I can never trust a PUT request. There is no way of knowing if it is a real request to create a new file or if it is just an application trying to save an existing file. Forget sessions and cookies to store information about what is going on. They are not supported in WebDAV.

So here is my idea. When someone drags a file into a folder, I pretend that it exists. I don't currently show that file in the folder, but I could. If I do show the file, I can also allow it to be edited. For users of WebDAV, it would appear that the file has been created in the CMS, but it really only exists in the WebDAV database. To commit the file to the CMS, a user could go to some location in MySource 4.0 and indicate that a pending WebDAV file should be turned into a real File asset.

Deleting existing files and folders
For the same reason as adding files and folders is a problem, deleting is a problem as well. There is no way to tell if the user deleted the file or if the application deleted it while saving.

In the same way that added files can be shown, deleted files can be hidden. In fact, I already do hide them because it causes OS X's Finder to go crazy if it thinks a file should be deleted but it is still there (fair enough I guess). Again, a user could go to a location in MySource 4.0 and indicate that files marked as deleted should be moved to the trash within the CMS.

Authentication and permissions
Forcing a user to authenticate before connecting to the WebDAV server is dead easy. However, you do need to re-authenticate every time a request is made because sessions (cookies) are not supported. That isn't a problem, but it is something to remember when this functionality is added.

Similarly, checking permissions on assets before displaying them is not going to be hard. Where I do see things getting a little interesting is the display of projects and project folders. They don't have any specific permissions applied to them, so who do we show them too? We could say that any user can see the projects in which their account exists, or we could say that they see projects where they can read at least one item in the project. The first method is quick, the second is slow. Unsurprisingly, I'm leaning towards the first option.

Temporary items on OS X
I noticed, completely by accident, that if I told Word on OS X that the Temporary Items folder didn't exist, it would save the file using less requests. The figures are something like 30 requests versus 22. Instead of moving temporary files around, it would just create backup copies in the same location as the existing file.

I do have support for the Temporary Items folder in the WebDAV server, but I'm wondering if taking out that support might actually improve performance on OS X. Word on Windows doesn't suffer from the same problem as it choses to save files differently (of course).

I'd like to do some testing to see if this could be a possible improvement to the WebDAV server.

Tuesday, 27 March 2007

MySource 4.0 WebDAV complete

Well, complete enough for the alpha release anyway. There is no authentication or permission checking in there, and you cant add and remove files and folders. I didn't leave these features out because they were hard, but because I don't want to finish planing this server without some feedback from users first. I have some ideas about how I want those features to work, so I'm interested to see if they go down well.

I'll write another post with my ideas in it later. This one is all about the fact that the server finally works. I didn't have to change any of the functionality to get it working on Windows, but it has been quite a wait to test it.

The problems I had were interesting.

First, I was using Lighttpd as the web server. Everything worked fine on OS X, but when saving a Word document on Windows, Lighttpd would receive a very specific GET request from Word and drop it. That is, it would return a 400 (bad request) error without ever asking by script to process the request. This caused Word to always open the file as read-only. There was nothing I could do about this error. I couldn't get Word to change the request and I couldn't get Lighttpd to accept it.

The server admins then set me up with Apache running the php5-cgi module (our Apache already runs mod-php4, so we couldn't just use mod-php5). Everything was working great with my existing saved connections until I tried creating a new connection for testing. The very first OPTIONS request that gets sent to see what version of the WebDAV protocol is being used was being handled by Apache without asking my script to process the request. Apparently, there was a bug in Apache where it handled the OPTIONS request for all CGI scripts. The version of Apache on our dev box could not be updated for a few weeks, so we had to find another way.

The solution turned out to be FastCGI on Apache. Every request made it through to my script and saving/browsing was working on both OS X and Windows XP.

It's been a long road, but the functionality this server provides will be a fantastic addition to MySource 4.0. I'm looking forward to trying it out on some real data when the alpha is released.

Wednesday, 21 March 2007

Easier custom standards with PHP_CodeSniffer

I committed a fairly large change to PHP_CodeSniffer today that allows you to create custom coding standards without having to write your own sniffs.

The MySource 4.0 team needed a new code sniff to check that we were including files correctly, but the sniff was very specific to the product, so I could not include it in the Squiz coding standard. I needed the team to use a new MySource4 coding standard to check their code, but I wanted it to be the Squiz coding standard with a few more sniffs.

The only way to do this previously was to create empty sniffs files for every Squiz sniff that I wanted to include. This meant a lot of directories and a lot of maintenance as I would have to update the MySource4 standard every time I added or removed sniffs from the Squiz standard.

So I decided to give coding standards their own management class and allow them to override a method in there to tell PHP_CodeSniffer which sniffs, directories of sniffs, or whole coding standards they would like to include in addition to their own. This not only allowed me to create the MySource4 standard easily, but also allowed me to remove some empty sniff files from both the Squiz and PEAR coding standards.

I haven't update the end user docs for PHP_CodeSniffer yet, but I will get around to it before the next release. All existing coding standards will need this management class, so you'll need to be aware of this if you do have your own custom standard.

Saturday, 10 March 2007

WedDAV test server

While trying to work out why I couldn't save Microsoft Word documents from OS X, it occurred to me that a good way to get it working was to look at what other WebDAV servers do and try to copy them. I used this technique with Ethereal and a Windows Sever 2003 box to get my prototype server working earlier in the year. The only problem this time was that Microsoft Word on OS X couldn't save files on a Windows Server 2003 WebDAV share running under IIS, and that's a big problem for me.

I'm not sure why saving doesn't work, but I tried it on two different Macs using two different versions of Microsoft Word and both failed. On a Windows XP machine, saving works fine. I needed to find another WebDAV server to use for testing, or configure one myself. My limited access to server hardware meant that I was going to have to go with the first option.

Enter the WebDAV Testing Server. This is a free public WebDAV server that runs Apache with mod_dav to provide WebDAV functionality. It's primary goal is to provide a test server for developers writing WebDAV clients, but it also happens to come in handy when writing your own server.

Luckily for me, this test server can read and write Microsoft Word documents on OS X just fine, so I used Ethereal to compare the requests and responses and I can now (finally) save Microsoft Word docs from OS X into MySource 4.0. As an added bonus, my problems with saving from Photoshop have gone away as well. One of the changes made today must have caused it to start working, so things are looking up.

Saturday, 3 March 2007

MySource 4.0 WebDAV server started

I've been waiting about a month for MySource 4.0 development to reach a point where it made sense to begin porting my stand-alone WebDAV server to MySource 4.0. This week, it finally caught-up.

Currently, my WebDav server can display the projects in your system as folders. Three project folders are listed under each; Documents, Images and Movies. The server currently only supports the viewing of Folder and File assets under these folders, but the mime type of each File asset is determined, so they appear as different file types in the OS.

I've had to put the ID of the asset in the path for now (which means it also appears in the folder/file name) because we don't have URLs assigned to project folders yet. For example, a folder name would be something like [23] Holiday Photos. Once these URLs go in, I'll be able to use the web path of the asset instead of the ID. For example, a folder name would be something like holiday_photos. I'm thinking of making this an option though, because some people may prefer seeing the name rather than the web path, even if the name does have the asset ID on the front. It's also one less query in most cases, so that is a bonus too. It's just a lot harder to remember a URL with /[23]%20Holiday%20Photos/ in it than /holiday_photos/ if you want to navigate to that folder directly.

The next thing to tackle for WebDAV is the editing of files, which includes working out a permanent solution for locking. Supporting the creation of new files and folders would be the next logical step, before finally moving the server into MySource 4.0 and converting it to a System with Actions and Channels.

Friday, 16 February 2007

A better way to cascade in MySource 4.0

When the MySource Matrix permission system was first being planned, we tried a number of different database schemas to allow permissions to inherit to assets from multiple parents. The biggest problem was the time taken to check if a permission exists (eg. read access). With permission queries being some of the most common, they really needed to be as fast as possible.

The solution we came up with was a pretty basic one; cascade permissions to all child assets when setting them. So, for example, when you grant public read access on a Site asset, we run a HIPO job to set that same permission on every asset within the site. This allows us to check if any particular asset has public read access without having to determine its position in the tree. Instead of waiting for slow queries on the frontend, we made the backend processing slower.

There are two main problems with this approach. The first is that the data storage requirements are significantly greater than if we inherited permissions. The second problem is that cascading takes a very long time.

We just finished the planning of the Roles system for MySource 4.0. The roles system replaces the Permissions system in MySource Matrix, but requires the same general concept. We reevaluated the storage of permission assignments in MySource Matrix to see if we could remove the need for cascading role assignments.

Long story short; we couldn't. We still need to have a table with all the role assignments for every asset so we can quickly access role assignments for specific assets, and so that we can join the table to add permission checks to other queries. So we turned our attention to how we cascade assignments and looked for ways to make the process faster.

Here, we did succeed.

In MySource Matrix, we first get a list of all assets under the asset we are setting permissions on. Then we loop through each asset and assign the permission. A database query is executed for each of these assets to add the permission assignment. In reality, a lot more database queries are executed to load the asset and check its current assignments. HIPO thresholds are used to process more than one asset at a time, and the Squiz Server is used to process all assets in one go. Both thresholds and the Squiz Server make the process faster, but they don't reduce the number of queries executed.

In MySource 4.0, we have always wanted to get rid of the need for HIPO jobs and the Squiz Server. We are pretty sure we don't need the Squiz Server any more, but we will still need a HIPO job of some sort. The big difference are the thresholds. Whereas in MySource Matrix you could potentially process up to 50 assets at a time, MySource 4.0 thresholds will be more like 50,000. So even with HIPO jobs, you'll probably never see them.

We have written some new queries that will allow us to process different levels of the tree in one go, or multiple levels if they fit within the threshold. The reason we can increase the number of assets processed at once so much is because we no longer load assets and insert rows one by one. Instead, our new queries can look at the tree, select an entire level, and insert several thousand rows at once. These queries can also take granted and denied permissions into account, so you can't apply public read access where it is already denied (eg. a members only area).

We tested our theory yesterday with a sample of 44,000 assets from a MySource Matrix system. The goal was to select a entire section of a tree and insert new role assignments for all assets that did not currently have that role set. Here are the results:

# INSERT INTO asset_role_assignments (assetid, userid, roleid, granted)
# SELECT distinct l.minorid AS assetid, '90211' AS userid, '1234' AS roleid, 1 AS granted FROM
# sq_ast_lnk l INNER JOIN sq_ast_lnk_tree t ON t.linkid = l.linkid
# WHERE
# t.treeid like '00010002000D00030000%'
# AND NOT EXISTS (
# SELECT 1 FROM
# sq_ast_perm p
# WHERE
# p.assetid = l.minorid
# AND p.userid = '90211'
# AND p.permission = 2
# );
INSERT 0 44041
Time: 2441.133 ms
This test was run on a dedicated database server using PostgreSQL 8.2. Over 44,000 entries were inserted in about 2.4 seconds. We calculated that processing 44,000 assets in MySource Matrix would take around 6 hours. The other thing to consider is that a Standard Page in MySource Matrix is actually 4 assets, whereas it is only 1 asset in MySource 4.0. So these figures actually tell us that MySource 4.0 can process 44,000 pages in 2.4 seconds whereas MySource Matrix can process 11,000 in 6 hours.

We have now started development of the Roles system, so it wont be too long until we can start trying this out with some real data. The results so far do look very promising though.