View Issue Details

IDProjectCategoryView StatusLast Update
0033173mantisbtapi restpublic2023-11-14 04:56
Reporterobmsch Assigned Todregad  
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.26.0 
Target Version2.26.1 
Summary0033173: No endpoints working on Windows server with PHP 8.1+
Description

I just opened 0033172, which I solved commenting out the startup code in my App.
The App starts now, but it is even worse. No single endpoint I use works any more.
I have no time to further debug this before next week, but this is definitely a
2.26.0 issue. A lot of 'HTTP/1.1 500 Internal Server Error' in the call chain.

TagsNo tags attached.

Relationships

related to 0033172 closedatrol Missing header values in response to '.../users/me' 
related to 0032866 closeddregad Allow REST API to run on PHP 8.1 without squelching E_DEPRECATED notices 

Activities

obmsch

obmsch

2023-11-10 16:51

reporter   ~0068306

All endpoints working for my App on 2.25.8.

atrol

atrol

2023-11-10 17:23

developer   ~0068308

See my note 0033172:0068307

obmsch

obmsch

2023-11-12 10:27

reporter   ~0068312

Last edited: 2023-11-13 06:03

Looks like the 'deprecated_errors_handler' is not working correctly. At least on Windows.

From the PHP error log:

[12-Nov-2023 15:43:39 Europe/Berlin] PHP Fatal error:  During inheritance of ArrayAccess: Uncaught Mantis\Exceptions\StateException: Unhandled deprecation warning in M:\www.root\MantisBT\vendor\slim\slim\Slim\Collection.php line 112: 'Return type of Slim\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice' in M:\www.root\MantisBT\api\rest\index.php:110
Stack trace:
#0 M:\www.root\MantisBT\vendor\slim\slim\Slim\Collection.php(20): deprecated_errors_handler()
0000001 M:\www.root\MantisBT\vendor\composer\ClassLoader.php(478): include('...')
0000002 M:\www.root\MantisBT\vendor\composer\ClassLoader.php(346): Composer\Autoload\includeFile()
0000003 M:\www.root\MantisBT\vendor\slim\slim\Slim\Container.php(83): Composer\Autoload\ClassLoader->loadClass()
0000004 M:\www.root\MantisBT\vendor\pimple\pimple\src\Pimple\Container.php(122): Slim\Container->Slim\{closure}()
0000005 M:\www.root\MantisBT\vendor\slim\slim\Slim\Container.php(109): Pimple\Container->offsetGet()
#6 M:\www.root\MantisBT\vendor\slim\slim\Slim\DefaultServicesProvider.php(84): Slim\Container->get()
0000007 M:\www.root\MantisBT\vendor\pimple\pimple\src\Pimple\Container.php(122): Slim\DefaultServicesProvider->Slim\{closure}()
#8 M:\www.root\MantisBT\vendor\slim\slim\Slim\Container.php(109): Pimple\Container->offsetGet()
0000009 M:\www.root\MantisBT\vendor\slim\slim\Slim\App.php(267): Slim\Container->get()
#10 M:\www.root\MantisBT\api\rest\restcore\config_rest.php(31): Slim\App->group()
#11 M:\www.root\MantisBT\api\rest\index.php(170): require_once('...')
0000012 {main} in M:\www.root\MantisBT\vendor\slim\slim\Slim\Collection.php on line 20

Problem with path separator? On windows its '\'.

$p_file = "M:\www.root\MantisBT\vendor\slim\slim\Slim\Collection.php"
The result of preg_match("~/vendor/(?:\w+/){2}(.*)$~", $p_file) is 0.

obmsch

obmsch

2023-11-12 14:05

reporter   ~0068313

I patched my MantisBT version and changed 'deprecated_errors_handler' from

        if( preg_match( '~/vendor/(?:\w+/){2}(.*)$~', $p_file, $t_matches ) ) {

to

        $t_file = str_replace( '\\', '/', $p_file );
        if( preg_match( '~/vendor/(?:\w+/){2}(.*)$~', $t_file, $t_matches ) ) {

And the REST API is working again.

Changing the regex itself makes no sense, as the case-tags also expect '/' as well. I think doing the replacement on Windows
only, is the best option here.

dregad

dregad

2023-11-13 06:02

developer   ~0068314

Thanks for the analysis @obmsch, I'll have a look.

dregad

dregad

2023-11-13 10:00

developer   ~0068315

Confirmed - I fired up a windows server and an API call that works just fine on LAMP, fails on WAMP with the error message reported in 0033173:0068312.

This is a regression introduced by 0032866 (MantisBT master 795ff02e)

dregad

dregad

2023-11-13 11:20

developer   ~0068319

PR https://github.com/mantisbt/mantisbt/pull/1941

obmsch

obmsch

2023-11-13 14:02

reporter   ~0068320

@dregad thanks, can confirm this works.

Related Changesets

MantisBT: master-2.26 032000c6

2023-11-13 11:15

dregad


Details Diff
Fix REST API endpoints failing on Windows

When running on PHP >= 8.1, REST API calls throw errors on Windows, due
to deprecated_errors_handler() function incorrectly expecting Unix-style
path on offending file name.

Converting `\` to `/` in $p_file variable before processing fixes the
problem.

Fixes 0033173
Affected Issues
0033173
mod - api/rest/index.php Diff File