Stuck upgrading mantis ADMIN checks plugin

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

Hello,

I'm upgrading mantis to version 2.25.7.

When checking the admin page, I get a plugin error without any more info, just :
installed Plugin 'XXX'' is operational + FAIL.

It's not a matter of the plugin tested because if I remove this plugin (which isn't very used) -> https://github.com/mantisbt-plugins/csv ... /README.md, I have the same error on MantisCore.

I added debugs in the check_api.php, please check screenshot :
Capture.PNG
Capture.PNG (42.23 KiB) Viewed 26919 times
As we can see error is :
APPLICATION WARNING #2400: L’événement « EVENT_UPDATE_BUG_DATA  » n’est pas encore défini. (translation : EVENT is not defined)
Raised in file /opt/mantisbt-2.25.7/core/event_api.php on line 96

I have no clue how to fix, can anyone help ?

Thanks

Kind regards

Jules

PS : forgive logs in french
atrol
Site Admin
Posts: 8534
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Stuck upgrading mantis ADMIN checks plugin

Post by atrol »

Which version was installed before 2.25.7?
Which PHP version are you using?
How did you run the upgrade? (provide step by step instructions)
Please use Search before posting and read the Manual
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

Hello atrol,

I'm upgrading from mantis 2.18.0.
I'm using PHP 8.1.2.
I followed this upgrading https://www.mantisbt.org/docs/master/en ... grade.html

