Custom function using example code errors

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
SteveBaxter
Posts: 4
Joined: 31 Jul 2019, 20:10

Custom function using example code errors

Post by SteveBaxter »

Hello

I am making my first attempt a using a custom function but am getting an 'INTERNAL APPLICATION ERROR'

This is what I did..

1. I created a new file in the config folder called custom_functions_inc.php
2. I copied the example code into this file for function custom_function_override_roadmap_print_issue from the documentation here : http://www.mantisbt.org/docs/master/en- ... ct.roadmap

My intention was to amend the example code to suit my purposes but I can't get the original code to work !

What am I doing wrong? I am hoping I have made some basic and obvious error that a more experienced user will immediately spot :-)

(I am using the current stable release of MantisBT 2.21.1 running on my own hosted webserver with PHP 7.3.7)
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom function using example code errors

Post by cas »

Trying to find the problem can be cumbersome.
Simple trick is to comment out the lines and then try y uncommenting the lines one by one.
Sometimes it is reall soemthing stupid like a typo :oops:
SteveBaxter
Posts: 4
Joined: 31 Jul 2019, 20:10

Re: Custom function using example code errors

Post by SteveBaxter »

Thanks cas - I followed your advice and commented out the code a line at a time. Unfortunately the error did not clear until I have commented out the entire function including its declaration - leaving just a <?php in the file :-)

Just having the code

Code: Select all

<?php
​function custom_function_override_roadmap_print_issue( $p_issue_id, $p_issue_level = 0 ) { }
..is enough to cause the error.

I also tried just adding a simple echo 'Test'; to the function so it had a body, also I copied in the code from the custom_function_default_roadmap_print_issue() function in the MantisBT core code.

Stumped !
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom function using example code errors

Post by cas »

Strange, perhaps documentation is not fully update to latest release.
If you just add:

Code: Select all

<?php
function XXX ($id){
}
still an error message?
SteveBaxter
Posts: 4
Joined: 31 Jul 2019, 20:10

Re: Custom function using example code errors

Post by SteveBaxter »

That doesn't cause an error, however this does...

Code: Select all

<?php
​function custom_function_override_roadmap_print_issue( $p_issue_id, $p_issue_level = 0 ) {

}
It is indeed, strange ! Whilst the function is specific to the Roadmap the site errors wherever which suggests to me that the very existence of the function, irrespective of its content, is causing a site wide error.
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom function using example code errors

Post by cas »

What do you want the custiom function for?
Give it a logical name refering to its purpose.
SteveBaxter
Posts: 4
Joined: 31 Jul 2019, 20:10

Re: Custom function using example code errors

Post by SteveBaxter »

The custom function is to change the format of entries listed on the Roadmap page so I can tailor this to our specific needs. The function name is dictated by MantisBT as documented here http://www.mantisbt.org/docs/master/en- ... ct.roadmap
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom function using example code errors

Post by cas »

Then I would start with copying the existing function "custom_function_default_roadmap_print_issue" which is located in custom_function_api.php within the core directory.
Change the name according instructions and see if that works as expected. If so, you can make the required changes.
Post Reply