View Issue Details

IDProjectCategoryView StatusLast Update
0037343mantisbtplug-inspublic2026-08-18 11:06
ReporterprzemyslawWiatr Assigned Todregad  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Target Version2.29.0Fixed in Version2.29.0 
Summary0037343: validation error check mismatches return types
Description

bug_actiongroup_ext.php checks for failed id's by matching the type of the value returned from validation function to not null:

$t_failed_ids = array();

foreach( $t_projects_bugs as $t_project_id => $t_bugs ) {
    $g_project_override = $t_project_id;
    foreach( $t_bugs as $t_bug_id ) {
        $t_fail_reason = bug_group_action_validate( $f_action, $t_bug_id );
        if( $t_fail_reason !== null ) {
            $t_failed_ids[$t_bug_id] = $t_fail_reason;
        }
        if( !isset( $t_failed_ids[$t_bug_id] ) ) {
            $t_fail_reason = bug_group_action_process( $f_action, $t_bug_id );
            if( $t_fail_reason !== null ) {
                $t_failed_ids[$t_bug_id] = $t_fail_reason;
            }
        }
    }
}

However, the validation function is supposed to return either true on success or a key=>value array with reasons for validation failure:

/**
 * Validates the combination of an action and a bug.  This ends up calling
 * action_<action>_validate() from bug_actiongroup_<action>_inc.php
 *
 * @param string  $p_action The custom action name without the "EXT_" prefix.
 * @param integer $p_bug_id The id of the bug to validate the action on.
 *
 * @return boolean|array true if action can be applied or array of ( bug_id => reason for failure to validate )
 */
function bug_group_action_validate( $p_action, $p_bug_id ) {
    $t_function_name = 'action_' . $p_action . '_validate';
    return $t_function_name( $p_bug_id );
}
Steps To Reproduce

I'm using asterisk (*) as a placeholder here,

  1. Create new bug_actiongroup_*_inc.php
  2. Inside bug_action_group_*_inc.php create function action_*_validate(int $p_bug_id) that returns true
  3. Validation will fail and the function action_*_process(int $p_bug_id) will not be called for the given $p_bug_id
TagsNo tags attached.

Activities

atrol

atrol

2026-08-06 13:54

developer   ~0071342

PR https://github.com/mantisbt/mantisbt/pull/2257

dregad

dregad

2026-08-18 10:44

developer   ~0071344

@przemyslawWiatr I checked our internal implementations of the action_XXX_validate() function:

$ git grep -P "action_\w+_validate\("
bug_actiongroup_add_note_inc.php:121:function action_add_note_validate( $p_bug_id ) {
bug_actiongroup_attach_tags_inc.php:72:function action_attach_tags_validate( $p_bug_id ) {
bug_actiongroup_update_product_build_inc.php:76:function action_update_product_build_validate( $p_bug_id ) {
bug_actiongroup_update_severity_inc.php:80:function action_update_severity_validate( $p_bug_id ) {

None of them actually follow the boolean|array return type documented for bug_group_action_validate(). Instead, they all return string|null, which matches what is expected by the foreach loop in bug_actiongroup_ext.php at line 98.

In fact, tt does not make any sense to return an array, considering that bug_group_action_validate() only processes a single Issue at a time.

Consequently, I believe that your proposed change is not necessary, and we should just update the PHPDoc comment to reflect what the code actually does instead.

Related Changesets

MantisBT: master dcf3bdcd

2026-08-18 10:46

dregad


Details Diff
Fix PHPDoc for bug_group_action_validate()

The documented return value was incorrect. Updated to reflect actual
usage in action_*_validate() functions and bug_actiongroup_ext.php.

Fixes 0037343
Affected Issues
0037343
mod - core/bug_group_action_api.php Diff File