View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0020864||mantisbt||administration||public||2016-04-30 08:18||2016-08-15 09:02|
|Platform||nginx+uwsgi+mariadb+php7||OS||Arch Linux||OS Version|
|Target Version||1.2.20||Fixed in Version||1.2.20|
|Summary||0020864: "user_pref_get_language()" not defined|
As mentioned downstream (https://bugs.archlinux.org/task/49141) 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".
PHP Fatal error: Uncaught Error: Call to undefined function user_pref_get_language() in /usr/share/webapps/mantisbt/core/lang_api.php:104
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 http://www.mantisbt.org */ +/** + * 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)
I propose applying the attached patch. As I don't know the codebase, this could be horribly wrong, though. ;-)
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 ?
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.
This was actually fixed in 0020501
@dregad: Renaming the UserPreferences function to __construct() (line 96 in core/user_pref_api.php) also fixes the problem!
As for the patches (https://mantisbt.org/bugs/view.php?id=20501): When will these fixes find their way to a release tarball?
MantisBT: master-1.2.x 672a256e
2016-04-30 11:25:15Details 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.
|mod - core/lang_api.php||Diff File|
|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|