9
9
# set up error_handler() as the new default error handling function
10
10
set_error_handler ( 'mc_error_handler ' );
11
11
12
- # override some MantisBT configurations
13
- $ g_show_detailed_errors = OFF ;
14
- $ g_stop_on_errors = ON ;
15
- $ g_display_errors = array (
16
- E_WARNING => 'halt ' ,
17
- E_NOTICE => 'halt ' ,
18
- E_USER_ERROR => 'halt ' ,
19
- E_USER_WARNING => 'halt ' ,
20
- E_USER_NOTICE => 'halt ' ,
21
- );
22
-
23
12
/**
24
13
* Get the MantisConnect webservice version.
25
14
*/
@@ -86,10 +75,12 @@ function mci_has_administrator_access( $p_user_id, $p_project_id = ALL_PROJECTS
86
75
}
87
76
88
77
function mci_get_project_id ( $ p_project ) {
89
- if ( (int ) $ p_project ['id ' ] != 0 ) {
78
+ if ( isset ( $ p_project [ ' id ' ] ) && (int ) $ p_project ['id ' ] != 0 ) {
90
79
$ t_project_id = (int ) $ p_project ['id ' ];
91
- } else {
80
+ } else if ( isset ( $ p_project [ ' name ' ] ) && ! is_blank ( $ p_project [ ' name ' ] ) ) {
92
81
$ t_project_id = project_get_id_by_name ( $ p_project ['name ' ] );
82
+ } else {
83
+ $ t_project_id = ALL_PROJECTS ;
93
84
}
94
85
95
86
return $ t_project_id ;
@@ -177,7 +168,7 @@ function mci_null_if_empty( $p_value ) {
177
168
* @return MantisBT URL terminated by a /.
178
169
*/
179
170
function mci_get_mantis_path () {
180
-
171
+
181
172
return config_get ( 'path ' );
182
173
}
183
174
@@ -260,26 +251,26 @@ function mci_filter_db_get_available_queries( $p_project_id = null, $p_user_id =
260
251
# first, we can override any query that has the same name as a private query
261
252
# with that private one
262
253
$ query = "SELECT * FROM $ t_filters_table
263
- WHERE (project_id=' $ t_project_id'
264
- OR project_id='0')
265
- AND name!=''
266
- ORDER BY is_public DESC, name ASC " ;
267
- $ result = db_query ( $ query );
254
+ WHERE (project_id= " . db_param () . "
255
+ OR project_id=0)
256
+ AND name!=''
257
+ AND (is_public = " . db_prepare_bool (true ) . "
258
+ OR user_id = " . db_param () . ")
259
+ ORDER BY is_public DESC, name ASC " ;
260
+ $ result = db_query_bound ( $ query , Array ( $ t_project_id , $ t_user_id ) );
268
261
$ query_count = db_num_rows ( $ result );
269
262
270
263
for ( $ i = 0 ;$ i < $ query_count ;$ i ++ ) {
271
264
$ row = db_fetch_array ( $ result );
272
- if (( $ row ['user_id ' ] == $ t_user_id ) || db_prepare_bool ( $ row ['is_public ' ] ) ) {
273
-
274
- $ t_filter_detail = explode ( '# ' , $ row ['filter_string ' ], 2 );
275
- if ( !isset ($ t_filter_detail [1 ]) ) {
276
- continue ;
277
- }
278
- $ t_filter = unserialize ( $ t_filter_detail [1 ] );
279
- $ t_filter = filter_ensure_valid_filter ( $ t_filter );
280
- $ row ['url ' ] = filter_get_url ( $ t_filter );
281
- $ t_overall_query_arr [$ row ['name ' ]] = $ row ;
265
+
266
+ $ t_filter_detail = explode ( '# ' , $ row ['filter_string ' ], 2 );
267
+ if ( !isset ($ t_filter_detail [1 ]) ) {
268
+ continue ;
282
269
}
270
+ $ t_filter = unserialize ( $ t_filter_detail [1 ] );
271
+ $ t_filter = filter_ensure_valid_filter ( $ t_filter );
272
+ $ row ['url ' ] = filter_get_url ( $ t_filter );
273
+ $ t_overall_query_arr [$ row ['name ' ]] = $ row ;
283
274
}
284
275
285
276
return array_values ( $ t_overall_query_arr );
@@ -300,11 +291,11 @@ function mci_category_as_array_by_id( $p_category_id ) {
300
291
301
292
/**
302
293
* Transforms a version array into an array suitable for marshalling into ProjectVersionData
303
- *
294
+ *
304
295
* @param array $p_version
305
296
*/
306
297
function mci_project_version_as_array ( $ p_version ) {
307
-
298
+
308
299
return array (
309
300
'id ' => $ p_version ['id ' ],
310
301
'name ' => $ p_version ['version ' ],
@@ -318,31 +309,23 @@ function mci_project_version_as_array( $p_version ) {
318
309
319
310
/**
320
311
* Returns time tracking information from a bug note.
321
- *
312
+ *
322
313
* @param int $p_issue_id The id of the issue
323
314
* @param Array $p_note A note as passed to the soap api methods
324
- *
315
+ *
325
316
* @return String the string time entry to be added to the bugnote, in 'HH:mm' format
326
317
*/
327
318
function mci_get_time_tracking_from_note ( $ p_issue_id , $ p_note ) {
328
-
319
+
329
320
if ( !access_has_bug_level ( config_get ( 'time_tracking_view_threshold ' ), $ p_issue_id ) )
330
321
return '00:00 ' ;
331
322
332
323
if ( !isset ( $ p_note ['time_tracking ' ] ))
333
324
return '00:00 ' ;
334
-
325
+
335
326
return db_minutes_to_hhmm ($ p_note ['time_tracking ' ]);
336
327
}
337
328
338
- /**
339
- * SECURITY NOTE: these globals are initialized here to prevent them
340
- * being spoofed if register_globals is turned on
341
- */
342
- $ g_error_parameters = array ();
343
- $ g_error_handled = false ;
344
- $ g_error_proceed_url = null ;
345
-
346
329
# Default error handler
347
330
#
348
331
# This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
@@ -352,9 +335,6 @@ function mci_get_time_tracking_from_note( $p_issue_id, $p_note) {
352
335
# The others, being system errors, will come with a string in $p_error
353
336
#
354
337
function mc_error_handler ( $ p_type , $ p_error , $ p_file , $ p_line , $ p_context ) {
355
- global $ g_error_parameters , $ g_error_handled , $ g_error_proceed_url ;
356
- global $ g_lang_overrides ;
357
- global $ g_error_send_page_header ;
358
338
global $ l_oServer ;
359
339
360
340
# check if errors were disabled with @ somewhere in this call chain
@@ -363,24 +343,13 @@ function mc_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
363
343
return ;
364
344
}
365
345
366
- $ t_lang_pushed = false ;
367
-
368
346
# flush any language overrides to return to user's natural default
369
347
if ( function_exists ( 'db_is_connected ' ) ) {
370
348
if ( db_is_connected () ) {
371
349
lang_push ( lang_get_default () );
372
- $ t_lang_pushed = true ;
373
350
}
374
351
}
375
352
376
- $ t_short_file = basename ( $ p_file );
377
- $ t_method_array = config_get ( 'display_errors ' );
378
- if ( isset ( $ t_method_array [$ p_type ] ) ) {
379
- $ t_method = $ t_method_array [$ p_type ];
380
- } else {
381
- $ t_method = 'none ' ;
382
- }
383
-
384
353
# build an appropriate error string
385
354
switch ( $ p_type ) {
386
355
case E_WARNING :
@@ -400,22 +369,21 @@ function mc_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
400
369
$ t_error_description = error_string ( $ p_error );
401
370
break ;
402
371
case E_USER_NOTICE :
403
-
404
372
# used for debugging
405
373
$ t_error_type = 'DEBUG ' ;
406
374
$ t_error_description = $ p_error ;
407
375
break ;
408
376
default :
409
-
410
377
#shouldn't happen, just display the error just in case
411
378
$ t_error_type = '' ;
412
379
$ t_error_description = $ p_error ;
413
380
}
414
381
415
- $ t_error_description = $ t_error_description ;
416
382
$ t_error_stack = error_get_stack_trace ();
383
+
384
+ error_log ("[mantisconnect.php] Error Type: $ t_error_type, \nError Description: $ t_error_description \nStack Trace: \n$ t_error_stack " );
417
385
418
- $ l_oServer ->fault ( 'Server ' , "Error Type: $ t_error_type, \nError Description: \n $ t_error_description , \n Stack Trace: \n $ t_error_stack " );
386
+ $ l_oServer ->fault ( 'Server ' , "Error Type: $ t_error_type, \nError Description: $ t_error_description " );
419
387
$ l_oServer ->send_response ();
420
388
exit ();
421
389
}
@@ -480,9 +448,9 @@ function error_get_stack_trace() {
480
448
}
481
449
482
450
/**
483
- * Returns a soap_fault signalling corresponding to a failed login
451
+ * Returns a soap_fault signalling corresponding to a failed login
484
452
* situation
485
- *
453
+ *
486
454
* @return soap_fault
487
455
*/
488
456
function mci_soap_fault_login_failed () {
@@ -492,7 +460,7 @@ function mci_soap_fault_login_failed() {
492
460
/**
493
461
* Returns a soap_fault signalling that the user does not have
494
462
* access rights for the specific action.
495
- *
463
+ *
496
464
* @param int $p_user_id a valid user id
497
465
* @param string $p_detail The optional details to append to the error message
498
466
* @return soap_fault
@@ -502,6 +470,6 @@ function mci_soap_fault_access_denied( $p_user_id, $p_detail = '' ) {
502
470
$ t_reason = 'Access denied for user ' . $ t_user_name . '. ' ;
503
471
if ( !is_blank ( $ p_detail ))
504
472
$ t_reason .= ' Reason: ' . $ p_detail . '. ' ;
505
-
473
+
506
474
return new soap_fault ( 'Client ' , '' , $ t_reason );
507
475
}
0 commit comments