Steps were :
1 - Downloading new mantis version
2 - Unzip
3 - Deleting the config folder
4 - Recreating the symbolic link to the config folder (we use a custom config folder) so it's easier to maintain when upgrading (it's where we place the custom constants / strings / configs etc)
5 - Recreating the symbolic link to a custom plugin folder from /plugins folder (we have custom plugin to handle tables)
6 - Redownloaded the plugin CSV mentioned + installed as following instructions (https://github.com/mantisbt-plugins/csv ... /README.md)
7 - Lauching the install.php + using it
8 - Fixing error LDAP (had to add "$g_ldap_use_starttls = OFF;")
9 - Deleted the doc folder
10 - Fixing a few kernel sources (cfdef_standard.php, BugFilterQuery.class.php, custom_field_api.php, mc_project_api.php, gpc_api.php, filter_form_api.php) because we have a custom plugin to handle tables
11 - Fixing a few kernel sources just to restrict the summary max characters : (bug_change_status_page.php, bug_report_page.php, bug_update_page.php)
12 - Testing out a bit mantis & our plugin to see if something is broken but everything look fine
13 - Trying to fix paths errors from the admin page admin/check/index.php :
core_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the core_path directory outside the web root. WARN
class_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the class_path directory outside the web root. WARN
library_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the library_path directory outside the web root. WARN
language_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the language_path directory outside the web root. WARN
but couldn't make it work so I just let it like that, reverted what I tried
14 - Again, fixed a few errors that I don't remember from the admin page admin/check/index.php
15 - Trying to debug + facing that error on the plugin ...

PS : I went ahead and tested again mantis but I get that error now ... might be linked
Capture.PNG
Capture.PNG (18.59 KiB) Viewed 26860 times
Kind regards

Jules
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

Update : error without a doubt is due to our custom plugin, if I uninstall it, I no more get errors on plugins (in the admin/check page)

Here is the content of our plugin :
Capture.PNG
Capture.PNG (2.15 KiB) Viewed 26847 times
(file blurred code is : )

Code: Select all

<?php

require( 'pages/utils.php' );

class pggPlugin extends MantisPlugin{
    function register(){
        $this->name = lang_get('plugin_pgg_Table_title');
        $this->description = lang_get('plugin_pgg_Table_description');
        $this->page = 'config';
        
        $this->version = '1.0';
        $this->requires = array(
            'MantisCore' => '2.18.0',
        );
        
        $this->author = 'xxxx xxxx';
        $this->contact = 'xxxx.xxxx@xxxx.fr';
        $this->url = 'https://www.xxxxxx.fr/';
    }
    
    function config(){
        return array(
            'conf_auto_load' => true,
            'auto_load_threshold' => MANAGER,
            'debug_interface_active' => true,
        );
    }
    
    function hooks(){
        return array(
            'EVENT_LAYOUT_RESOURCES' => 'resources',
            'EVENT_REPORT_BUG_FORM' => 'pgg_display_field_on_create',
            'EVENT_UPDATE_BUG_STATUS_FORM' => 'pgg_display_field_on_status_change',
            'EVENT_UPDATE_BUG_FORM' => 'pgg_display_field_on_update',
            //'EVENT_UPDATE_BUG_DATA' => 'pgg_save_custom_field',
            'EVENT_VIEW_BUG_DETAILS' => 'pgg_display_field_on_view',
            'EVENT_UPDATE_BUG_DATA ' => 'pgg_check_table'
        );
    }
    
    function resources($p_event) {
        return 
            '<link rel="stylesheet" type="text/css" href="https://unpkg.com/bootstrap-table@1.22.0/dist/bootstrap-table.min.css"></link>'
            . '<script src="https://unpkg.com/bootstrap-table@1.22.0/dist/bootstrap-table.min.js"></script>'
            . '<script src="https://unpkg.com/bootstrap-table@1.22.0/dist/bootstrap-table-locale-all.min.js"></script>'
            . '<link rel="stylesheet" type="text/css" href="' . plugin_file( 'jquery-ui.css' ) . '"></link>'
            . '<script type="text/javascript" src="' . plugin_file( 'jquery-ui.js' ) . '"></script>';
            
    }
    
    function pgg_display_field_on_create( $p_event, $p_project_id ){   
        pgg_display_field_with_wkf( null, $p_project_id, config_get( 'bug_submit_status' ), true );
    }

    function pgg_display_field_on_status_change( $p_event, $p_bug_data ){
        $t_project_id = bug_get( $p_bug_data, false )->project_id;
        pgg_display_field_with_wkf( $p_bug_data, $t_project_id, gpc_get_int( 'new_status' ), true );
    }
    
    function pgg_display_field_on_update( $p_event, $p_bug_data ){
        $t_project_id = bug_get( $p_bug_data, false )->project_id;
        pgg_display_all_fields_update($p_bug_data, $t_project_id);
    } 
    
    function pgg_display_field_on_view( $p_event, $p_bug_data ){
        $t_project_id = bug_get( $p_bug_data, false )->project_id;
        pgg_display_all_fields_view($p_bug_data, $t_project_id);
    } 

    function pgg_check_table( $p_event, $p_bug_data_after, $p_bug_data_before ){
        return $p_bug_data_after;
    }
}

?>
Update 2 : if I delete this row :
'EVENT_UPDATE_BUG_DATA ' => 'pgg_check_table'
, I no more have errors in the admin/check page but I still have the error
APPLICATION ERROR #1304 : Definition of custom field not valid
Update 3 : for some reasons that are unclear, steps 10 and 11 were reverted ... (back to original sources), I fixed it, and now, I no more have the error
APPLICATION ERROR #1304 : Definition of custom field not valid
, I can modify / create bugs fine. But still have the
'EVENT_UPDATE_BUG_DATA ' => 'pgg_check_table'
error.

Update 4 (final update ) : sorry for debugging my "own plugin", I didn't code it , it's quite hard to read but it doesn't seem like the function pgg_check_table is doing anything anyways (someone can confirm, yes?) so I went ahead and remove both the EVENT_UPDATE_BUG_DATA hook + the function. Everything works well.

@atrol, is that normal that the hook didn't work ? Just for knowledge
atrol
Site Admin
Posts: 8534
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Stuck upgrading mantis ADMIN checks plugin

Post by atrol »

Wrong

Code: Select all

'EVENT_UPDATE_BUG_DATA ' => 'pgg_check_table'
Should be

Code: Select all

'EVENT_UPDATE_BUG_DATA' => 'pgg_check_table'
Of course, you can keep the line dropped, as function pgg_check_table does not check or change any data.
Please use Search before posting and read the Manual
atrol
Site Admin
Posts: 8534
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Stuck upgrading mantis ADMIN checks plugin

Post by atrol »

5 - Recreating the symbolic link to a custom plugin folder from /plugins folder (we have custom plugin to handle tables)
Doesn't this mean, that you lose the latest versions of the plugins that come out of the box with MantisBT?
Please use Search before posting and read the Manual
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

atrol wrote: 21 Aug 2023, 11:02 Wrong

Code: Select all

'EVENT_UPDATE_BUG_DATA ' => 'pgg_check_table'
Should be

Code: Select all

'EVENT_UPDATE_BUG_DATA' => 'pgg_check_table'
Of course, you can keep the line dropped, as function pgg_check_table does not check or change any data.
Good catch I'm so blind ...

Sorry !

It works fine when fixing that extra space. I'll just remove it since it's dead code, doesn't do anything, to avoid further confusion.

Thanks !

It also means that everytime we modify a plugin / install a plugin, it's a good idea to re-download the admin folder ?
Last edited by JulesA on 21 Aug 2023, 12:44, edited 2 times in total.
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

atrol wrote: 21 Aug 2023, 11:04
5 - Recreating the symbolic link to a custom plugin folder from /plugins folder (we have custom plugin to handle tables)
Doesn't this mean, that you lose the latest versions of the plugins that come out of the box with MantisBT?
No no, only the link to our plugin is created (blurred in the capture.png), please see screenshot for the plugins folder :
Capture.PNG
Capture.PNG (4.49 KiB) Viewed 26822 times
atrol
Site Admin
Posts: 8534
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Stuck upgrading mantis ADMIN checks plugin

Post by atrol »

It also means that everytime we modify a plugin / install a plugin, it's a good idea to re-download the admin folder ?
Of course, it is.
I would move the folder to a place in the file system that can't be reached by the web server and move it back when needed.
Even better to have a complete separate test installation, not reachable by users, where you can try any changes before you roll it out to your production system.
Please use Search before posting and read the Manual
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

Yes, we do have two separate environments, but I'm not sure admin folder was used to test the plugin, I doubt.

Thanks for the answer.

Final question, about the paths warnings :
Paths
core_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the core_path directory outside the web root. WARN
class_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the class_path directory outside the web root. WARN
library_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the library_path directory outside the web root. WARN
language_path configuration option is set to a path outside the web root
For increased security it is recommended that you move the language_path directory outside the web root. WARN
I tried following this subject : https://mantisbt.org/forums/viewtopic.php?t=23994 but couldn't make it work, mantis homepage was all white.

I just have to add this in the config file + move folders right ?

Code: Select all

$g_core_path     = '/<somewhereOutsideWebRoot>/share/MantisBT/core/';
$g_class_path    = '/<somewhereOutsideWebRoot>/share/MantisBT/core/classes/';
$g_library_path  = '/<somewhereOutsideWebRoot>/share/MantisBT/library/';
$g_language_path = '/<somewhereOutsideWebRoot>/share/MantisBT/lang/';
Jules
atrol
Site Admin
Posts: 8534
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Stuck upgrading mantis ADMIN checks plugin

Post by atrol »

There is a known problem with these settings.
I created a bug report for that some years ago, but never had time to have a deeper look or to fix it myself https://www.mantisbt.org/bugs/view.php?id=21584

I had a very short look at the current code.
There are quite a lot of changes around this code since I reported this bug, so my original analysis, as well as some notes and hints of other users might be wrong.
Please use Search before posting and read the Manual
JulesA
Posts: 37
Joined: 11 Feb 2020, 10:01

Re: Stuck upgrading mantis ADMIN checks plugin

Post by JulesA »

Alright, thanks for the link, I had a look at it but couldn't make it work.
I'll check again.

Thanks a lot for the time spent, thanks for the precious help.

Have a great day.

Jules
Post Reply