EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #10445


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] bug or feature: zero valued float export couldn't be re-imported


Hi Thomas,

This was a fun little problem.  As is often the case with EPrints, where quite a bit of drilling down is needed to find something that in the end is very simple to fix.  I have submitted a fix for this under the GitHub issue I created for it:

https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprints%2Feprints3.4%2Fissues%2F650&data=05%7C02%7Ceprints-tech%40ecs.soton.ac.uk%7Ccb4f4c1367614b70678608df4d7cf4b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C639314871217758399%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=awaL%2BP2FTPM7KRFWqqnjX31U6ixPcL3E6cFlVfCs1IY%3D&reserved=0

Basically, a check for whether a variable is false (i.e. 0) before setting it to empty string needed to be changed to a check for whether the variable is defined.  I don't think this change should have any side-effects, as it is so low-level.  The modified function should rarely if ever be called if the value for the field concerned is undefined.  So it shouldn't suddenly cause XML export to include loads of empty elements.

Regards

David Newman

On 27/11/2026 17:11, Thomas Lauke wrote:
CAUTION: This e-mail originated outside the University of Southampton.

CAUTION: This e-mail originated outside the University of Southampton.

Hi folks,

an EP3 xml export of value 0 for a float field results in <OurFloat></OurFloat>, e.g. for 3.4.7.

A reimport of
<?xml version="1.0" encoding="utf-8"?>
<eprints xmlns="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Feprints.org%2Fep2%2Fdata%2F2.0&data=05%7C02%7Ceprints-tech%40ecs.soton.ac.uk%7Ccb4f4c1367614b70678608df4d7cf4b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C639314871217783129%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=nM%2BpfBc40eDnv5KBQxBNRvlnyBnIFpF5L6Eic9xVhBo%3D&reserved=0";>
   <eprint>
     <eprintid>506</eprintid>
     <eprint_status>archive</eprint_status>
     <userid>1</userid>
     <type>article</type>
     <metadata_visibility>show</metadata_visibility>
     <temperature>
       <Tmin></Tmin>
       <Tmax>50</Tmax>
     </temperature>
   </eprint>
</eprints>

