The view_3 property does not exist in the Item_Model class - Possibly solved

coldpenguin

Joined: 2009-04-22
Posts: 15
Posted: Fri, 2013-10-18 17:12

So I have seen a few people report this issue, a while ago, but no real resolutions, or ideas on why it happened (that I could see).

My configuration is going to be 'difficult'
I am upgrading to a new server, AND upgrading to gallery3 at the same time.

So server1, had the http and database on the same machine.
Server2, has the database and http on different machines.

I have installed G3 rpm on Centos, and done the update within the admin GUI.
I then immediately went to modules, added the G2 import module.
I have mounted using NFS the two directories used for G2 on server1, onto the correct areas on server2 (I will be using different directories eventually).
I have modified the SQL service for server1 so that server3 can now authenticate using the correct credentials.

Going to the G2 import module, I get the option to select the place of embed.php
Then:
---
Gallery version 2.3 detected
Your most common thumbnail size in Gallery 2 is 150 pixels, but your Gallery 3 thumbnail size is set to 200 pixels. Using the same value will speed up your import.
Your Gallery 2 has the following importable data in it: 16 users, 4 groups, 234 albums, 19500 photos/movies, 1 comment, 17 tagged photos/movies/albums
---

When I go to import.....
---
The view_3 property does not exist in the Item_Model class
---
If I attempt to import again, it recognises the users and groups. It also attempts to re-import the first album, and then it does again.

So where do I start to look? At the gallery2 database? I can't see a view_3. In the G3 database, I see a view_2, but that is a table schema.
The G2 server is 2.3-14, unfortunately rpm updates are no longer available for that system. Don't particularly want to do a source code update if I can avoid it.

 
coldpenguin

Joined: 2009-04-22
Posts: 15
Posted: Fri, 2013-10-18 17:20

Error log, doesn't exactly expand on things:
2013-10-18 16:46:22 +00:00 --- error: exception 'Kohana_Exception' with message 'The view_3 property does not exist in the Item_Model class' in /usr/share/gallery3/system/libraries/ORM.php:398
Stack trace:
#0 /usr/share/gallery3/modules/gallery/models/item.php(338): ORM_Core->__get('view_3')
#1 /usr/share/gallery3/modules/gallery/helpers/access.php(149): Item_Model_Core->__get('view_3')
#2 /usr/share/gallery3/modules/g2_import/helpers/g2_import.php(825): access_Core::group_can(Object(Group_Model), 'view', Object(Item_Model))
#3 /usr/share/gallery3/modules/g2_import/helpers/g2_import.php(488): g2_import_Core::_import_permissions(Object(GalleryAlbumItem), Object(Item_Model))
#4 /usr/share/gallery3/modules/g2_import/helpers/g2_import_task.php(137): g2_import_Core::import_album(Array)
#5 [internal function]: g2_import_task_Core::import(Object(Task_Model))
#6 /usr/share/gallery3/modules/gallery/helpers/task.php(90): call_user_func_array('g2_import_task:...', Array)
#7 /usr/share/gallery3/modules/gallery/controllers/admin_maintenance.php(195): task_Core::run('1')
#8 [internal function]: Admin_Maintenance_Controller->run('1')
#9 /usr/share/gallery3/modules/gallery/controllers/admin.php(62): call_user_func_array(Array, Array)
#10 [internal function]: Admin_Controller->__call('maintenance', Array)
#11 /usr/share/php/Kohana/system/core/Kohana.php(303): ReflectionMethod->invokeArgs(Object(Admin_Controller), Array)
#12 [internal function]: Kohana_Core::instance(NULL)
#13 /usr/share/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#14 /usr/share/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#15 /usr/share/gallery3/index.php(116): require('/usr/share/gall...')
#16 {main}

 
coldpenguin

Joined: 2009-04-22
Posts: 15
Posted: Fri, 2013-10-18 18:13

Looks like for some reason the mysql_setpermissions I was using, whilst pretending to grant full permissions, didn't

Log into the mysql server as the admin user, and run:

update db set alter_priv="y" where user="<gallery user>";
flush privileges;

This appears to add the alter privilege which was missing.

The import is now progressing further (and taking somewhat longer)

Possibly it would be wise for the gallery installer to check that the correct permissions exist for the database user. I don't think this should be too difficult?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-10-18 21:20
Quote:
Possibly it would be wise for the gallery installer to check that the correct permissions exist for the database user. I don't think this should be too difficult?

I don't think is "should" be too hard to detect. Perhaps you can look to see how other open source projects do this and submit a ticket with those suggestions.

Cheers!
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
coldpenguin

Joined: 2009-04-22
Posts: 15
Posted: Sat, 2013-10-19 10:21

I think something like the following would probably do (bit of a hack, the regular expression could do with some extra work, but it is better than the nothing there currently is!), but where to put it.....

 <?php

$server="";
$user="";
$pass="";
$db="";

#pass
$privs=array("ALTER","SELECT","UPDATE","DELETE","CREATE","DROP");
#fail
$privs=array("ALTER","SELECT","UPDATE","DELETE","CREATE","DROP","Notthere");

$link=mysql_connect($server, $user, $pass);
mysql_select_db($db);
$query="Show grants";
$fails=array();
$found=0;
if($result=mysql_query($query)){
        $found=1;
        while($row=mysql_fetch_array($result)){
                if(preg_match("/SELECT/",$row[0])){
                        foreach($privs as &$privilege){
                                if(!preg_match("/$privilege/",$row[0])){
                                        $found=0;
                                        array_push($fails,$privilege);
                                }else{
                                        #We don't really need to test here
                                }
                        }
                }
        }
        if(1==$found){
                echo "All privileges have been checked and are OK\n<br>";
        }else{
                echo "Some privileges are missing for this user\n<br>The following extra privileges are required:\n<br>";
                foreach($fails as $failure){
                        echo "$failure\n<br>";
                }
        }
}else{
        echo "Could not connect to the database to check privileges\n<br>";
}
?>