Fixed PhotoPost Pro Importer: Member albums not imported into correct category

Kirby

Well-known member
Affected version
2.2.2
In PhotoPost Pro, users were able to create member albums which were shown when viewing category 500.

The importer does import those as albums, but does not set the parent caegory which is problematic for redirection scripts as it isn't possible to correctly redirect URLs like showgallery.php?cat=500&ppuser=<userid>

I therefore suggest to change the step order (eg. import categories before importing albums) and set the parent to imported category 500 when importing albums.
 
Based on what you've said, I've currently got these changes outstanding:

Diff:
Index: src/addons/XFMG/Import/Importer/PhotopostPro.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/addons/XFMG/Import/Importer/PhotopostPro.php b/src/addons/XFMG/Import/Importer/PhotopostPro.php
--- a/src/addons/XFMG/Import/Importer/PhotopostPro.php    (revision Staged)
+++ b/src/addons/XFMG/Import/Importer/PhotopostPro.php    (date 1625497304318)
@@ -204,12 +204,12 @@
     public function getSteps()
     {
         return [
-            'albums' => [
-                'title' => \XF::phrase('xfmg_albums')
-            ],
             'categories' => [
                 'title' => \XF::phrase('xfmg_categories')
             ],
+            'albums' => [
+                'title' => \XF::phrase('xfmg_albums')
+            ],
             'mediaItems' => [
                 'title' => \XF::phrase('xfmg_media_items'),
                 'depends' => ['albums', 'categories']
@@ -301,6 +301,12 @@
                 'media_count' => 'photos'
             ]));
 
+            if ($album['ismember'] || $oldId == 500)
+            {
+                $categoryId = $this->lookupId('xfmg_category', $oldId, 0);
+            }
+
+            $albumImport->category_id = $categoryId ?? 0;
             $albumImport->user_id = $userId;
             $albumImport->create_date = $createDate;
             $albumImport->view_privacy = $album['private'] == 'yes' ? 'private' : 'public';

I don't have a significant amount of data to test against. Is this what you had in mind and does this seem to work against the data you have?

In summary, this simply moves the category step to happen first, and we attempt to add the album to the album category for the member album if the original "album" appears to have been a member category.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.2.3).

Change log:
Adjust order of import steps from PhotoPost Pro to ensure member albums are imported into categories.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom