I’m working with a PHP8.1 CodeIgniter application, and I’m facing an issue with a custom function my_add_custom_task_status($current_statuses) that adds custom task statuses based on a flow parameter in the URL.
function my_add_custom_task_status($current_statuses)
{
$CI = &get_instance();
$flow = $CI->input->get('flow'); // demo url: https://example.org/demo?flow=1 equals 1
//$flow = 1; if we just declare this, all works fine
if ($flow) {
$CI->load->model('flow/task_status_model');
$CI->session->set_userdata([
'tasks_kanban_view' => true,
]);
$new_statuses = $CI->task_status_model->get_statuses_by_flow($flow);
//var_dump($new_statuses) - no issue with $flow variable since it returns correct response from model
return $new_statuses; // it doesn't stop here
//die(); - even this is ignored
}
// It ignores the first return and continues below in the function
// var_dump($new_statuses) returns the correct array
// return $new_statuses leads to an error: $new_statuses not defined
// If I simply declare $flow=1 at the beginning, all works fine
return $current_statuses;
}
Problem:
When $flow is obtained from the URL using $CI->input->get('flow'), the return statement inside the if ($flow) block is ignored.
Even using die(); right after the return statement doesn’t stop the function execution.
The function then continues to the bottom and tries to execute the final return statement, which results in an error because $new_statuses is not defined outside the if ($flow) block.
Interestingly, if I hardcode $flow = 1; at the beginning, the function works as expected, and the return statement inside the if ($flow) block is respected.
What I've Tried:
I verified that the $flow value from the URL is correct and passed properly.
Debugging with var_dump($new_statuses) shows that $new_statuses contains the expected data.
Despite this, the return statement is still skipped, and the function continues executing past the if block.
Multiple devices , different servers apache/nginx
I’m working with a PHP8.1 CodeIgniter application, and I’m facing an issue with a custom function my_add_custom_task_status($current_statuses) that adds custom task statuses based on a flow parameter in the URL.
Problem: When $flow is obtained from the URL using $CI->input->get('flow'), the return statement inside the if ($flow) block is ignored. Even using die(); right after the return statement doesn’t stop the function execution. The function then continues to the bottom and tries to execute the final return statement, which results in an error because $new_statuses is not defined outside the if ($flow) block. Interestingly, if I hardcode $flow = 1; at the beginning, the function works as expected, and the return statement inside the if ($flow) block is respected.
What I've Tried: I verified that the $flow value from the URL is correct and passed properly. Debugging with var_dump($new_statuses) shows that $new_statuses contains the expected data. Despite this, the return statement is still skipped, and the function continues executing past the if block. Multiple devices , different servers apache/nginx