Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guard on fclose in Zend_Mail_Storage_Mbox #70

Merged
merged 3 commits into from
Oct 1, 2021

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Mar 13, 2021

Extracted changes made by @Megatherium from #32

@@ -335,7 +335,9 @@ protected function _openMboxFile($filename)
*/
public function close()
{
@fclose($this->_fh);
if ($this->_fh && 'Unknown' !== get_resource_type($this->_fh)) {
@fclose($this->_fh);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Megatherium, @falkenhawk should the @-silencer still be applied here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably keep @ just to be extra safe...
Btw, should other @fclose in this class be similarly wrapped, or maybe $this->close() should be used in other places? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Megatherium: Why was this specific fclose() even addressed?

Perhaps the close() method lacks $this->_fh = null; to avoid errors on double close?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@falkenhawk The close() method also resets $this->_positions, not sure what's the side effect. but seems it's called on open sequence so probably safe to do so...

... and the other call uses private handle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling close instead of close resulted these failures:

will revert the commit and see :)

@glensc
Copy link
Contributor Author

glensc commented Mar 15, 2021

Looks like the problem this PR is attempting to fix is this output:

........................................................... 10620 / 15572 ( 68%)
PHP Fatal error:  Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in /home/runner/work/zf1/zf1/packages/zend-mail/library/Zend/Mail/Storage/Mbox.php:338
Stack trace:
#0 /home/runner/work/zf1/zf1/packages/zend-mail/library/Zend/Mail/Storage/Mbox.php(338): fclose()
#1 /home/runner/work/zf1/zf1/packages/zend-mail/library/Zend/Mail/Storage/Abstract.php(161): Zend_Mail_Storage_Mbox->close()
#2 [internal function]: Zend_Mail_Storage_Abstract->__destruct()
#3 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestCase.php(987): ReflectionMethod->invokeArgs()
#4 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestCase.php(838): PHPUnit_Framework_TestCase->runTest()
#5 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestResult.php(648): PHPUnit_Framework_TestCase->runBare()
#6 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestCase.php(783): PHPUnit_Framework_TestResult->run()
#7 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(779): PHPUnit_Framework_TestCase->run()
#8 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(749): PHPUnit_Framework_TestSuite->runTest()
#9 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(708): PHPUnit_Framework_TestSuite->run()
#10 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(708): PHPUnit_Framework_TestSuite->run()
#11 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(708): PHPUnit_Framework_TestSuite->run()
#12 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/Framework/TestSuite.php(708): PHPUnit_Framework_TestSuite->run()
#13 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/TextUI/TestRunner.php(349): PHPUnit_Framework_TestSuite->run()
#14 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/TextUI/Command.php(176): PHPUnit_TextUI_TestRunner->doRun()
#15 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run()
#16 /home/runner/work/zf1/zf1/vendor/zf1s/phpunit/composer/bin/phpunit(63): PHPUnit_TextUI_Command::main()
#17 {main}
  thrown in /home/runner/work/zf1/zf1/packages/zend-mail/library/Zend/Mail/Storage/Mbox.php on line 338
.............
Error: Process completed with exit code 1.

however, this doesn't reveal which test this comes from, so need to test this locally with xdebug breakpoint.

@glensc glensc force-pushed the fclose branch 3 times, most recently from 99ab1d6 to 968a880 Compare March 15, 2021 20:16
@glensc glensc mentioned this pull request Mar 16, 2021
32 tasks
@falkenhawk falkenhawk changed the base branch from master to fix-zend-log-php8 September 26, 2021 13:38
@falkenhawk falkenhawk marked this pull request as ready for review September 26, 2021 13:38
@falkenhawk falkenhawk changed the base branch from fix-zend-log-php8 to master October 1, 2021 08:26
@falkenhawk falkenhawk force-pushed the fclose branch 2 times, most recently from a41a413 to 3443f48 Compare October 1, 2021 09:58
@falkenhawk falkenhawk merged commit c68a782 into zf1s:master Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants