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

PHP Notice in SugarWidgetField.php #7912

Closed
Abuelodelanada opened this issue Sep 23, 2019 · 0 comments
Closed

PHP Notice in SugarWidgetField.php #7912

Abuelodelanada opened this issue Sep 23, 2019 · 0 comments
Labels
Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type:Bug Bugs within the core SuiteCRM codebase

Comments

@Abuelodelanada
Copy link
Contributor

Abuelodelanada commented Sep 23, 2019

Issue

The method getVardef() in include/generic/SugarWidgets/SugarWidgetField.php is not checking that column_key and reporter are setted.

    public function getVardef($layout_def)
    {
        $myName = $layout_def['column_key'];
        $vardef = $this->layout_manager->defs['reporter']->all_fields[$myName];

        if (!isset($vardef)) {
            // No vardef, return an empty array
            return array();
        }
        return $vardef;
    }

Because of this, many PHP Notice like these are register in php log:

[Mon Sep 23 15:17:45 2019] PHP Notice:  Undefined index: column_key in /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetField.php on line 233                                                                                    
[Mon Sep 23 15:17:45 2019] PHP Stack trace:                                                                                                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   1. {main}() /home/jose/trabajos/gca-suitecrm7.10x/index.php:0                                                                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP   2. SugarApplication->execute() /home/jose/trabajos/gca-suitecrm7.10x/index.php:80                                                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP   3. SugarController->execute() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/SugarApplication.php:113                                                                                                                     
[Mon Sep 23 15:17:45 2019] PHP   4. SugarController->processView() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:375                                                                                                       
[Mon Sep 23 15:17:45 2019] PHP   5. CustomSugarView->process() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:435                                                                                                           
[Mon Sep 23 15:17:45 2019] PHP   6. ViewClassic->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/SugarView.php:108                                                                                                                    
[Mon Sep 23 15:17:45 2019] PHP   7. SugarView->includeClassicFile() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/views/view.classic.php:32                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   8. include_once() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/View/SugarView.php:818                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   9. SubPanel->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/modules/Contacts/SubPanelViewer.php:69                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP  10. SubPanel->ProcessSubPanelListView() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:238                                                                                                               
[Mon Sep 23 15:17:45 2019] PHP  11. ListViewSubPanel->process_dynamic_listview() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:222                                                                                                      
[Mon Sep 23 15:17:45 2019] PHP  12. ListViewSubPanel->process_dynamic_listview_rows() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:159                                                                                         
[Mon Sep 23 15:17:45 2019] PHP  13. LayoutManager->widgetDisplay() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:508                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP  14. SugarWidgetFieldInt->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/LayoutManager.php:375                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP  15. SugarWidgetReportField->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldint.php:96                                                                                           
[Mon Sep 23 15:17:45 2019] PHP  16. SugarWidgetFieldFloatDecorated->displayList() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetReportField.php:104                                                                           
[Mon Sep 23 15:17:45 2019] PHP  17. SugarWidgetFieldFloat->displayList() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/generic/SugarWidgets/SugarWidgetFieldFloatDecorated.php:13                                                                      
[Mon Sep 23 15:17:45 2019] PHP  18. SugarWidgetField->getVardef() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldfloat.php:49                                                                                             
[Mon Sep 23 15:17:45 2019] PHP Notice:  Undefined index: reporter in /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetField.php on line 234                                                                                      
[Mon Sep 23 15:17:45 2019] PHP Stack trace:                                                                                                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   1. {main}() /home/jose/trabajos/gca-suitecrm7.10x/index.php:0                                                                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP   2. SugarApplication->execute() /home/jose/trabajos/gca-suitecrm7.10x/index.php:80                                                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP   3. SugarController->execute() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/SugarApplication.php:113                                                                                                                     
[Mon Sep 23 15:17:45 2019] PHP   4. SugarController->processView() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:375                                                                                                       
[Mon Sep 23 15:17:45 2019] PHP   5. CustomSugarView->process() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:435                                                                                                           
[Mon Sep 23 15:17:45 2019] PHP   6. ViewClassic->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/SugarView.php:108                                                                                                                    
[Mon Sep 23 15:17:45 2019] PHP   7. SugarView->includeClassicFile() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/views/view.classic.php:32                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   8. include_once() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/View/SugarView.php:818                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   9. SubPanel->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/modules/Contacts/SubPanelViewer.php:69                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP  10. SubPanel->ProcessSubPanelListView() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:238                                                                                                               
[Mon Sep 23 15:17:45 2019] PHP  11. ListViewSubPanel->process_dynamic_listview() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:222                                                                                                      
[Mon Sep 23 15:17:45 2019] PHP  12. ListViewSubPanel->process_dynamic_listview_rows() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:159                                                                                         
[Mon Sep 23 15:17:45 2019] PHP  13. LayoutManager->widgetDisplay() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:508                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP  14. SugarWidgetFieldInt->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/LayoutManager.php:375                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP  15. SugarWidgetReportField->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldint.php:96                                                                                           
[Mon Sep 23 15:17:45 2019] PHP  16. SugarWidgetFieldFloatDecorated->displayList() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetReportField.php:104                                                                           
[Mon Sep 23 15:17:45 2019] PHP  17. SugarWidgetFieldFloat->displayList() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/generic/SugarWidgets/SugarWidgetFieldFloatDecorated.php:13                                                                      
[Mon Sep 23 15:17:45 2019] PHP  18. SugarWidgetField->getVardef() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldfloat.php:49                                                                                             
[Mon Sep 23 15:17:45 2019] PHP Notice:  Trying to get property of non-object in /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetField.php on line 234                                                                           
[Mon Sep 23 15:17:45 2019] PHP Stack trace:                                                                                                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   1. {main}() /home/jose/trabajos/gca-suitecrm7.10x/index.php:0                                                                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP   2. SugarApplication->execute() /home/jose/trabajos/gca-suitecrm7.10x/index.php:80                                                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP   3. SugarController->execute() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/SugarApplication.php:113                                                                                                                     
[Mon Sep 23 15:17:45 2019] PHP   4. SugarController->processView() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:375                                                                                                       
[Mon Sep 23 15:17:45 2019] PHP   5. CustomSugarView->process() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/Controller/SugarController.php:435                                                                                                           
[Mon Sep 23 15:17:45 2019] PHP   6. ViewClassic->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/SugarView.php:108                                                                                                                    
[Mon Sep 23 15:17:45 2019] PHP   7. SugarView->includeClassicFile() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/MVC/View/views/view.classic.php:32                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   8. include_once() /home/jose/trabajos/gca-suitecrm7.10x/include/MVC/View/SugarView.php:818                                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP   9. SubPanel->display() /home/jose/trabajos/gca-suitecrm7.10x/custom/modules/Contacts/SubPanelViewer.php:69                                                                                                                   
[Mon Sep 23 15:17:45 2019] PHP  10. SubPanel->ProcessSubPanelListView() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:238                                                                                                               
[Mon Sep 23 15:17:45 2019] PHP  11. ListViewSubPanel->process_dynamic_listview() /home/jose/trabajos/gca-suitecrm7.10x/include/SubPanel/SubPanel.php:222                                                                                                      
[Mon Sep 23 15:17:45 2019] PHP  12. ListViewSubPanel->process_dynamic_listview_rows() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:159                                                                                         
[Mon Sep 23 15:17:45 2019] PHP  13. LayoutManager->widgetDisplay() /home/jose/trabajos/gca-suitecrm7.10x/include/ListView/ListViewSubPanel.php:508                                                                                                            
[Mon Sep 23 15:17:45 2019] PHP  14. SugarWidgetFieldInt->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/LayoutManager.php:375                                                                                                                
[Mon Sep 23 15:17:45 2019] PHP  15. SugarWidgetReportField->display() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldint.php:96                                                                                           
[Mon Sep 23 15:17:45 2019] PHP  16. SugarWidgetFieldFloatDecorated->displayList() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetReportField.php:104                                                                           
[Mon Sep 23 15:17:45 2019] PHP  17. SugarWidgetFieldFloat->displayList() /home/jose/trabajos/gca-suitecrm7.10x/custom/include/generic/SugarWidgets/SugarWidgetFieldFloatDecorated.php:13
[Mon Sep 23 15:17:45 2019] PHP  18. SugarWidgetField->getVardef() /home/jose/trabajos/gca-suitecrm7.10x/include/generic/SugarWidgets/SugarWidgetFieldfloat.php:49

Expected Behavior

Avoid annoying PHP Notices ;-)

Actual Behavior

A lot of PHP Notices are in the php log.

Possible Fix

We sould verify if column_key and reporter are setted with something like this

        if (!empty($layout_def['column_key']) && !empty($this->layout_manager->defs['reporter'])) {
            $myName = $layout_def['column_key'];
            $vardef = $this->layout_manager->defs['reporter']->all_fields[$myName];
        }

Steps to Reproduce

  1. Define a Float field in a subpanel
  2. Check for Notices in PHP log

Context

Your Environment

  • SuiteCRM Version used: 7.10.20
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.3
  • Operating System and version (e.g Ubuntu 16.04): Ubuntu 19.04
@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 Sep 24, 2019
Dillon-Brown added a commit that referenced this issue Oct 3, 2019
FIX #7912 - Avoid PHP Notices in getVardefs() method
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 Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type:Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

3 participants