View Issue Details

IDProjectCategoryView StatusLast Update
0016187mantisbtadministrationpublic2021-06-20 09:16
Reporterpeterbruin Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.16 
Target Version1.2.16Fixed in Version1.2.16 
Summary0016187: Application error on fresh install
Description

When working with a fresh install without any projects defined application errors keep on being generated. This is caused by the fact that empty arrays are being combined and as a result a object that is not an array is being returned.

All though this is a minor issue and goes away by creating one project it is not good for confidence when starting a fresh install.

Steps To Reproduce
  1. Create fresh install
  2. Log in using administrator account
Additional Information

Patch to fix it:

--- a/core/user_api.php
+++ b/core/user_api.php
@@ -1012,6 +1012,10 @@ function user_get_all_accessible_projects( $p_user_id, $p_project_id ) {
        if( ALL_PROJECTS == $p_project_id ) {
                $t_topprojects = user_get_accessible_projects( $p_user_id );

+               if ( is_array($t_topprojects) && count($t_topprojects) == 0 ) {
+                       return Array();
+               }
+
                # Create a combined array where key = value
                $t_project_ids = array_combine( $t_topprojects, $t_topprojects );
TagsNo tags attached.
Attached Files
mantis-error.png (16,993 bytes)   
mantis-error.png (16,993 bytes)   

Relationships

related to 0009876 closeddregad Performance problem with a lot of projects 
related to 0028830 closeddregad Remove PHP < 5.4 compatibility code from user_get_all_accessible_projects() 

Activities

atrol

atrol

2013-07-18 03:06

developer   ~0037488

I was not able to reproduce this issue.
This might be caused by a changed behavior since PHP 5.4 [1]

Can you confirm that you use a PHP version < 5.4 ?

[1] http://php.net/manual/en/function.array-combine.php

peterbruin

peterbruin

2013-07-18 03:35

reporter   ~0037489

I am using Ubuntu 12.04.2 LTS, this is the php --version output

PHP 5.3.10-1ubuntu3.7 with Suhosin-Patch (cli) (built: Jul 15 2013 18:05:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

peterbruin

peterbruin

2013-07-18 22:22

reporter   ~0037497

As the recommended version for PHP is 5.1 or 5.2 this issue should still be fixed as not many people will be running with PHP 5.4

See: http://www.mantisbt.org/docs/master-1.2.x/en/administration_guide.html#ADMIN.INSTALL.REQUIREMENTS

atrol

atrol

2013-07-19 02:47

developer   ~0037499

this issue should still be fixed as not many people will be running with PHP 5.4

That's why I didn't set status to "resolved" and resolution to "won't fix"

dregad

dregad

2013-07-22 07:45

developer   ~0037506

I'm changing Product Version, because the array_combine() call was introduced in (not-yet-released) changeset cc7703ac, fixing 0009876.

@peterbruin
Comment on your proposed patch - user_get_accessible_projects() always returns an array, so your test is more complex than necessary.

Please test proposed fix at https://github.com/dregad/mantisbt/tree/fix-16187

peterbruin

peterbruin

2013-07-22 21:20

reporter   ~0037509

I have tested your fix and can confirm that it works. Thanks.

Related Changesets

MantisBT: master-1.2.x f9a07a0d

2013-07-22 21:56

dregad


Details Diff
Fix 0016187: error caused by array_combine() with PHP<5.4

array_combine() function behavior was changed in PHP 5.4 [1]; in earlier
versions it would issue a warning and return false when working with
empty arrays, which then causes Mantis to trigger an application error.

This is a regression introduced by cc7703acc8d05f253d52a152a7d8cd0c1c43815d

[1] http://php.net/function.array-combine.php
Affected Issues
0016187
mod - core/user_api.php Diff File

MantisBT: master 79baa9aa

2013-07-22 21:56

dregad


Details Diff
Fix 0016187: error caused by array_combine() with PHP<5.4

array_combine() function behavior was changed in PHP 5.4 [1]; in earlier
versions it would issue a warning and return false when working with
empty arrays, which then causes Mantis to trigger an application error.

This is a regression introduced by cc7703acc8d05f253d52a152a7d8cd0c1c43815d

[1] http://php.net/function.array-combine.php
Affected Issues
0016187
mod - core/user_api.php Diff File

MantisBT: master dfdcd29d

2021-06-20 05:02

dregad


Details Diff
Remove code needed only for PHP < 5.4

This test was added in issue 0016187 and is no longer necessary since
we require PHP 7.0 or later.

Fixes 0028830
Affected Issues
0016187, 0028830
mod - core/user_api.php Diff File