Bug #76801 [Com]: require()ing a file blocks writing or deleting the file

From: Date: Wed, 20 Mar 2019 00:48:54 +0000
Subject: Bug #76801 [Com]: require()ing a file blocks writing or deleting the file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220083@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76801&edit=1

 ID:                 76801
 Comment by:         andrew at nicols dot co dot uk
 Reported by:        peehaa@php.net
 Summary:            require()ing a file blocks writing or deleting the
                     file
 Status:             Open
 Type:               Bug
 Package:            phpdbg
 Operating System:   Windows
 PHP Version:        7.2.9
 Block user comment: N
 Private report:     N

 New Comment:

Also, it's worth pointing out that the behaviour was also broken before this patch (The script
being run is not in the list of includedfiles like it is in PHP). Either way
Zend/tests/014.phpt will fail both before and after this patch when called with phpdbg.


Previous Comments:
------------------------------------------------------------------------
[2019-03-20 00:45:01] andrew at nicols dot co dot uk

I've been debugging with this further and rediscovered what I was seeing  with this patch

Using phpdbg, files which were included using include or require are not
added to the list of included files, and are then included again when include_once is
called.

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:
---------------
2015 nicols@boysenberry:/tmp/argh> php test2.php
Array
(
    [0] => /private/tmp/argh/test2.php
    [1] => /private/tmp/argh/example.php
)


Actual result with PHPDBG before this patch:
---------------
2011 nicols@boysenberry:/tmp/argh> 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
)

Actual result with PHPDBG after this patch:
---------------
2016 nicols@boysenberry:/tmp/argh> 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
(
)


Overall effect of the proposed change:
---------------
File handles are now closed correctly
Files which have been included with include or require are not added to
the list of included files, and are re-included the first time that include_once or
require_once is called.

------------------------------------------------------------------------
[2019-03-19 01:36:15] andrew at nicols dot co dot uk

Sadly I'm still seeing this issue on MacOS, and Linux, and it still renders phpdbg entirely
useless for code coverage.

I've just tried applying this patch to the latest 7.2 release and it seems to be working as it
should. The multiple includes are no longer an issue, but I am hitting segfaults on master so
I'm unable to test things further.

cmb@php.net, are you able to progress this by any chance?

------------------------------------------------------------------------
[2019-01-08 00:16:18] andrew at nicols dot co dot uk

Related To: Bug #76882

------------------------------------------------------------------------
[2018-09-17 04:11:11] andrew at nicols dot co dot uk

Sorry, to confirm the previous comment relates to the patch suggested by cmb@php.net

Calling a.php via php directly:
2054 nicols@boysenberry:~/git/tmp> php a.php
/Users/nicols/git/tmp/b.php was included

Calling it via phpdbg -qqr:
2055 nicols@boysenberry:~/git/tmp> phpdbg -qqr a.php
/Users/nicols/git/tmp/b.php was included
/Users/nicols/git/tmp/b.php was included
[Script ended normally]
prompt>

Essentially it appears that when called via PHP CLI, a file included via require or include is not
subsequently loaded if called via require_once or include_once.
However if it is called via phpdbg, it is included again.

------------------------------------------------------------------------
[2018-09-17 04:05:37] andrew at nicols dot co dot uk

The attached patch fails with the following test:

a.php:
```
<?php

require('b.php');
require_once('b.php');
```

b.php:
```
<?php
echo __FILE__ . " was included\n";
```

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=76801


--
Edit this bug report at https://bugs.php.net/bug.php?id=76801&edit=1


Thread (1 message)

  • andrew at nicols dot co dot uk
  • Unknown Message
    • andrew at nicols dot co dot uk
« previous php.bugs (#220083) next »