by ~/Eprints/bin/import repoID eprint XML --update --enable-import-fields --force /tmp/506
fails with
Argument "" isn't numeric in numeric gt (>) at /usr/share/eprints/bin/../perl_lib/EPrints/MetaField/Int.pm line 243.
DBD::mysql::st execute failed: Incorrect double value: '' for column `repoID`.`eprint`.`temperature_Tmin` at row 1 at /usr/share/eprints/bin/../perl_lib/EPrints/Database.pm line 1196.
UPDATE `eprint` SET `temperature_Tmin`=?, `lastmod_year`=?, `lastmod_month`=?, `lastmod_day`=?, `lastmod_hour`=?, `lastmod_minute`=?, `lastmod_second`=? WHERE `eprintid`='506': 1366 at /usr/share/eprints/bin/../perl_lib/EPrints/Database.pm line 1086.
         EPrints::Database::update(EPrints::Database::mysql=HASH(0x5578327711c0), EPrints::DataSet=HASH(0x55783272a930), HASH(0x5578369c4130), HASH(0x5578367620b0)) called at /usr/share/eprints/bin/../perl_lib/EPrints/DataObj.pm line 1043
         EPrints::DataObj::commit(EPrints::DataObj::EPrint=HASH(0x5578368273c0), 0) called at /usr/share/eprints/bin/../perl_lib/EPrints/DataObj/EPrint.pm line 1113
         EPrints::DataObj::EPrint::commit(EPrints::DataObj::EPrint=HASH(0x5578368273c0)) called at /home/eprints/Eprints/bin/import line 346
         main::__ANON__(HASH(0x557836785298), "dataset", EPrints::DataSet=HASH(0x55783272a930)) called at /usr/share/eprints/bin/../perl_lib/EPrints/CLIProcessor.pm line 129
         EPrints::CLIProcessor::epdata_to_dataobj(EPrints::CLIProcessor=HASH(0x5578369f43c8), HASH(0x557836785298), "dataset", EPrints::DataSet=HASH(0x55783272a930)) called at /usr/share/eprints/bin/../perl_lib/EPrints/Plugin/Import.pm line 310
         EPrints::Plugin::Import::epdata_to_dataobj(EPrints::Plugin::Import::XML=HASH(0x557836a00690), HASH(0x557836785298)) called at /usr/share/eprints/bin/../perl_lib/EPrints/Plugin/Import/DefaultXML.pm line 225
         EPrints::Plugin::Import::DefaultXML::Handler::end_element(EPrints::Plugin::Import::DefaultXML::Handler=HASH(0x55783021cfe0), HASH(0x55783675cc80)) called at /usr/share/eprints/bin/../perl_lib/XML/SAX/Base.pm line 2201
         XML::SAX::Base::__ANON__(HASH(0x55783675cc80)) called at /usr/share/eprints/bin/../perl_lib/XML/SAX/Base.pm line 2176
         XML::SAX::Base::end_element(XML::LibXML::SAX=HASH(0x5578369cf700), HASH(0x55783675cc80)) called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML.pm line 883
         eval {...} called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML.pm line 883
         eval {...} called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML.pm line 883
         XML::LibXML::parse_fh(XML::LibXML=HASH(0x557836769120), GLOB(0x557836a048c8)) called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML/SAX.pm line 104
         eval {...} called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML/SAX.pm line 103
         XML::LibXML::SAX::_parse(XML::LibXML::SAX=HASH(0x5578369cf700)) called at /usr/local/lib/x86_64-linux-gnu/perl/5.40.1/XML/LibXML/SAX.pm line 60
         XML::LibXML::SAX::_parse_bytestream(XML::LibXML::SAX=HASH(0x5578369cf700), GLOB(0x557836a048c8)) called at /usr/share/eprints/bin/../perl_lib/XML/SAX/Base.pm line 2607
         XML::SAX::Base::parse(XML::LibXML::SAX=HASH(0x5578369cf700), HASH(0x557836826f40)) called at /usr/share/eprints/bin/../perl_lib/XML/SAX/Base.pm line 2631
         XML::SAX::Base::parse_file(XML::LibXML::SAX=HASH(0x5578369cf700), GLOB(0x557836a048c8)) called at /usr/share/eprints/bin/../perl_lib/EPrints/XML/LibXML.pm line 155
         EPrints::XML::event_parse(GLOB(0x557836a048c8), EPrints::Plugin::Import::DefaultXML::Handler=HASH(0x55783021cfe0)) called at /usr/share/eprints/bin/../perl_lib/EPrints/Plugin/Import/DefaultXML.pm line 81
         eval {...} called at /usr/share/eprints/bin/../perl_lib/EPrints/Plugin/Import/DefaultXML.pm line 81
         EPrints::Plugin::Import::DefaultXML::input_fh(EPrints::Plugin::Import::XML=HASH(0x557836a00690), "fh", GLOB(0x557836a048c8), "user", undef, "dataset", EPrints::DataSet=HASH(0x55783272a930), "filename", ...) called at /usr/share/eprints/bin/../perl_lib/EPrints/Plugin/Import.pm line 258
         EPrints::Plugin::Import::input_file(EPrints::Plugin::Import::XML=HASH(0x557836a00690), "dataset", EPrints::DataSet=HASH(0x55783272a930), "filename", "/tmp/506", "user", undef, "actions", ...) called at /home/eprints/Eprints/bin/import line 413
         eval {...} called at /home/eprints/Eprints/bin/import line 413

Use of uninitialized value $db_error in concatenation (.) or string at /usr/share/eprints/bin/../perl_lib/EPrints/DataObj.pm line 1049.
Error committing eprint.506:
Number of records imported: 1

Unfortunately the final message is wrong :(

Up to now we recreate the original value <OurFloat>0</OurFloat> for a successful import ... but is this really intended?

Thanks in advance for any comment
Thomas
Thomas

*** Options: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FEprints-tech_Mailing_List&data=05%7C02%7Ceprints-tech%40ecs.soton.ac.uk%7Ccb4f4c1367614b70678608df4d7cf4b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C639314871217803471%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=YA5Hlomdoh%2BpFvtd2z84OxjZJ8fsoHGbpE1zi2AaMT4%3D&reserved=0
*** Archive: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&data=05%7C02%7Ceprints-tech%40ecs.soton.ac.uk%7Ccb4f4c1367614b70678608df4d7cf4b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C639314871217823165%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=284296K5v3BjWpgSV9vz9cP4tvztb7BAIXOAhg5pQxc%3D&reserved=0
*** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2F&data=05%7C02%7Ceprints-tech%40ecs.soton.ac.uk%7Ccb4f4c1367614b70678608df4d7cf4b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C639314871217845418%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=9B5m7XGnPaqEIshXYIpqmhBqxxX3J66GbforAPw%2BeeA%3D&reserved=0