Server error: Error #2038 (IO) with gallery 3.0.8

sburg

Joined: 2014-02-06
Posts: 3
Posted: Thu, 2014-02-06 13:06

Hi,

I am having problems running a newly installed gallery 3.0.8.

Whenever I try to upload pictures (size doesn't matter here) I am getting
an error message like "Server error: Error #2038 (IO)". Still, after
refreshing the site, all uploaded pictures appear. Further, I can exclude any
server/permission/php issues from the list of potential errors. I went down this road already.
In the logs found the following:

Quote:
error: ORM Validation has failed for items model
#0 htdocs/gallery/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 htdocs/gallery/modules/gallery/models/item.php(738): ORM_Core->validate(NULL)
#2 htdocs/gallery/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 htdocs/gallery/modules/gallery/libraries/MY_ORM.php(23): ORM_Core->save()
#4 htdocs/gallery/modules/gallery/libraries/ORM_MPTT.php(79): ORM->save()
#5 htdocs/gallery/modules/gallery/models/item.php(419): ORM_MPTT_Core->save()
#6 htdocs/gallery/modules/gallery/helpers/item.php(116): Item_Model_Core->save()
#7 htdocs/gallery/modules/gallery/helpers/gallery_event.php(95): item_Core::make_album_cover(Object(Item_Model))
#8 htdocs/gallery/modules/gallery/helpers/module.php(378): gallery_event_Core::item_created(Object(Item_Model))
#9 htdocs/gallery/modules/gallery/models/item.php(403): module_Core::event('item_created', Object(Item_Model))
#10 htdocs/gallery/modules/gallery/controllers/uploader.php(74): Item_Model_Core->save()
#11 [internal function]: Uploader_Controller->add_photo('1')
#12 htdocs/gallery/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Uploader_Controller), Array)
#13 [internal function]: Kohana_Core::instance(NULL)
#14 htdocs/gallery/system/core/Event.php(208): call_user_func_array(Array, Array)
#15 htdocs/gallery/application/Bootstrap.php(79): Event_Core::run('system.execute')
2014-02-06 09:34:31 +01:00 --- error: Validation errors: Array
(
[title] => required
)

Obviously the "title" attribute of item-Objects can't be validated correctly, but
after the upload has been finished, all photos have a title (which is the filename without extension).
So it seems everything works even with the error message.

After digging into the code I found the validation setup for item objects
under models/item.php:

Quote:
public function validate(Validation $array=null) {
if (!$array) {
$this->rules = array(
"album_cover_item_id" => array("callbacks" => array(array($this, "valid_album_cover"))),
"description" => array("rules" => array("length[0,65535]")),
"mime_type" => array("callbacks" => array(array($this, "valid_field"))),
"name" => array("rules" => array("length[0,255]", "required"),
"callbacks" => array(array($this, "valid_name"))),
"parent_id" => array("callbacks" => array(array($this, "valid_parent"))),
"rand_key" => array("rule" => array("decimal")),
"slug" => array("rules" => array("length[0,255]", "required"),
"callbacks" => array(array($this, "valid_slug"))),
"sort_column" => array("callbacks" => array(array($this, "valid_field"))),
"sort_order" => array("callbacks" => array(array($this, "valid_field"))),
- "title" => array("rules" => array("length[0,255]", "required")),
+ //"title" => array("rules" => array("length[0,255]", "required")),
"type" => array("callbacks" => array(array($this, "read_only"),
array($this, "valid_field"))),
);

After commenting out the "title" attribute everything works just fine. There is no more error
message or any other strange behaviour. This was just trial and error but at least I was able to narrow
down the problem space.

I would be grateful for any help / suggestions. Thanks in advance.

 
sburg

Joined: 2014-02-06
Posts: 3
Posted: Thu, 2014-02-06 14:43

Hi again,

I think I found the problem. Every time an item is uploaded all items, also the ones stored in the database, are being validated.

The validation rules forbid empty titles. Since all my uploaded pictures show up with a title I thought maybe the database contains
invalid items, so I checked and got the following:

Quote:
mysql> select id, name, title from items;
+----+--------------+-------+
| id | name | title |
+----+--------------+-------+
| 1 | NULL | |
| 6 | photo.JPG | photo |
| 7 | rhino.jpeg | rhino |
| 8 | photo-01.JPG | photo |
+----+--------------+-------+

While debugging, I dumped the object causing the stacktrace. Here it is:

Quote:
[object:protected] => Array
(
[id] => 1
[album_cover_item_id] => 8
[captured] =>
[created] => 1309327982
[description] =>
[height] =>
[left_ptr] => 1
[level] => 1
[mime_type] =>
[name] =>
[owner_id] => 2
[parent_id] => 0
[rand_key] =>
[relative_path_cache] =>
[relative_url_cache] =>
[resize_dirty] => 1
[resize_height] =>
[resize_width] =>
[right_ptr] => 8
[slug] =>
[sort_column] => weight
[sort_order] => ASC
[thumb_dirty] => 1
[thumb_height] => 0
[thumb_width] => 0
[title] =>
[type] => album
[updated] => 1391695926
[view_count] => 9
[weight] => 1
[width] =>
[view_1] => 1
[view_2] => 1
)

Interesting is this:

Quote:
[id] => 1
[title] =>
[type] => album

This is the root album, which exists by default. Since its title is empty it violates the validation rules and also causes the stacktrace
in the end. So I tried to manually give it a name as in

Quote:
mysql> update items set title = "foo" where id = 1;
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select id, name, title from items;
+----+--------------+-------+
| id | name | title |
+----+--------------+-------+
| 1 | NULL | foo |
| 6 | photo.JPG | photo |
| 7 | rhino.jpeg | rhino |
| 8 | photo-01.JPG | photo |
+----+--------------+-------+
4 rows in set (0.00 sec)

After that, no more errors or stacktraces. It seems everything works fine now. But, why does it seem I am the only one experiencing
this error. Maybe something went wrong during the installation. As mentioned before, this is a new installation, no upgrade or
something.

Should I report this as a bug ?

Thanks

 
sburg

Joined: 2014-02-06
Posts: 3
Posted: Thu, 2014-02-06 15:40

Hi again,

so I checked on github, how the database is installed initially. As you can see in

https://github.com/gallery/gallery3/blob/master/installer/install.sql

the items database is set up correctly:

INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1');

I really don't get why my items table was missing this 'gallery' value. However, I reinstalled gallery and now everything works as it should.

Sorry for the noise anyway.