First of all, we should encourage people to test upgrade scripts on live system data so we detect any hickups in advance before releasing our software. Now for the real issue:
The file storage upgrade from 5.1.0a6 to 5.1.0a7 introduced a change that exchanged the name and the title of a file. After fixing the upgrade script with Dave for dotlrn.org yesterday, I realized (together with experience collected at Heidelberg's site) that we have a fundamental problem due to this switch.
Direct links to files are broken as long as you do not navigate to them using the file storage interface. Take this as an example:
http://dotlrn.org:8000/file-storage/view/images/screenshot-dotlrn-download.jpg used to work before the upgrade. As there were multiple versions of screenshot-dotlrn-download.jpg, the upgrade renamed them (as we have a unique constraint on name,parent_id in cr_items) by adding a counter. The new file is called therefore called screenshot-dotlrn-download.5.jpg (name) with the title screenshot-dotlrn-download.jpg (title). Title does not have to be unique !
But how can you access this file now? http://dotlrn.org:8000/file-storage/view/images/screenshot-dotlrn-download.5.jpg
As you can see, the URLs are different and obviously all pages that contain links to files in file storage (with multiple revisions before the upgrade) are broken.
My proposed solution to this:
Before marking a file as failed, check if there is not an item with the TITLE (instead of name) for the URL.
This has been done and tested briefly. Change made to the content::init function as follows:
# cache this query persistently for 1 hour set item_info(item_id) [::content::item::get_id -item_path $url \
-root_folder_id $content_root \
-resolve_index "f"]
# Make sure we are not dealing with an upgraded file and there exists a file with the title
if { [string equal "" $item_info(item_id)] } {
set splitted_url [split $url "/"]
set item_url_title [lindex $splitted_url end]
set item_url_folder [lindex $splitted_url end-1]
set item_info(item_id) [db_string test "select i.item_id
from cr_revisions r, cr_items i where r.item_id = i.item_id
and r.title = :item_url_title and i.parent_id = (select
item_id from cr_i\tems where name = :item_url_folder) order
by revision_id desc limit 1"]
}
If this solution is flawed, please state how and why. If noone complains I will commit this (with the db_query put into the .xql file) tomorrow morning. It fixed all issues at dotlrn.org with regards to files not being found with direct URLs and I think Heidelberg will be happy as well.