upgrading from G2: ORM Validation has failed for items model

sagemaniac

Joined: 2003-03-26
Posts: 47
Posted: Tue, 2010-06-15 07:04

Hi everybody,
G3 is really great - just what was needed ;).

I have migrated 4 galleries so far with minor problems from G1 to G2 and then to G3.
Now I am migrating a G2 with many, many plugins and I can't seem to get past user migration. I suspect I need to turn a few things off in G2? Like maybe the panorama plugin?

When I turn comments on in G3 and then click on G 2 Import, I get a white screen ;) - when I turn comments off, I get to run G2 Import, but it stops right after User Import with "ORM Validation has failed for items model"

Here is my info, maybe someone has a few pointers, what to turn off in G2 - both installs are up to date:

G3 LOG:

Task Import from Gallery 2 started (task id 4)
Group 'Admin' does not exist in Gallery 3, skipping
User with id: 3200 already imported, skipping
...(many more users, I only show last one)...
User with id: 3211 already imported, skipping
exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /var/www/clients/client1/web56/web/gallery3/system/libraries/ORM_Validation_Exception.php:20
Stack trace:
#0 /var/www/clients/client1/web56/web/gallery3/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /var/www/clients/client1/web56/web/gallery3/modules/gallery/models/item.php(755): ORM_Core->validate(NULL)
#2 /var/www/clients/client1/web56/web/gallery3/system/libraries/ORM.php(778): Item_Model->validate()
#3 /var/www/clients/client1/web56/web/gallery3/modules/gallery/libraries/MY_ORM.php(23): ORM_Core->save()
#4 /var/www/clients/client1/web56/web/gallery3/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /var/www/clients/client1/web56/web/gallery3/modules/gallery/models/item.php(386): ORM_MPTT_Core->save()
#6 /var/www/clients/client1/web56/web/gallery3/modules/g2_import/helpers/g2_import.php(412): Item_Model->save()
#7 /var/www/clients/client1/web56/web/gallery3/modules/g2_import/helpers/g2_import_task.php(130): g2_import_Core::import_album(Array)
#8 [internal function]: g2_import_task_Core::import(Object(Task_Model))
#9 /var/www/clients/client1/web56/web/gallery3/modules/gallery/helpers/task.php(90): call_user_func_array('g2_import_task:...', Array)
#10 /var/www/clients/client1/web56/web/gallery3/modules/gallery/controllers/admin_maintenance.php(186): task_Core::run('4')
#11 [internal function]: Admin_Maintenance_Controller->run('4')
#12 /var/www/clients/client1/web56/web/gallery3/modules/gallery/controllers/admin.php(57): call_user_func_array(Array, Array)
#13 [internal function]: Admin_Controller->__call('maintenance', Array)
#14 /var/www/clients/client1/web56/web/gallery3/system/core/Kohana.php(330): ReflectionMethod->invokeArgs(Object(Admin_Controller), Array)
#15 [internal function]: Kohana_Core::instance(NULL)
#16 /var/www/clients/client1/web56/web/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#17 /var/www/clients/client1/web56/web/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#18 /var/www/clients/client1/web56/web/gallery3/index.php(91): require('/var/www/client...')
#19 {main}

G2 system details:
Gallery URL = http://www.mygallery.de/main.php
Gallery version = 2.3.1 core 1.3.0.1
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6-1+lenny8 apache2handler
Webserver = Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
Database = mysqli 5.0.51a-24+lenny3, lock.system=flock
Toolkits = ArchiveUpload, Exif, Getid3, LinkItemToolkit, NetPBM, SquareThumb, Thumbnail, Gd, ImageMagick
Acceleration = full/900, full/900
Operating system = Linux r3d2.de 2.6.26-2-amd64 #1 SMP Wed May 12 18:03:14 UTC 2010 x86_64
Default theme = matrix
gettext = enabled
Locale = de_DE
Browser = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Rows in GalleryAccessMap table = 170
Rows in GalleryAccessSubscriberMap table = 865
Rows in GalleryUser table = 28
Rows in GalleryItem table = 863
Rows in GalleryAlbumItem table = 24
Rows in GalleryCacheMap table = 71

