View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0033906 | mantisbt | bugtracker | public | 2024-02-29 05:52 | 2024-06-25 11:05 |
Reporter | rossh_mb | Assigned To | dregad | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.26.1 | ||||
Target Version | 2.26.2 | Fixed in Version | 2.26.2 | ||
Summary | 0033906: Failed opening core.php in timeline_inc.php on PHP 8.2 / IIS | ||||
Description | With php 8.2, Mantis 2.26.1, Windows, the My View page has INTERNAL APPLICATION ERROR... and display the associated error text. php error log says [29-Feb-2024 18:40:00 Asia/Manila] Failed opening required 'core.php' (include_path='.;C:\php\pear') Line 166 of that file is include( $g_core_path . 'timeline_inc.php' ); | ||||
Steps To Reproduce | Visit the page | ||||
Additional Information | If I comment out line 166, no more error. $g_core_path can be set, or not set - no difference. $g_core_path contains a valid path either way. core and all other dirs are in default locations. | ||||
Tags | No tags attached. | ||||
Was it working before you upgraded to 2.26.1 ? Is it OK with other PHP versions ?
Looks like the problem is not with my_view_page.php line 166, but inside of timeline_inc.php, which does I assume you've checked that core.php is present and accessible, but I would guess it is because if not you would likely have other errors, as this file is used everywhere. Additional, debugging information is needed to help understanding the problem. Please follow these steps:
WARNING - SECURITY RISK: the 'show_detailed_errors' config can cause MantisBT to display sensitive information about your system. We recommend to restrict its activation to a Test environment, only for as long as necessary. If possible, do not turn it ON globally, instead limit it for specific user(s) using the Manage Configuration page.
If the output does not help you resolving the issue and you need further assistance,
You could also try to add |
|
Before? No errors with 8.26.0 or 8.26.1 and php 7.4. Goes bad with either 8.26.0.or 8.26.1 and php 8.2. With config extras: SYSTEM WARNING
Stack trace Filename Line Class Type Function Args0 E:\websites\zzzzzz\www\repairs\core\timeline_inc.php 17 - - require_once <string>'E:\websites\zzzzzz\www\repairs\core\error_api.php' timeline_inc.php add line 16 echo getcwd(); die; == C:\Program Files\php\8.2 I went into timeline_inc.php and commented off line 17 //require_once( 'core.php' ); Now it all works. Maybe that's the solution? |
|
No. core.php is an essential part of MantisBT source code [1], being the main include file responsible for initializing everything that's needed for it to run.
I guess you meant 2.26.0 or 2.26.1, and the 8 is just a typo ;-) The very same core.php file is included by my_view_page.php [2] without errors
So the behavior changes between the main script (my_view_page.php) and the timeline include. This is really weird. I would expect that to print Do you get the same behavior when accessing http://path.to/mantis/view_user_page.php?id=1 (replace 1 with a valid user ID) ? NOTE: I tried, but am not able to reproduce this error here with PHP 8.2, so I would suspect that something specific to your server's setup is causing the script's current directory to change.
That's a workaround for this specific problem, and it is probably safe to comment this line out considering that core.php is included by the parent script in both occurrences where it's used. But it should not be necessary to do that. I'm concerned that you may be facing the problem elsewhere though, so it's probably worth investigating the root cause. |
|
Looking deeper, I think the include path and file locations are at issue. calling echo get_include_path(); die; prior to my_view_page.php 166: include( $g_core_path . 'timeline_inc.php' ) , and also prior to core\timeline_inc.php 17: require_once( 'core.php' ); If I adjust timeline_inc.php 17: require_once( 'core.php' ); to read So it looks to me like php 8.x got a lot tougher on the include path and the redirection shortcuts. I have tried every other page and tab, and no other errors present. On my system, php.exe and IIS and the system account it runs under, is executing on C:, while all the websites are on E:. Maybe its the assumed include path, and that's the reason why this is somewhat limited to my setup?? |
|
Thanks for investigating.
That is expected. The problem's root cause is IMO not with the include path's definition, but due to the fact that we rely on the
Right, I forgot that timeline_inc.php is in ./core and not in the MantisBT root directory. Sorry about that.
That is not surprising actually, based on what you stated in 0033906:0068613. Since the current working directory is
What I don't understand, is why it works for you with PHP 7.4 but not 8.2... Is the server configuration identical (except for PHP version) ? Could you please check the value of getcwd() for both 7.4 and 8.2, in
|
|
[01-Mar-2024 20:06:41 Asia/Manila] PHP v8.2.16, cwd = C:\Program Files\php\8.2 from line 166 in /repairs/my_view_page.php [01-Mar-2024 20:10:32 Asia/Manila] PHP v7.4.33, cwd = C:\Program Files\php\7.4 from line 166 in /repairs/my_view_page.php [01-Mar-2024 20:12:43 Asia/Manila] PHP v7.4.33 includepath = .;C:\php\pear |
|
Thanks for the feedback. So at least the behavior is consistent and as expected. Unfortunately, that does not give me any clue as to why it works with PHP 7.4 and not with 8.2 :-/ Anyway I don't think it's worth spending any more time on this. I'll remove the unnecessary require_once in timeline_inc.php. |
|
I found one other page affected by this, with same "internal error" message: The logged error is: And the line of code at 512: print_admin_menu_bar( 'test_langs.php' ); |
|
The actual error occurs in html_api.php print_admin_menu_bar() function at line 953. The So it indeed appears to be the same root cause, the only difference being the included file is present in the same directory as the calling script. Again, I can fix the symptoms (i.e. make sure that count() is not called with null), and/or work around the problem either by setting an absolute path when including schema.php in print_admin_menu_bar() or including the file in test_langs.php like it's done for the other admin helper scripts, but that does not address the root cause. According to the PHP documentation for include
There is definitely something strange going on with your system (or maybe it's specific to IIS, but I don't have access to an instance of it to test), and you need to figure out what it is and fix it, i.e. why is your CWD not that of the script being called. |
|
@rossh_mb please test these possible solutions Workaround 1
Workaround 2 |
|
..or maybe it's specific to IIS?? I ran this script. results below. <?php A test of paths and includes....in PHP version = 8.2.16. This is run from the mantis web root dir. The php help says the this about include; Who sets the include path ?? its probably compiled into the windows php binary, or is some default value. From that... the . (dot) gets us the adjacent php files, and subdir/files. But going back up the path, the .(dot) can't help us. So going up needs the full path and in my case, the drive too as the implied root dir == C: and not E: I think the issue I'm reporting here, is from a vagueness in paths. The include ('subdir/file.php), injects the subdir/file into the current file making the include call, and any further file locations referenced within subdir/file.php, need to be in the context of calling file (one dir higher). A solution for Mantis might be to set the cwd to DIR at the common header, and now your on firm ground for location. ***** note the editor has stripped off the double underscore before / after DIR and FILE |
|
As I said before, yes maybe. I've never used IIS for PHP myself, but many other Mantis users have, and never reported such problems. Is your 7.4 system also using the same FastCGI configuration ? It would be interesting to know, what happens to the various paths if you use this code snippet as an include file, depending on how many levels deep it is included, i.e. assuming your script from 0033906:0068622 is named test1.php
test2.php |
|
I suggest that you go rent an online server for a month at Kamtera or a hundred other places, and try it out,. Or download the trial server program into a vm. This will help answer all your questions and more. PM me if you want to discuss the setup. Thanks for the adjustments. |
|
Well I do this in my spare time, and I'm certainly not going to spend money on that, sorry. |
|
Just committed a fix to address the problem with test_lang.php. |
|
See also PR https://github.com/mantisbt/mantisbt/pull/2011 for follow-up commit - setting current working dir in core.php to reduce risk of this issue occurring again in the future. |
|
MantisBT: master-2.26 bff76ed9 2024-03-02 06:56 Details Diff |
Remove inclusion of core.php in timeline_inc.php By definition an include file is part of a main script, which will always include core.php, so it's not necessary to reference it again in the include. This actually caused an error on a user's system (PHP 8.2 on IIS). The problem could not be reproduced, but an easy fix is to remove the useless require_once. Fixes 0033906 |
Affected Issues 0033906 |
|
mod - core/timeline_inc.php | Diff File | ||
MantisBT: master-2.26 70905946 2024-03-10 11:58 Details Diff |
Use absolute path to schema.php in html API print_admin_menu_bar() needs to include schema.php, to determine whether we have an upgrade pending or not. This include_once call did not specify the path to the file, resulting in a failure to include it on IIS with FastCGI, as the current working directory was not set to that of the currently executing script, but to where the PHP executable was stored. This caused $g_upgrade to be null, leading to an error when calling count() on PHP 8. We now use require_once instead so we get a hard failure if schema.php could not be included, and we specify the full path to the file to avoid the problem on IIS/FastCGI. Fixes 0033906 |
Affected Issues 0033906 |
|
mod - core/html_api.php | Diff File | ||
MantisBT: master-2.26 131a3d8f 2024-03-10 11:59 Details Diff |
Remove unnecessary require_once schema.php is included by print_admin_menu_bar() Issue 0033906 |
Affected Issues 0033906 |
|
mod - admin/email_queue.php | Diff File | ||
mod - admin/index.php | Diff File | ||
mod - admin/system_utils.php | Diff File | ||
MantisBT: master c8ba25be 2024-03-10 12:03 Details Diff |
Set current working directory in core.php This is a follow-up on fixes for issue 0033906. Making sure we have a consistent working directory will help avoid such issues in the future. |
Affected Issues 0033906 |
|
mod - core.php | Diff File | ||
MantisBT: master d41893e3 2024-06-15 10:22 Details Diff |
Use absolute path to WSDL file when initializing SOAP API Issue 0033906 |
Affected Issues 0033906 |
|
mod - api/soap/mantisconnect.php | Diff File | ||
MantisBT: master 90c33bf1 2024-06-19 12:18 Details Diff |
Revert "Set current working directory in core.php" Reverts commit c8ba25be74b83d267619fd4b0fd1742e8e0f2974 (Issue 0033906). As requested by @atrol in PR review [1]. [1]: https://github.com/mantisbt/mantisbt/pull/2011#discussion_r1645103612 |
Affected Issues 0033906 |
|
mod - core.php | Diff File |