Git Product home page Git Product logo

tablecsvimportexport's People

Contributors

adrianbj avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

polvanrijn

tablecsvimportexport's Issues

php7 - variable handling issue on import

Hi

I stumbled across a problem while testing the new ProFieldsTable v14 with this Import Module.
On CSV Import it adds the correct amount of rows but all of them have empty values.

This issue only occurs with PHP7.

After enabling debug it gave me following PHP Notice...
Notice: Indirect modification of overloaded property TableRow::$Array has no effect in
( https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L339 )

I nailed it down to the new variable handling of PHP7:
http://php.net/manual/de/migration70.incompatible.php#migration70.incompatible.variable-handling

The curly braces are needed. for example:
$tableEntry->$subfieldNames[$subfieldKey] =
to:
$tableEntry->{$subfieldNames[$subfieldKey]} =

I added curly braces in the if/else section from Line 327 to 339:

if($fieldType == 'pageSelect' || $fieldType == 'pageRadios') {
                        $tableEntry->{$subfieldNames[$subfieldKey]} = wire('pages')->get("{$fieldSelector}, title={$fieldValue}")->id;
                    }
                    elseif($fieldType == 'pageSelectMultiple' || $fieldType == 'pageAsmSelect' || $fieldType == 'pageCheckboxes') {
                        foreach(explode($importMultipleValuesSeparator, $fieldValue) as $title) {
                            $tableEntry->{$subfieldNames[$subfieldKey]}->add(wire('pages')->get("{$fieldSelector}, title={$title}")->id);
                        }
                    }
                    elseif($fieldType == 'selectMultiple') {
                        $tableEntry->{$subfieldNames[$subfieldKey]} = explode($importMultipleValuesSeparator, $fieldValue);
                    }
                    else {
                        //$tableEntry->$subfieldNames[$subfieldKey] = $convertDecimals == true ? $this->convertDecimals($fieldValue) : $fieldValue; // old, does not work in php7
                        $tableEntry->{$subfieldNames[$subfieldKey]} = $convertDecimals == true ? $this->convertDecimals($fieldValue) : $fieldValue; // new with curly braces
                        //$tableEntry->set($subfieldNames[$subfieldKey],$convertDecimals == true ? $this->convertDecimals($fieldValue) : $fieldValue); // would work also
                    }

after that the column values are imported correctly. At least for last "else". I didn´t test all of the other "elseif" statements, but it should be good to go...

can you confirm this issue?
regards, tom

Call to a member function add() on null

I exported a CSV and re-imported it and got an error (also with fresh data):
File: .../TableCsvImportExport.module.php:463
Call to a member function add() on null

The PageTable Field has the following columns:
-Text
-Tiny Integer Unsigned
-Textarea
-Page (Select Multiple/Sortable ASM)
-Page (Select Multiple/Sortable ASM)

--
PW 3.0.126
TableCsvImportExport 2.0.8
PHP 7.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.