Thanks,
Ritch

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Tue, 2010-06-15 19:40

First thing I'd check is are you using the latest experimental code for G3?

Get the code here:
http://github.com/gallery/gallery3/zipball/master

Upgrade instructions here:
http://codex.gallery2.org/Gallery3:Upgrading

Then I'd check is to make sure all your G2 users have a valid email address if it still fails after upgrading to the latest experimental code.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
sagemaniac

Joined: 2003-03-26
Posts: 47
Posted: Tue, 2010-06-15 19:57

Thanks for answering.
I have upgraded to the latest g3 code and now I get a better error message:

Failed to import Gallery 2 album with id 1114 and name Portraits. ORM validation errors: Array ( [sort_order] => invalid ) exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /var/www/clients/client1/web56

I will check this album and report back, nothing wrong on first look.

User emails all seem valid, I do not think there was a problem with user import.

 
sagemaniac

Joined: 2003-03-26
Posts: 47
Posted: Tue, 2010-06-15 21:17

Ok, I've done a bit more testing with the latest G3 code:

- when I activate comments module in G3, I still get a white screen upon using G 2 Import
- restarting the task from Maintenance just shows Starting up... for ever
- after turning comments off in G3, I can start G2 Import, which fails right away
- var logs now shows same error over and over:

2010-06-15 13:44:18 -07:00 --- error: exception 'G2_Import_Exception' with message 'Failed to import Gallery 2 album with id 1114 and name Portraits.
ORM validation errors: Array
(
[sort_order] => invalid
)

I have not been able to find out what an invalid sort_order really means. The album in question seems just fine in G2. I have tried sorting, moving, renaming and changing permissions of the album in G2 - get the same error message.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Tue, 2010-06-15 21:33

It's probably trying to import the same sort order you have in G2, but there's not a corresponding sort order in G3. At least that's my shot in the dark. In G2, try to set the sort order back to default. Edit Album > Album (tab)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
sagemaniac

Joined: 2003-03-26
Posts: 47
Posted: Wed, 2010-06-16 12:35
nivekiam wrote:
In G2, try to set the sort order back to default.

Thanks, yes, resetting to default did the trick. Plus I had to move one album to be a able to reset it's subfolders, it created a white screen upon click on edit album, so there must have been something wrong there.

Remains the problem with comments - still can't import those, and there is no error message, just a white screen in G3...

There are almost no entries anyway, so this does not matter - it is just puzzling ;)

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sun, 2010-08-01 15:24

I have this exact problem and tried everything mentioned above. I went to all my albums and set it to default sort order. The main theme has it set as manual sort order.

Ive never had this problem with G3 RC1 or prior, it always imported just fine. Not sure why RC2 feels the sort order is invalid.

Ive even set different sort orders on the album below of "Lucy" and still doesnt work.

===============

2010-08-01 08:08:44 -07:00 --- error: exception 'G2_Import_Exception' with message 'Failed to import Gallery 2 album with id 1981 and name Lucy.
ORM validation errors: Array
(
[sort_order] => invalid
)

exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /home/username/public_html/domainname/gallery3/system/libraries/ORM_Validation_Exception.php:20

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 25953
Posted: Mon, 2010-08-02 05:30

Please add your details to this ticket:
http://sourceforge.net/apps/trac/gallery/ticket/803

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7985
Posted: Wed, 2010-08-04 04:50

@DixitS: Please try the latest code from git (see my signature below) and if it still fails with the same album, please run the following SQL statement in your G2 database and let us know what you get:

mysql> SELECT * FROM g2_AlbumItem where g_id=1981;

