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

FIX #7923 - Verify the variable is an array #7924

Merged

Conversation

@Abuelodelanada
Copy link
Contributor

Abuelodelanada commented Sep 24, 2019

Description

Read #7923

Now the Smarty code is 'transformed' into a php file in cache/smarty/templates_c with

<?php if (is_array ( $this->_tpl_vars['ROWS_BUTTONS'][$this->_tpl_vars['rowHeader']] ) && count($this->_tpl_vars['ROWS_BUTTONS'][$this->_tpl_vars['rowHeader']]) > 0): ?>

As we can see if the variable is not an array, we do not count it, avoiding Warnings

How To Test This

  1. Run SuiteCRM with PHP 7.3
  2. Load a DetailView with subpanels
  3. Reload a Subpanle
  4. Check this Warning is not in PHP error log

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.
@Mac-Rae

This comment has been minimized.

Copy link
Contributor

Mac-Rae commented Sep 25, 2019

Hi @Abuelodelanada,

Could you provide some more detailed testing & replication instructions as I have been unable to replicate the error in the latest version without your fix?

@Abuelodelanada

This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Sep 25, 2019

Hi @Mac-Rae

This happens when there is no button_row in a subpanel. Sometimes you have subpanels with data retrieved from a WS and there is no action available for the records.

Try removing the row_buttons in, for example, in modules/Opportunities/metadata/subpanels/ForAccounts.php

-        'edit_button'=>array(
-            'vname' => 'LBL_EDIT_BUTTON',
-            'widget_class' => 'SubPanelEditButton',
-            'module' => 'Opportunities',
-            'width' => '4%',
-        ),

If you do this, you will get this in php log when you refresh (or re-order) the subpanel:

PHP Notice:  Undefined index: b9990462-021c-0176-f28d-5d8ba61c0243 in /home/jose/trabajos/SuiteCRM/cache/smarty/templates_c/%%8C^8C3^8C367BA2%%SubPanelDynamic.tpl.php on line 72
PHP Stack trace:
PHP   1. {main}() /home/jose/trabajos/SuiteCRM/index.php:0
PHP   2. SugarApplication->execute() /home/jose/trabajos/SuiteCRM/index.php:52
PHP   3. SugarController->execute() /home/jose/trabajos/SuiteCRM/include/MVC/SugarApplication.php:113
PHP   4. SugarController->process() /home/jose/trabajos/SuiteCRM/include/MVC/Controller/SugarController.php:373
PHP   5. SugarController->handleActionMaps() /home/jose/trabajos/SuiteCRM/include/MVC/Controller/SugarController.php:468
PHP   6. require_once() /home/jose/trabajos/SuiteCRM/include/MVC/Controller/SugarController.php:1087
PHP   7. SubPanel->display() /home/jose/trabajos/SuiteCRM/include/SubPanel/SubPanelViewer.php:96
PHP   8. SubPanel->ProcessSubPanelListView() /home/jose/trabajos/SuiteCRM/include/SubPanel/SubPanel.php:236
PHP   9. ListViewSubPanel->process_dynamic_listview() /home/jose/trabajos/SuiteCRM/include/SubPanel/SubPanel.php:220
PHP  10. Sugar_Smarty->display() /home/jose/trabajos/SuiteCRM/include/ListView/ListViewSubPanel.php:162
PHP  11. Sugar_Smarty->fetch() /home/jose/trabajos/SuiteCRM/vendor/smarty/smarty/libs/Smarty.class.php:1113
PHP  12. Sugar_Smarty->fetch() /home/jose/trabajos/SuiteCRM/include/Sugar_Smarty.php:164
PHP  13. include() /home/jose/trabajos/SuiteCRM/vendor/smarty/smarty/libs/Smarty.class.php:1263 

It's very strange, but before (when I opened the issue) the error was slightly different:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in

I was debuging some hours to find out why the error changed, but I could not find the reason.

Anyway we should check in themes/SuiteP/include/SubPanel/tpls/SubPanelDynamic.tpl file if $this->_tpl_vars['ROWS_BUTTONS'][$this->_tpl_vars['rowHeader']] is set.

@Abuelodelanada

This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Oct 2, 2019

Hi @Mac-Rae

Could you read how to test this PR?

@Mac-Rae

This comment has been minimized.

Copy link
Contributor

Mac-Rae commented Oct 3, 2019

Assessed 👍

@Mac-Rae Mac-Rae added the Assessed label Oct 3, 2019
@Dillon-Brown Dillon-Brown merged commit 363001b into salesagility:hotfix-7.10.x Oct 3, 2019
3 checks passed
3 checks passed
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Abuelodelanada Abuelodelanada deleted the gcoop-libre:hotfix-7.10.x-7923 branch Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.