Page 1 of 1
history_get_raw_events_array returns no data
Posted: 09 Mar 2006, 14:54
by Darkness
I am trying to hack some override functions together to generate some data for an IRC bot.
I created the file custom_functions_inc.php in the main folder.
In this file I created the functions:
* custom_function_override_issue_create_notify
* custom_function_override_issue_delete_notify
* custom_function_override_issue_update_notify
in custom_function_override_issue_update_notify, I call history_get_raw_events_array to get access to the history of an issue, but this does not seem to return any data. Neither does history_get_events_array.
Am I not allowed to call this function?
Do I need to include some file? (I tried with require_once ("core/history_api.php"); )
It's the history data that I would like to use for the IRC bot.
(btw, the overrides for update and delete do not work in rc5, I had to fix them myself, fix pending ;) )
edit: perhaps it was better to post it in the help section...
Posted: 09 Mar 2006, 21:04
by Guest
It would be great if you can submit any fixes to
http://bugs.mantisbt.org. Also the code for the integration with IRC.
You will need to include any core API that you are using. In this case core/history_api.php as you indicated.
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'history_api.php' );
The above code will guarantee that the path is correct independent of where the custom functions header file is included from.
Regards,
Victor
MantisConnect
http://www.futureware.biz
Posted: 09 Mar 2006, 21:05
by vboctor
Sorry, I wasn't logged in when I posted the reply.
Posted: 10 Mar 2006, 02:23
by Darkness
strange, this is what I did:
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'history_api.php' );
in the file custom_functions_inc.php. There I made the following function:
Code: Select all
function custom_function_override_issue_update_notify( $p_issue_id ) {
if (file_exists("_updatefile.txt")){
$contents = file_get_contents("_updatefile.txt");
}
else $contents ="";
$output="issue updated: ".$p_issue_id."\n";
$newfile="_updatefile.txt";
$file = fopen ($newfile, "w");
fwrite($file, $contents);
fwrite($file, $output);
fflush($file);
$hist = history_get_raw_events_array( $p_bug_id );
$history_count = count( $hist );
$output="history ($history_count): ";
for ( $i=0; $i < $history_count; $i++ ) {
$output.=$hist[$i]['date']."\t";
$output.=$hist[$i]['userid']."\t";
$output.=$hist[$i]['field']."\t";
$output.=$hist[$i]['type']."\t";
$output.=$hist[$i]['old_value']." => ";
$output.=$hist[$i]['new_value']."\t";
$output.=$hist[$i]['username']."\n";
}
fwrite($file, $output."\n");
fclose ($file);
}
for some reason this results in _updatefile.txt:
I don't get any content of the history. If I put this code in history_api.php, I get all the necessary info in the textfile.
what's going wrong here?
Posted: 10 Mar 2006, 02:25
by Darkness
hmm, something very strange is going on here with the code tag
Posted: 10 Mar 2006, 02:29
by Darkness
Anonymous wrote:It would be great if you can submit any fixes to
http://bugs.mantisbt.org. Also the code for the integration with IRC.
I submitted the fixes for the custom functions
here
When I succeeded in creating an IRC bot that makes use of the code I'm working on I will post the IRC bot here so other people can make use of it. I just need to work out some kind of protocol.
Posted: 10 Mar 2006, 02:30
by vboctor
The parameter name is $p_issue_id and you use $p_bug_id.
Regards,
Victor.
Mantis Blog
http://www.futureware.biz/
Posted: 10 Mar 2006, 02:34
by Darkness
holy shit, damn copy/paste...
thanks for seeing this :)
Posted: 10 Mar 2006, 02:35
by vboctor
I would recommend you make sure that notices are ON, this will catch such things for you.
Let me know when you get things running :)
Regards,
Victor
MantisConnect
http://www.futureware.biz/mantisconnect
Posted: 10 Mar 2006, 02:43
by Darkness
make sure notices are on??
I'm using a default install of rc5, and it did execute the overrriden function for create, but not for update and delete.
Posted: 10 Mar 2006, 02:46
by vboctor
I meant PHP notices are ON in order to catch problems like using an undefined variable like $p_bug_id. There may also be a config variable (I don't have access to it now) that allows you to make Mantis stop on a notice, rather than just output a message and continue.
Regards,
Victor
Posted: 10 Mar 2006, 02:48
by Darkness
oh, ok, I will check this. But for now I think I have the things I need to get an IRC bot working.
Will keep you guys updated ;)