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

Close file handles and add files to included files after opening #3968

Closed
wants to merge 2 commits into from

Conversation

andrewnicols
Copy link

@andrewnicols andrewnicols commented Mar 20, 2019

Fixes bug #76801

Note: This patch largely came from @cmb69 but I discovered that the inclusion of that patch prevented the list of included files from being filled so I've fixed that too.

I also discovered whilst fixing the list of included files that the behaviour of phpdbg is different to that of php in that the original script being run was not included via phpdbg but is via php:

Initial demonstration of files not closed

Script to demonstrate the issue of files not being closed:

<?php

for ($i = 0; $i < 10; $i++) {
    echo "Requiring setup for run {$i}\n";
    require_once('example.php');
}


$mypid = getmypid();
echo "\n";
echo "Take a look and see what's included:\n\n";
echo "lsof -p {$mypid}\n\n";
passthru("lsof -p {$mypid}");

Demonstration of included files being incomplete

Test script:

<?php

require('example.php');
print_r(get_included_files());

Expected result:

Array
(
    [0] => /private/tmp/argh/test2.php
    [1] => /private/tmp/argh/example.php
)

Actual result with PHP:

php test2.php
Array
(
    [0] => /private/tmp/argh/test2.php
    [1] => /private/tmp/argh/example.php
)

Actual result with PHPDBG before this patch:

phpdbg -rr test2.php
[Welcome to phpdbg, the interactive PHP debugger, v0.5.0]
To get help using phpdbg type "help" and press enter
[Please report bugs to <http://bugs.php.net/report.php>]
Array
(
    [0] => /private/tmp/argh/example.php
)

cmb69 and others added 2 commits March 20, 2019 15:04
This change also adds the original file included to mimic the behaviour
seen in PHP.
@cmb69
Copy link
Contributor

cmb69 commented Mar 20, 2019

See also PR #3965 which is supposed to be a fix for bug #76801, too.

@andrewnicols
Copy link
Author

Thanks @cmb69 , wish I'd known that earlier /o.

I'll close this request. I've just tested 3965 locally and it solves all of the issues for me, and in a more forward-moving way.

Thanks.

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.

None yet

2 participants