View Issue Details

IDProjectCategoryView StatusLast Update
0020864mantisbtadministrationpublic2016-08-15 09:02
ReporterdvzrvAssigned Todregad 
Status closedResolutionfixed 
Platformnginx+uwsgi+mariadb+php7OSArch LinuxOS Version
Product Version1.2.19 
Target Version1.2.20Fixed in Version1.2.20 
Summary0020864: "user_pref_get_language()" not defined

As mentioned downstream ( I ran into the issue of being unable to login with the administrator account after an initial setup of mantisbt, using nginx+uwsgi+mariadb+php7 on Arch Linux, hitting the bug mentioned under "Additional Information"

Steps To Reproduce

Install mantisbt using nginx+uwsgi+mariadb+php7 and the tarball from version 1.2.19. After completing the database install setup (/admin/install.php), try to login using the standard first admin user "administrator" with the password "root".

Additional Information

PHP Fatal error: Uncaught Error: Call to undefined function user_pref_get_language() in /usr/share/webapps/mantisbt/core/lang_api.php:104
Stack trace:
#0 /usr/share/webapps/mantisbt/core/error_api.php(82): lang_get_default()
0000001 /usr/share/webapps/mantisbt/core/string_api.php(33): error_handler(8192, 'Methods with th...', '/usr/share/weba...', 31, Array)
0000002 /usr/share/webapps/mantisbt/core/string_api.php(33): require_once()
0000003 /usr/share/webapps/mantisbt/core/email_api.php(40): require_once('/usr/share/weba...')
0000004 /usr/share/webapps/mantisbt/core/bug_api.php(33): require_once('/usr/share/weba...')
0000005 /usr/share/webapps/mantisbt/core/project_api.php(36): require_once('/usr/share/weba...')
#6 /usr/share/webapps/mantisbt/core.php(239): require_once('/usr/share/weba...')
0000007 /usr/share/webapps/mantisbt/index.php(26): require_once('/usr/share/weba...')
#8 {main}
thrown in /usr/share/webapps/mantisbt/core/lang_api.php on line 104



related to 0020500 closedatrol Installation fails in PHP 7 environment 
related to 0020501 closeddregad Installer throws warning in PHP 7 environment 
related to 0020865 closeddregad 'Content Encoding Error' when errors occur before compress handler is started 




2016-04-30 08:18


lang_api.patch (408 bytes)
--- mantisbt-1.2.19/core/lang_api.php	2015-01-26 00:00:30.000000000 +0100
+++ mantisbt-1.2.19/core/lang_api.php.patch	2016-04-30 13:41:10.536906702 +0200
@@ -23,6 +23,11 @@
  * @link
+ * requires user_pref_api
+ */
+require_once( 'user_pref_api.php' );
 # Cache of localization strings in the language specified by the last
 # lang_load call
 $g_lang_strings = array();
lang_api.patch (408 bytes)


2016-04-30 08:21

reporter   ~0053040

I propose applying the attached patch. As I don't know the codebase, this could be horribly wrong, though. ;-)



2016-04-30 10:40

developer   ~0053041


Although your proposed patch could fix the problem (I didn't test it), looking at your call stack, I don't think it addresses the root cause:

1 /usr/share/webapps/mantisbt/core/string_api.php(33): error_handler(8192, 'Methods with th...', '/usr/share/weba...', 31, Array)

That's an E_DEPRECATED warning, which is triggered exactly as user_pref_api.php is being included by string_api.php (line 33).

You only provide a partial error message 'Methods with th...', but since you mentioned PHP7, I assume it is 'Methods with the same name as their class will not be constructors in a future version of PHP' , triggered by the UserPreferences class constructor (line 96 in user_pref_api.php).

Can you please try renaming the method to __construct() and let me know if that fixes the issue ?



2016-04-30 11:23

developer   ~0053042

For the record: I can confirm that the issue can be reproduced anytime an error is triggered prior to user_pref_api.php being successfully included in string_api.php.

The proposed patch is therefore the correct way of fixing the reported issue.

The problem with PHP4 constructors (as the cause for the error occuring in the first place) still needs to be addressed for PHP7 support.



2016-05-01 04:43

developer   ~0053046

The problem with PHP4 constructors (as the cause for the error occuring in the
first place) still needs to be addressed for PHP7 support.

This was actually fixed in 0020501



2016-05-01 08:24

reporter   ~0053047

@dregad: Renaming the UserPreferences function to __construct() (line 96 in core/user_pref_api.php) also fixes the problem!

As for the patches ( When will these fixes find their way to a release tarball?
MantisBT is not functional without patches downstream (at least when looking at Arch).

Related Changesets

MantisBT: master-1.2.x 672a256e

2016-04-30 11:25:15


Details Diff
Require user pref API in lang API

If the user pref API has not yet been loaded and an error is triggered,
then the error API is not able to retrieve the error message because
language API cannot get the user's preferred language.

Fixes 0020864
mod - core/lang_api.php Diff File

Issue History

Date Modified Username Field Change
2016-04-30 08:18 dvzrv New Issue
2016-04-30 08:18 dvzrv File Added: lang_api.patch
2016-04-30 08:21 dvzrv Note Added: 0053040
2016-04-30 10:39 dregad Tag Attached: php7
2016-04-30 10:40 dregad Assigned To => dregad
2016-04-30 10:40 dregad Status new => feedback
2016-04-30 10:40 dregad Note Added: 0053041
2016-04-30 11:23 dregad Note Added: 0053042
2016-04-30 12:41 dregad Changeset attached => MantisBT master-1.2.x 672a256e
2016-04-30 12:41 dregad Status feedback => resolved
2016-04-30 12:41 dregad Resolution open => fixed
2016-04-30 12:41 dregad Fixed in Version => 1.2.20
2016-04-30 12:41 dregad Relationship added related to 0020865
2016-04-30 13:18 atrol Relationship added related to 0020500
2016-04-30 13:18 atrol Relationship added related to 0020501
2016-04-30 13:19 atrol Target Version => 1.2.20
2016-05-01 04:43 dregad Note Added: 0053046
2016-05-01 08:24 dvzrv Note Added: 0053047
2016-08-15 09:02 dregad Status resolved => closed