RotherOSS / otobo

OTOBO is one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management. https://otobo.io/
GNU General Public License v3.0
257 stars 76 forks source link

Check the cases where autoclose of lexical variables is used #1051

Closed bschmalhofer closed 3 years ago

bschmalhofer commented 3 years ago

There are instances where the code relies on the autoclosing of lexical file handles are autoclosed. Autoclosing works just fine, however the scoping rules are a bit surprising. See https://stackoverflow.com/questions/67644504/why-does-repeatedly-opening-appending-and-closing-a-text-file-cause-the-lines-t and https://perlmonks.org/?node_id=11133380 .

Here is an example:

        if ( open my $ViewerDataFH, '>', $Filename ) {    ## no critic qw(OTOBO::ProhibitOpen InputOutput::RequireBriefOpen)
            print $ViewerDataFH $Data{Content};
        }
        else {

            # log error
            $LogObject->Log(
                Priority => 'error',
                Message  => "Cant write $Filename: $!",
            );

            return $LayoutObject->ErrorScreen();
        }

TODO:

bschmalhofer commented 3 years ago

Readd the close statement hat were remove in 08b155568c03649068a2d552b67bfe02402d45a7, even though it looks like no bugs were introduced in that commit. Checked the 91 file that have open statements and found no critical issues.

bschmalhofer commented 3 years ago

Test suite looks fine. Closing this issue.