Announcement

  •  » Beta testing
  •  » Metadata Sync does not collect any files/albums to synchronize

#1 2020-11-11 11:16:44

AlexDebri
Member
2020-08-21
5

Metadata Sync does not collect any files/albums to synchronize

Hello there,

thanks for the continuous development on piwigo :-)

I just installed the latest beta, because I wanted to see, if the metadata synchronization is fixed now.

But It is still broken.

I think the problem has something to do with multi-site feature. I'm running without multisite feature enabled.

In site_update.php:835 we have this call:

Code:

  $files = get_filelist($opts['category_id'], $site_id,
                        $opts['recursive'],
                        $opts['only_new']);

In get_filelist (functions_metadata.php:311)  we have this query:

Code:

SELECT id
  FROM '.CATEGORIES_TABLE.'
  WHERE site_id = '.$site_id.'
    AND dir IS NOT NULL';

This wil never return any item from the categories table.

1. dir is always NULL in my categories table (does it make sense to include it in the query?)
2. site_id is always NULL in my categories table (but $site_id param defaults to 1)

I think the function maybe needs an bugfix, so that it also works with non-multi-site instances.

What do you think about it? Mayb this can be fixed in the next release?

Last edited by AlexDebri (2020-11-11 11:19:03)

Offline

 

#2 2020-11-11 11:40:45

erAck
Only trying to help
2015-09-06
650

Re: Metadata Sync does not collect any files/albums to synchronize

Are you even using physical albums and syncing? Because dir and site_id are not NULL only then, and it's all about synchronizing metadata.


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2020-11-11 11:46:52

AlexDebri
Member
2020-08-21
5

Re: Metadata Sync does not collect any files/albums to synchronize

Are you even using physical albums and syncing? Because dir and site_id are not NULL only then, and it's all about synchronizing metadata.

Hello erAck!

In the end, all files are stored at a physical location and metadata can be read from the files located there, so  the database fields can be updated with the values from these files.

Also, thats what the function comment says:

Code:

/**
 * Sync all metadata of a list of images.
 * Metadata are fetched from original files and saved in database.
 *
 * @param int[] $ids
 */
function sync_metadata($ids)
{
...

When I open the site-management page i see 1 entry, I'm not sure if that is correct?

Code:

Directory Action
./galleries/
(Lokal, 0 Alben, 0 Foto)  [Synchronisieren]

When uploading files as admin, the metadata is perfectly synced into the mapped fields. Howerver, using the community upload, the metadata ist not put into the mapped fields. That's why I'm interested in this sync thing. :-)

Last edited by AlexDebri (2020-11-11 11:51:46)

Offline

 

#4 2020-11-11 16:35:17

AlexDebri
Member
2020-08-21
5

Re: Metadata Sync does not collect any files/albums to synchronize

I have found the real problem.

The Metadata is correctly synchronized when the community plugin uploads the files. However, afterwards it calls pwg.images.setInfo without further check, so that the metadata values gets overwritten with empty strings.

Here is the patch for the community plugin template, so that it only overwrites fields that have user supplied content:

Code:

git diff plugins/community/add_photos.tpl
diff --git a/plugins/community/add_photos.tpl b/plugins/community/add_photos.tpl
index 0152d3b..d463fbb 100644
--- a/plugins/community/add_photos.tpl
+++ b/plugins/community/add_photos.tpl
@@ -290,16 +290,28 @@ var limit_storage = {$limit_storage};
         uploadedPhotos.push(parseInt(data.result.image_id));
         uploadCategory = data.result.category;

+        // Improved handling of settings override:
+        var postParams = {
+            single_value_mode: "replace",
+            image_id: data.result.image_id
+        };
+
+        if(jQuery("input[name=author]").val().length > 0) {
+          postParams.author = jQuery("input[name=author]").val();
+        }
+
+        if(jQuery("input[name=name]").val().length > 0) {
+          postParams.name = jQuery("input[name=name]").val();
+        }
+
+        if(jQuery("textarea[name=description]").val().length > 0) {
+          postParams.comment = jQuery("textarea[name=description]").val();
+        }
+
         jQuery.ajax({
           url: rootUrl + "ws.php?format=json&method=pwg.images.setInfo",
           type:"POST",
-          data: {
-            single_value_mode: "replace",
-            image_id: data.result.image_id,
-            author: jQuery("input[name=author]").val(),
-            name: jQuery("input[name=name]").val(),
-            comment: jQuery("textarea[name=description]").val(),
-          },
+          data: postParams,
           dataType: "json",
           success:function(data) {
             console.log(data);

Maybe you want to add it to the official repository.

Offline

 

#5 2020-11-11 17:29:41

erAck
Only trying to help
2015-09-06
650

Re: Metadata Sync does not collect any files/albums to synchronize

Please create an issue at https://github.com/plegall/Piwigo-community/issues and if possible submit a pull request or at least post the patch in the issue.


Running Piwigo at https://erack.net/gallery/

Offline

 
  •  » Beta testing
  •  » Metadata Sync does not collect any files/albums to synchronize

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2020 · Contact