---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Wed, 2010-08-04 05:42

Still fails with the latest code from Git. Same error too. Below is the error

Failed to import Gallery 2 album with id 1981 and name Lucy. ORM 
validation errors: Array ( [sort_order] => invalid ) exception 
'ORM_Validation_Exception' with message 'ORM Validation has failed 
for items model' in /home/username/public_html/domainname

When I run the SQL cmd I get the single line which is similar to almost every other line in that table.
==================
SQL query: SELECT * FROM g2_AlbumItem where g_id=1981 LIMIT 0, 30 ;
Rows: 1

g_id	g_theme	      g_orderBy	      g_orderDirection
1981	simplified	 	      asc

==================

All the records in the g2_AlbumItem have either a NULL/NULL in the g_orderBy and g_orderDirection or what you see above where its a blank for g_orderBy and asc for the g_orderDirection.

Dixit

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7985
Posted: Sat, 2010-08-07 04:33

Ok, we're gonna have to dig a little further. Edit modules/g2_import/helpers/g2_import.php and look for this code (I've added line numbers to make it easier to find):

   453        $g2_order_direction = explode("|", $g2_album->getOrderDirection() . "");                          
   454        $g2_order_direction = $g2_order_direction[0];                                                     
   455        if (empty($g2_order_direction)) {                                                                 
   456          $g2_order_direction =                                                                           
   457            g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection'));           
   458        }                                                                                                 
   459        if (array_key_exists($g2_order, $order_map)) {                                                    
   460          $album->sort_column = $order_map[$g2_order];                                                    
   461          $album->sort_order = $direction_map[$g2_order_direction];                                       
   462        }                                                                                                 
   463                                                                                                          
   464        try {                                                                                             
   465          $album->save();                                                                                 
   466        } catch (Exception $e) {                                                                          
   467          throw new G2_Import_Exception(                                                                  
   468              t("Failed to import Gallery 2 album with id %id and name %name.",                           
   469                array("id" => $g2_album_id, "name" => $album->name)),                                     
   470              $e);                                                                                        
   471        }                                                                                                 

It's the code that sets the order direction into the album that's busted. Let's tweak the code to dump out some extra debug info. Look for the lines without line numbers below, that's what we're adding:

   453        $g2_order_direction = explode("|", $g2_album->getOrderDirection() . "");                          
              Kohana_Log::add("error", "1: $g2_order_direction");
   454        $g2_order_direction = $g2_order_direction[0];                                                     
              Kohana_Log::add("error", "2: $g2_order_direction");
   455        if (empty($g2_order_direction)) {                                                                 
   456          $g2_order_direction =                                                                           
   457            g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection'));           
   458        }                                                                                                 
              Kohana_Log::add("error", "3: $g2_order_direction");
   459        if (array_key_exists($g2_order, $order_map)) {                                                    
   460          $album->sort_column = $order_map[$g2_order];                                                    
   461          $album->sort_order = $direction_map[$g2_order_direction];                                       
   462        }                                                                                                 
              Kohana_Log::add("error", "4: {$album->sort_order}");
   463                                                                                                          
   464        try {                                                                                             
   465          $album->save();                                                                                 
   466        } catch (Exception $e) {                                                                          
   467          throw new G2_Import_Exception(                                                                  
   468              t("Failed to import Gallery 2 album with id %id and name %name.",                           
   469                array("id" => $g2_album_id, "name" => $album->name)),                                     
   470              $e);                                                                                        
   471        }                                                                                                 

Then run it again. Then look in your logs and you should see a bunch of error lines marked 1, 2, 3, 4, etc. Report back with the last 1/2/3/4 set you find and that should give me enough clues to figure this out.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sat, 2010-08-07 15:35

This is what I got below. I believe you are interested in the first set of lines, but I just included the entire log file to see if that helps any.

I see 2 and 4 are blank or i guess NULL, not sure if thats a problem, but reading this thread you mention NULL shouldnt be a problem.

