https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44086

            Bug ID: 44086
           Summary: Koha::Exporter::Record::export does not restore the
                    previously selected filehandle when output_filepath is
                    used
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
  Target Milestone: ---

When Koha::Exporter::Record::export() is called with output_filepath, it opens
the file and selects it (select $fh), so that the internal prints without an
explicit filehandle go to the file. At the end the file is closed, but the
previously selected filehandle (usually STDOUT) is never restored.

After the call, the selected filehandle is still the closed $fh, so any later
print without an explicit filehandle in the calling code fails with "print() on
closed filehandle $fh" and its output is lost. The exported file itself is
fine.

The same happens when export() dies because the csv profile is not valid: the
check runs after the file has been selected (and created).

Core callers are not affected by chance: tools/export.pl prints to STDOUT, and
misc/export_records.pl redirects STDOUT (open STDOUT, '>', $filename) instead
of passing output_filepath. Any script or plugin that passes output_filepath
and prints something afterwards (a progress or summary message, for instance)
is affected.

To reproduce, from the Koha root (e.g. in koha-shell):

perl -we 'use Koha::Exporter::Record; Koha::Exporter::Record::export({
record_type => "bibs", record_ids => [1], format => "xml", output_filepath =>
"/tmp/export.xml" }); print "Export finished\n";'

=> print() on closed filehandle $fh at -e line 1.
=> "Export finished" is never printed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to