I updated my Gallery from version 3.03 to 3.06. Now some albums are behaving strangely.
I ran Fix your Gallery but it failed with the message "ORM Validation has failed for items model".
The log shows "illegal_data_file_extension". Apparently there are image files with file names that can not be handled by the new Gallery version (I checked and I do have many files with more than one dot in the file name).
I tried running the script from neuhalfen.name but it won't run properly on my computer (I don't have gsed and gfind and regular sed and find don't seem to do the trick).
Obviously I am not the only who has run into this but I can't seem to find an easy solution for this.
How has everyone else resolved this?
Daniel
Posts: 27300
The upgrade code in 3.0.6 and 3.0.7 that we just released fixes this issue. Did you run the upgrader?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 10
Yes, I did run the upgrader on 3.06.
I just installed 3.07 and ran the upgrader too but when I run "Fix your Gallery" I still get "ORM Validation has failed for items model".
Daniel
Posts: 183
@dpolak - hmm... by any chance, do/did you have the videos module installed?
In v3.0.4, filenames with extra dots were disallowed due to security reasons, and any new files should have been fixed upon upload.
In v3.0.5, a script was added to the upgrader to fix existing files with multiple dots.
The problem with this was that the videos module was, well, not very modular. In particular, rather than override the main item model to add some tweaks, it *replaced* it entirely with its own version... which was based on v3.0.1. In other words, the revised item model and its name-fixing-and-validating code was never really used, and perhaps the problem arises from there?
Take care,
Shad
Posts: 10
@shadlaws
AFAIK no video modules are installed.
The active modules are Info, Organise, RSS, Search, Server Add, Slideshow, Tags and Watermarks.
Is it possible to manually run the script that the upgrader runs so I can see if it encounters any errors?
This is what the log says:
Task Fix your Gallery started (task id 26)
exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /htdocs/album.sixappealwheel.org/gallery/system/libraries/ORM_Validation_Exception.php:20
Stack trace:
#0 /htdocs/album.sixappealwheel.org/gallery/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/models/item.php(887): ORM_Core->validate(NULL)
#2 /htdocs/album.sixappealwheel.org/gallery/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/libraries/MY_ORM.php(34): ORM_Core->save()
#4 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/libraries/ORM_MPTT.php(79): ORM->save()
#5 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/models/item.php(533): ORM_MPTT_Core->save()
#6 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/models/item.php(305): Item_Model_Core->save()
#7 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/helpers/gallery_task.php(672): Item_Model_Core->relative_path()
#8 [internal function]: gallery_task_Core::fix(Object(Task_Model))
#9 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/helpers/task.php(90): call_user_func_array('gallery_task::f...', Array)
#10 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/controllers/admin_maintenance.php(195): task_Core::run('26')
#11 [internal function]: Admin_Maintenance_Controller->run('26')
#12 /htdocs/album.sixappealwheel.org/gallery/modules/gallery/controllers/admin.php(62): call_user_func_array(Array, Array)
#13 [internal function]: Admin_Controller->__call('maintenance', Array)
#14 /htdocs/album.sixappealwheel.org/gallery/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Admin_Controller), Array)
#15 [internal function]: Kohana_Core::instance(NULL)
#16 /htdocs/album.sixappealwheel.org/gallery/system/core/Event.php(208): call_user_func_array(Array, Array)
#17 /htdocs/album.sixappealwheel.org/gallery/application/Bootstrap.php(67): Event_Core::run('system.execute')
#18 /htdocs/album.sixappealwheel.org/gallery/index.php(116): require('/htdocs/album.s...')
#19 {main}
Is it possible to install 3.04 and keep the current image files and database or have the upgrades changed things so 3.04 won't run?
Daniel
Posts: 183
@dpolak - Hmm, that's strange. Well, if it's an issue with double-dotted filenames, here's a hack that should fix it for you:
In modules/gallery/helpers/gallery_task.php, look for line 383 (has "This is a state machine" in it). Just before this block of code, we're going to cut'n'paste the upgrade block from gallery_installer.php that should have done the job of fixing your extra dots. The end result should look like this:
This is a bit of a hack (in the sense that this code doesn't really belong here), but should be safe in the sense that it should get the job done while having no effect on files that don't need fixing. Depending on how much there is to fix this could take awhile. If for some reason it times out, just try and restart the task and it'll automatically pick up where it left off (since the db query won't pick up the already-fixed items).
Hope that helps!
Shad
Posts: 10
@shadlaws
Thanks a lot for the patch. I added it to modules/gallery/helpers/gallery_task.php and ran "Fix your Gallery". It almost completes now but it still says
"ORM Validation has failed for items model".
Posts: 8339
@dpolak never copy that much information to any forum ever.
copy it to a txt document and attach it instead.
-s
________________________________
All New jQuery Minislideshow for G2/G3
Posts: 183
@dpolak - Hmm, so apparently it's not just a problem with dots. If you can, PM me with more details, logs, etc. so we can see what's up.
Shad
Posts: 10
The log must have been longer than I realised, sorry!
This is the relevant part:
2013-04-26 12:00:37 +00:00 --- error: Validation errors: Array
(
[name] => illegal_data_file_extension
)
Is there any way to see which picture is causing the "illegal_data_file_extension" error?
Daniel
Posts: 183
@dpolak - sure, we can figure that out. Again, it involves hacking some code, so these mods should be undone once you're finished.
The illegal_data_file_extension error is determined in /modules/gallery/models/item.php. There are three lines that look like:
Each of these lines correspond to one issue - double extensions, no extensions, or illegal extensions.
Now, let's change them to be more specific. For example:
This should generate the same error, but be a bit more verbose about which file is causing it.
Take care,
Shad
Posts: 10
@shadlaws
I think that change makes things clearer. Why do you think it should be undone?
If clarified the messages a bit more and IMHO it might be good to add that to the standard Gallery.
How about having these error messages?
The result is this:
[name] => illegal_data_file_extension (wrong extension type) in 31AG14, RAF St Mawgan. 11th December 1988
How can I solve this problem?
Was this image uploaded without a .jpg extension or did one of the fixes cause things to go wrong?
Daniel
Posts: 183
Hey Daniel,
True, it might be nice to add something like this to Gallery, but probably not exactly like this. "illegal_data_file_extension" isn't intended to be a human-readable message so much as an error type, and changing it can break things downstream that are looking for it (e.g. our test code, which makes sure Gallery properly catches errors before we ship it). Wanna file an issue ticket on Trac to include something like this later on?
Alright, back to the problem at hand. I'm not sure how this file ever got uploaded, but it's unlikely it got changed by one of our fixes (legal_file::smash_extensions() simply replaces extra dots with underscores, so "foo.bar.jpg" becomes "foo_bar.jpg").
First question: what does the "edit photo" dialog in Gallery report about the photo? Find the photo (perhaps by searching for part/all of the name), then open the "edit photo" dialog, and see what Gallery says the filename is.
Next question: what does the actual file system look like? Either by FTP or by a terminal window, go to the directory where the photo should be and see what it looks like (in gallery3/var/albums/...). Important: don't actually change anything here!!! The directory/file structure is synced with the database so tweaking it in one place and not the other could cause bad things to occur.
If the answers to the two questions above are the same, then attempt the simplest (and safest) solution: go back to the edit photo dialog in Gallery and change the filename. Remove the period (the comma is ok), add ".jpg" at the end, and hit save.
If the two are different, we'll need to be a bit more clever... let me know what you find!
Take care,
Shad
Posts: 183
(BTW, my note above assumes that it's actually a jpg... if you're unsure, download the file to your computer and get its type before doing this)
Posts: 10
I'll try, will have to find the Gallery Trac and I assume I will have to register for it.
Searching doesn't find it and when I click the album it appears to have no photo's.
Shall I change the extension of the file in the file system and edit the file name in MySQL? How do I take care of the files in thumbs and resize?
var/albums/Petes/album289/31AG14, RAF St Mawgan. 11th December 1988
So no extension.
Posts: 183
@dpolak - so, you added the photos, the file system has them, but Gallery shows an empty album? Hmm, that's really odd. I'll send you a PM to share a few more details and see if we can nail this down.
Thanks,
Shad