Dixit

<?php defined('SYSPATH') or die('No direct script access.'); ?>

2010-08-07 08:28:02 -07:00 --- error: 1: Array
2010-08-07 08:28:02 -07:00 --- error: 2: 
2010-08-07 08:28:02 -07:00 --- error: 3: 1
2010-08-07 08:28:02 -07:00 --- error: 4: 
2010-08-07 08:28:02 -07:00 --- error: exception 'G2_Import_Exception' with message 'Failed to import Gallery 2 album with id 1981 and name Lucy.
ORM validation errors: Array
(
    [sort_order] => invalid
)

exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /home/username/public_html/domainname/gallery3/system/libraries/ORM_Validation_Exception.php:20
Stack trace:
#0 /home/username/public_html/domainname/gallery3/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /home/username/public_html/domainname/gallery3/modules/gallery/models/item.php(774): ORM_Core->validate(NULL)
#2 /home/username/public_html/domainname/gallery3/system/libraries/ORM.php(778): Item_Model->validate()
#3 /home/username/public_html/domainname/gallery3/modules/gallery/libraries/MY_ORM.php(23): ORM_Core->save()
#4 /home/username/public_html/domainname/gallery3/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /home/username/public_html/domainname/gallery3/modules/gallery/models/item.php(392): ORM_MPTT_Core->save()
#6 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import.php(469): Item_Model->save()
#7 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import_task.php(130): g2_import_Core::import_album(Array)
#8 /home/username/public_html/domainname/gallery3/modules/gallery/helpers/task.php(90): g2_import_task_Core::import(Object(Task_Model))
#9 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin_maintenance.php(187): task_Core::run('g2_import_task:...', Array)
#10 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin.php(62): Admin_Maintenance_Controller->run('2')
#11 [internal function]: Admin_Controller->__call('2')
#12 /home/username/public_html/domainname/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Array, Array)
#13 /home/username/public_html/domainname/gallery3/system/core/Event.php(208): Kohana_Core::instance('maintenance', Array)
#14 /home/username/public_html/domainname/gallery3/application/Bootstrap.php(67): Event_Core::run(Object(Admin_Controller), Array)
#15 /home/username/public_html/domainname/gallery3/index.php(94): require('/home/username/...')
#16 {main}' in /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import.php:471
Stack trace:
#0 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import_task.php(130): g2_import_Core::import_album(Array)
#1 /home/username/public_html/domainname/gallery3/modules/gallery/helpers/task.php(90): g2_import_task_Core::import(Object(Task_Model))
#2 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin_maintenance.php(187): task_Core::run('g2_import_task:...', Array)
#3 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin.php(62): Admin_Maintenance_Controller->run('2')
#4 [internal function]: Admin_Controller->__call('2')
#5 /home/username/public_html/domainname/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Array, Array)
#6 /home/username/public_html/domainname/gallery3/system/core/Event.php(208): Kohana_Core::instance('maintenance', Array)
#7 /home/username/public_html/domainname/gallery3/application/Bootstrap.php(67): Event_Core::run(Object(Admin_Controller), Array)
#8 /home/username/public_html/domainname/gallery3/index.php(94): require('/home/username/...')
#9 {main}
 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7985
Posted: Sun, 2010-08-08 06:56

Hrm. Need a little bit more data.

Change this line:
Kohana_Log::add("error", "1: $g2_order_direction");

to:
Kohana_Log::add("error", "1: " . print_r($g2_order_direction, 1));

and let me know what you get this time.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sun, 2010-08-08 15:32

Here is the updated logfile with the new error log line you asked for.

<?php defined('SYSPATH') or die('No direct script access.'); ?>

2010-08-08 08:29:13 -07:00 --- error: 1: Array
(
    [0] => 
)

2010-08-08 08:29:13 -07:00 --- error: 2: 
2010-08-08 08:29:13 -07:00 --- error: 3: 1
2010-08-08 08:29:13 -07:00 --- error: 4: 
2010-08-08 08:29:13 -07:00 --- error: exception 'G2_Import_Exception' with message 'Failed to import Gallery 2 album with id 1981 and name Lucy.
ORM validation errors: Array
(
    [sort_order] => invalid
)

exception 'ORM_Validation_Exception' with message 'ORM Validation has failed for items model' in /home/username/public_html/domainname/gallery3/system/libraries/ORM_Validation_Exception.php:20
Stack trace:
#0 /home/username/public_html/domainname/gallery3/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /home/username/public_html/domainname/gallery3/modules/gallery/models/item.php(774): ORM_Core->validate(NULL)
#2 /home/username/public_html/domainname/gallery3/system/libraries/ORM.php(778): Item_Model->validate()
#3 /home/username/public_html/domainname/gallery3/modules/gallery/libraries/MY_ORM.php(23): ORM_Core->save()
#4 /home/username/public_html/domainname/gallery3/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /home/username/public_html/domainname/gallery3/modules/gallery/models/item.php(392): ORM_MPTT_Core->save()
#6 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import.php(469): Item_Model->save()
#7 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import_task.php(130): g2_import_Core::import_album(Array)
#8 /home/username/public_html/domainname/gallery3/modules/gallery/helpers/task.php(90): g2_import_task_Core::import(Object(Task_Model))
#9 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin_maintenance.php(187): task_Core::run('g2_import_task:...', Array)
#10 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin.php(62): Admin_Maintenance_Controller->run('3')
#11 [internal function]: Admin_Controller->__call('3')
#12 /home/username/public_html/domainname/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Array, Array)
#13 /home/username/public_html/domainname/gallery3/system/core/Event.php(208): Kohana_Core::instance('maintenance', Array)
#14 /home/username/public_html/domainname/gallery3/application/Bootstrap.php(67): Event_Core::run(Object(Admin_Controller), Array)
#15 /home/username/public_html/domainname/gallery3/index.php(94): require('/home/username/...')
#16 {main}' in /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import.php:471
Stack trace:
#0 /home/username/public_html/domainname/gallery3/modules/g2_import/helpers/g2_import_task.php(130): g2_import_Core::import_album(Array)
#1 /home/username/public_html/domainname/gallery3/modules/gallery/helpers/task.php(90): g2_import_task_Core::import(Object(Task_Model))
#2 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin_maintenance.php(187): task_Core::run('g2_import_task:...', Array)
#3 /home/username/public_html/domainname/gallery3/modules/gallery/controllers/admin.php(62): Admin_Maintenance_Controller->run('3')
#4 [internal function]: Admin_Controller->__call('3')
#5 /home/username/public_html/domainname/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Array, Array)
#6 /home/username/public_html/domainname/gallery3/system/core/Event.php(208): Kohana_Core::instance('maintenance', Array)
#7 /home/username/public_html/domainname/gallery3/application/Bootstrap.php(67): Event_Core::run(Object(Admin_Controller), Array)
#8 /home/username/public_html/domainname/gallery3/index.php(94): require('/home/username/...')
#9 {main}
 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7985
Posted: Sun, 2010-08-08 17:15

Ok, I think I've got my fingers around the neck of this bug. We made some weird decisions in G2! Filed https://sourceforge.net/apps/trac/gallery/ticket/1276 and fixed it in git -- want to upgrade to the latest code and try it out?
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sun, 2010-08-08 17:33

Wow that was fast!!! Its definitely working now. I got about 1000+ photos in this gallery2 thats its importing and so far upto 100, which is way further then it used to be where it errored right off the bat.

Looks like you definitely fixed this bug, good work Bharat!

Dixit

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7985
Posted: Sun, 2010-08-08 18:03

Couldn't have done it without you. Thanks DixitS!
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git