[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] tabular imports: return formatted data after import from the API, so the...

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68b8207610898_2c138aff812095@gitlab-sidekiq-low-urgency-cpu-bound-v2-dc78c9688-p2wnj.mail>

Victor Emanouilov pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
6812008a by Victor Emanouilov at 2025-09-03T14:03:11+03:00
[FIX] tabular imports: return formatted data after import from the API, so the remote point can sync any PKs or other data if needed

- - - - -


2 changed files:

- lib/core/Services/Tracker/TabularController.php
- lib/core/Tracker/Tabular/Writer/TrackerWriter.php


Changes:

=====================================
lib/core/Services/Tracker/TabularController.php
=====================================
@@ -12,6 +12,7 @@ use Tracker\Tabular\Source\CsvSource;
 use Tracker\Tabular\Schema;
 use Tracker\Tabular\Source\PaginatedQuerySource;
 use Tracker\Tabular\Source\QuerySource;
+use Tracker\Tabular\Source\TrackerSourceEntry;
 use Tracker\Tabular\Writer\APIWriter;
 use Tracker\Tabular\Writer\HtmlWriter;
 use Tracker\Tabular\Writer\ODBCWriter;
@@ -557,15 +558,25 @@ class Services_Tracker_TabularController
 
             return TikiLib::lib('tiki')->allocate_extra(
                 'tracker_import_items',
-                function () use ($writer, $source, $info) {
-                    $writer->write($source);
+                function () use ($writer, $source, $info, $schema) {
+                    $result = $writer->write($source);
 
                     unlink($_FILES['file']['tmp_name']);
 
                     $message = tr('Your import was completed successfully.');
 
                     if (TIKI_API) {
-                        return ['feedback' => $message];
+                        $data = [];
+                        $columns = $schema->getColumns();
+                        foreach ($result as $itemId) {
+                            $entry = new TrackerSourceEntry($itemId);
+                            $row = ['itemId' => $itemId];
+                            foreach ($columns as $column) {
+                                $row[$column->getField()] = $entry->render($column, false);
+                            }
+                            $data[] = $row;
+                        }
+                        return $data;
                     }
 
                     Feedback::success($message);


=====================================
lib/core/Tracker/Tabular/Writer/TrackerWriter.php
=====================================
@@ -132,7 +132,7 @@ class TrackerWriter
 
         $definition = $schema->getDefinition();
 
-        $iterate(function ($line, $info, $columns) use ($utilities, $definition, $schema) {
+        $result = $iterate(function ($line, $info, $columns) use ($utilities, $definition, $schema) {
             try {
                 if (! isset($info['status'])) {
                     $info['status'] = '';
@@ -184,7 +184,7 @@ class TrackerWriter
             $source->importSuccess();
         }
 
-        return true;
+        return $result;
     }
 
     /**



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6812008ac6999e510de6a9b3e3c78da2f0aff106

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6812008ac6999e510de6a9b3e3c78da2f0aff106
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.