Hello!
I am checking out Piwigo and am trying to migrate two G3 using this plugin. The first G3 import seemed to work fine: I copied the physical file structure to the Piwigo galleries, ran the synchronize, confirmed the numbers of photos/albums matched, and submitted the form ... no problems! Spot checking my photos the tags, descriptions, etc. seem to have come across. The only thing missing is maybe rotation information and album highlights? No big deal.
So then I tried my second G3 installation (note I am trying to merge both old G3 installations, each with their own MySQL database, into a single Piwigo installation). I put the new folders under the galleries directory, ran the synchronization, confirmed import numbers matched. Then when I tried to submit the form I got these errors:
Notice: Undefined variable: cover_id in /var/www/public/photos/plugins/menalto2piwigo/admin.php on line 577 Warning: Invalid argument supplied for foreach() in /var/www/public/photos/plugins/menalto2piwigo/admin.php on line 577 Notice: Undefined variable: image_updates in /var/www/public/photos/plugins/menalto2piwigo/admin.php on line 695 Notice: Undefined variable: cat_updates in /var/www/public/photos/plugins/menalto2piwigo/admin.php on line 704 Notice: Undefined variable: album_thumbs in /var/www/public/photos/plugins/menalto2piwigo/admin.php on line 713
And it doesn't look like any of the G3 info (tags, descriptions, etc.) have come across. How can I troubleshoot this?
Thanks!
P.S. One other thing, I've tried downloading the latest version of the plugin (2.7.c?) from GitHub and updating it manually just to see if maybe something was fixed, but same problem.
Piwigo version: 2.7.2
PHP version: 5.5.12-2ubuntu4.1
MySQL version: 5.5.40-0ubuntu1
Offline
Doing some more poking around, it looks like my tags from the second G3 gallery were imported, as under Tags in Piwigo it says I have 13,407 orphaned tags and they seem to be the ones from that second gallery.
Offline
Any ideas on how I can troubleshoot this? I suspect it's because I'm trying to import a second G3 database into an existing PWG database using the plugin a second time. I tried putting some debug/echo commands in admin.php but they don't appear anywhere.
I did turn on SQL, and I can see it inserting all of my G3 tags into the PWG tags table (that's why every time I run the plugin and it crashes I end up with duplicate, orphaned tags, so I keep cleaning those out every time). After the tags insert, I just see these two statements:
SELECT id, name FROM tags ; (this query time : 0.020 s) (total SQL time : 1.049 s) (total time : 2.901 s) (num rows : 4739 ) [23] SELECT mail_address FROM users WHERE id = 1 ; (this query time : 0.000 s) (total SQL time : 1.049 s) (total time : 3.668 s) (num rows : 1 )
(That mail_address query always seems to be the last one so I'm guessing that some internal PWG thing). Looking at admin.php, it looks like this is the first line causing the error:
$cover_id[$cat_id] = $row['album_cover_item_id'];
From what I can tell, that's trying to determine the album cover image and maybe getting no value, which causes $cover_id to be "undefined?" Then that is fed into the album cover id loop foreach and causes the "invalid argument?"
I'm just speculating. I'm pretty good at debugging and SQL but not that great at PHP and totally new to PWG, so I'm trying to figure out how to debug all of this. Any hints would be appreciated!
Offline
Figured it out!!
The problem was the relative_url_cache field in my G3 items table. At the beginning of the module, the path from the images table is populated into the $piwigo_paths array. Later on, when creating the map between the G3 and PWG items, the code tries to match the relative_url_cache field from the G3 items table to the filepath in PWG.
The first G3 gallery I imported had a structure like this:
root main album 1 album a album b ... etc main album 2 album c album d ... etc main album 3 main album 4
I kept this same structure when I moved the gallery into PWG's /galleries/ folder and synchronized, so the paths matched and I had no problems.
In my second gallery, the one giving me headaches, my structure was basically the same as the above, except when I moved it into the /galleries/ folder to synchronize, I put it under one of the existing albums (since it made structural sense and I was trying to combine the two galleries). This meant that the PWG path on the images table didn't match the relative_path_cache path from gallery.
For example, in G3 the relative_path_cache was:
- album f/2004/2004-01
- album f/2004/2004-02
But in PWG it was now:
- main album 1/album f/2004/2004-01
- main album 1/album f/2004/2004-02
So when the code searched the $piwigo_paths array, it couldn't find a match and that was the cause of the undefined variables and such.
To fix this, I just prepended the new PWG path to the values in the relative_path_cache column in the G3 database. Then the plugin ran normally and successfully! I then removed the prepended text since that was breaking G3 (although that won't matter for long since I'll be turning it off).
Anyway, this was a good learning experience for me as I learn my way around Piwigo, the database, and such. Hope this helps someone else who may be migrating from Gallery like I am.
Offline