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

Error in SearchForm2.php when having a function in field definition #7084

Closed
Abuelodelanada opened this issue Mar 20, 2019 · 0 comments
Closed
Labels
Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Type:Bug Bugs within the core SuiteCRM codebase
Milestone

Comments

@Abuelodelanada
Copy link
Contributor

Issue

If you have a field in vardefs.php defined like this:

        'product_selector' => array(
            'name' => 'product_selector',
            'vname' => 'LBL_GCOOP_PRODUCT_NAME',
            'type' => 'enum',
            'len' => 36,
            'options' => '',
            'massupdate' => 0,
            'source' => 'non-db',
            'required' => true,
            'function' => array(
                'name' => 'get_products',
                'include' => 'modules/gcoop_SalesOpportunity/Helper.php',
            ),
        ),

And loading a subpanel of that module a Warning appears:

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'get_products' not found or invalid function name in /home/jose/trabajos/gca-suitecrm7.10x/include/SearchForm/SearchForm2.php on line 693

In the context of line 693 of include/SearchForm/SearchForm2.php you can see:

if (!empty($this->fieldDefs[$fvName]['function']['returns']) && $this->fieldDefs[$fvName]['function']['returns'] == 'html') {
    if (!empty($this->fieldDefs[$fvName]['function']['include'])) {
        require_once($this->fieldDefs[$fvName]['function']['include']);
    }
    $value = call_user_func($function_name, $this->seed, $name, $value, $this->view);
    $this->fieldDefs[$fvName]['value'] = $value;
} else {
    if (!isset($function['params']) || !is_array($function['params'])) {
        $this->fieldDefs[$fvName]['options'] = call_user_func($function_name, $this->seed, $name, $value, $this->view);
    } else {
        $this->fieldDefs[$fvName]['options'] = call_user_func_array($function_name, $function['params']);
    }
}

The problem is that the code execute a require_once only in the IF structure and not in the ELSE structure.

Expected Behavior

To require the function defined in vardefs.php

Actual Behavior

In some cases do not require the function

Possible Fix

Execute the require_once before the if..else structure or in both if and else.

Steps to Reproduce

  1. Define a function in a field in vardefs.php (Module A)
  2. Load a DetailView of Module B that hava a subpanel of Module A
  3. Check php log.

Your Environment

  • SuiteCRM Version used: 7.10.x
@Dillon-Brown Dillon-Brown added Type:Bug Bugs within the core SuiteCRM codebase Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds labels Mar 21, 2019
@samus-aran samus-aran added Resolved: Next Release and removed Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution labels Mar 25, 2019
@Dillon-Brown Dillon-Brown added this to the 7.11.3 milestone Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Type:Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

4 participants