Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports Dashlet configuration bug for date “Period” parameters when using more than one report parameter, causing a fatal error and empty dashlet. #10610

Open
maclordaj opened this issue Jan 8, 2025 · 0 comments
Labels
Type: Bug Bugs within the core SuiteCRM codebase

Comments

@maclordaj
Copy link

maclordaj commented Jan 8, 2025

Issue

Description of the Issue

When an Advanced Open Reports (AOR) dashlet has multiple parameters and one of them is a “Period” parameter that is not the first parameter in the report, the dashlet config template renders that parameter using:

<select name="parameter_value[]">
    ...
</select>

instead of

<select name="parameter_value[{$condition.key}]">
    ...
</select>

Meanwhile, the associated hidden fields for that parameter use [{$condition.key}]. As a result, SuiteCRM’s backend receives inconsistent array indexes for this parameter in requestToUserParameters(), passing an empty or invalid value to getPeriodEndDate(). Eventually, this can trigger a fatal error (“Call to a member function sub() on null”).

Possible Fix

In the dashlet configuration template, change the select for Period to include the condition.key index.
For Instance, in:

<tr>
    ...
    {if $condition.value_type == "Period"}
        <select name='parameter_value[]'>
            {html_options options=$date_time_period_list selected=$condition.value}
        </select>
    {/if}
    ...
</tr>

replace with

<select name="parameter_value[{$condition.key}]">
    {html_options options=$date_time_period_list selected=$condition.value}
</select>

Steps to Reproduce the Issue

  1. Create a report in AOR_Reports with at least one parameter of type “Period” (e.g., “today,” “yesterday,” etc.).
    2. Add this report as a dashlet on the Home page.
    3. In the dashlet configuration screen, check that the “Period” parameter is displayed. Observe that the generated HTML select uses name="parameter_value[]" instead of something like name="parameter_value[0]".
    4. After saving or changing the parameter in the dashlet, SuiteCRM’s changeReportPage action may throw a fatal error or fail to load the correct data.

If the “Period” parameter is the first parameter in the report, you may not see the issue because the code and indexes sometimes align. The bug appears when the Period parameter is not the first in the list, causing mismatched indexes in the dashlet config form.

Context

Context
• This bug affects any user trying to configure an AOR Report Dashlet that includes “Period” type parameters.
• It can result in an empty or incorrect value for the parameter, sometimes causing a PHP fatal error if SuiteCRM attempts to manipulate a null date object.

Version

7.14.6

What browser are you currently using?

Chrome

Browser Version

Chrome

Environment Information

Mysql, PHP

Operating System and Version

Ubuntu

@maclordaj maclordaj added the Type: Bug Bugs within the core SuiteCRM codebase label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

1 participant