List CSV Import problems

Bauer

Well-Known Member
I had been using the CSV import'/export list plugin on 7 lists - but the import no longer works.
I'm getting an error message "Import Failed! Invalid file format..."

Looking at the code (line 200 of importcsv.php) I see this returns an empty string - which causes the error.
PHP:
$allowedlist = FabrikWorker::getMenuOrRequestVar('csv_import_extensions','',false,'menu');

Is anyone else who is also using recent github code having this same problem? I don't remember the last time I tried importing a file - but its been a while - and it used to work just fine.

I vaguely remember problems with this before - which happened because the Import page is a new page (independent of the actual list menu item) so the menu configuration settings that are being sought via that getMenuOrRequestVar function, like the "Valid file types" setting, are lost to that importcsv.php code.

I hope this isn't 'just me' and it can be fixed - because I have no idea how to fix it.:(
 
Yes. I was the one to push for adding those features.
I was then using it to import/export Excel files directly into these tables.

It's not just the valid file types - ALL of the parameters from the menu (like 'Show in list') are blank now from inside importcsv.php.
 
Yup, those menu vars were a PR I merged from you. But looking at the code, I don't see how they could ever have worked, because the Itemid wasn't getting passed through into the import view, and hence wasn't getting passed to the actual import task. That requires adding it to the import CSV link, then adding it as a hidden field in the import view (see first commit below).

Also ... the J! router doesn't seem to set the active menu if you aren't coming in through a view=foo, which the actual import doesn't (it's a task=foo.bar). So we'll have the manually set the active menu on the controller entry point (see second commit). Although that might be a side effect of recent changes to the J! router.

https://github.com/Fabrik/fabrik/commit/4a89586c0651ae243c2a0926278e43a954dac246
https://github.com/Fabrik/fabrik/commit/eb5b1836924278e8ac7a90f87efc5ce127d4c1ef

Anyway, should work now.

-- hugh
 
Well I'm glad somebody knows what's going on here. You're a lifesaver, Hugh!
(Though I haven't updated/tested yet.)

I'm pretty sure I had also made a change in view.base.php - and maybe that never got included in the pull request (you know the history of my fragmented pull requests). Because it did work.

In trying to figure this out last night I came to realize that the Worker.php file containing that function getMenuOrRequestVar must have been moved (because my file dates were old in /components/com_fabrik/fabrik/fabrik/Helpers).

I also came across this change I had made in importcsv.php line 1343
PHP:
        // Reimporting into existing list - should return true
        // $$ Phil changed because if from frontend menu $task is 'input.doimport'
        // if ($input->getInt('listid') !== 0 && $task === 'doimport')
        if ($input->getInt('listid') !== 0 && strpos($task,'doimport') !== false)

So I did a global search for 'doimport' and found 2 other places where this might be an issue (??? because the value of $task could be 'input.doimport' and not just 'doimport' ???)...
In list.php line 7712 - should that be changed to?...
PHP:
            if (
                ($this->importingCSV && !$this->csvOverwriting)
                || ( ($primaryKey !== '' && $table->auto_inc == true) && strpos($task,'doimport') !== false )
            )

In user.php line 223 - should that be changed to?...
PHP:
            if ($input->getString('rowid', '', 'string') == '' && strpos($input->get('task'), 'doimport') == false)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top