adrianbj / tablecsvimportexport Goto Github PK
View Code? Open in Web Editor NEWProcesswire module for admin and front-end importing and exporting of CSV formatted content for Profields Table fields.
License: GNU General Public License v2.0
Processwire module for admin and front-end importing and exporting of CSV formatted content for Profields Table fields.
License: GNU General Public License v2.0
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.