View Issue Details

IDProjectCategoryView StatusLast Update
0037343mantisbtplug-inspublic2026-08-06 13:55
ReporterprzemyslawWiatr Assigned Tocommunity  
PrioritylowSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version2.28.4 
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