Error while upgrading from 7.13.0 to 7.14.0

Upgrading from 7.13.0 to 7.14.0 I get the following error:

Fatal error: Uncaught Error: Non-static method MetaParser::hasMultiplePanels() cannot be called statically in /suitecrmroot/modules/UpgradeWizard/SugarMerge/EditViewMerge.php:612 Stack trace: #0 /suitecrmroot/modules/UpgradeWizard/SugarMerge/EditViewMerge.php(576): EditViewMerge->getFields(Array) #1 /suitecrmroot/modules/UpgradeWizard/SugarMerge/EditViewMerge.php(778): EditViewMerge->mergeMetaData() #2 /suitecrmroot/modules/UpgradeWizard/SugarMerge/SugarMerge.php(204): EditViewMerge->merge(ā€˜Meetingsā€™, ā€˜modules/Meetingā€¦ā€™, ā€˜/is/htdocs/wp10ā€¦ā€™, ā€˜custom/modules/ā€¦ā€™, true) #3 /suitecrmroot/modules/UpgradeWizard/SugarMerge/SugarMerge.php(172): SugarMerge->mergeFile(ā€˜Meetingsā€™, ā€˜editviewdefs.phā€¦ā€™, true, true) #4 /suitecrmroot/modules/UpgradeWizard/SugarMerge/SugarMerge.php(140): SugarMerge->mergeModule(ā€˜Meetingsā€™, true, true, true) #5 /suitecrmroot/modules/UpgradeWizard/commit.php(275): SugarMerge->mergeAll(true, true, true) #6 /suitecrmroot/modules/UpgradeWizard/index.php(298): require(ā€˜/is/htdocs/wp10ā€¦ā€™) #7 /suitecrmroot/include/MVC/View/SugarView.php(824): include_once(ā€˜/is/htdocs/wp10ā€¦ā€™) #8 /suitecrmroot/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile(ā€˜cache/smarty/teā€¦ā€™) #9 /suitecrmroot/include/MVC/View/SugarView.php(210): ViewClassic->display() #10 /suitecrmroot/include/MVC/Controller/SugarController.php(432): SugarView->process() #11 /suitecrmroot/include/MVC/Controller/SugarController.php(363): SugarController->processView() #12 /suitecrmroot/include/MVC/SugarApplication.php(101): SugarController->execute() #13 /suitecrmroot/index.php(52): SugarApplication->execute() #14 {main} thrown in /suitecrmroot/modules/UpgradeWizard/SugarMerge/EditViewMerge.php on line 612

Has somebody any idea? What can I do?

Looks like a PHP version issue.

Check the compatibility matrix and make sure you stay inside it

I think you might need to manually fix this file
Because the minimum version required for SuiteCRM 7.14 is php 8.1 and since php 8 this a fatal error that non static member functions cannot be called statically

Just to the definition of the function that is causing the error and add static in itā€™s definition

Yesterday I tried it with php 8.0 (according to suitecrm 7.13) and with php 8.1.
The error was the same.

So I think I have to edit EditViewMerge.php as proposed by abuzarfaris.
I would change from line 610:

    if ($this->scanForMultiPanel) {
        require_once('include/SugarFields/Parsers/MetaParser.php');
        if ($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) {
            $panels = array($this->defaultPanel=>$panels);
            $this->isMultiPanel = false;
        }
    }

to

    if ($this->scanForMultiPanel) {
        require_once('include/SugarFields/Parsers/MetaParser.php');
        if ($setDefaultPanel) {
            $panels = array($this->defaultPanel=>$panels);
            $this->isMultiPanel = false;
        }
		else
		$varMetaParser = new MetaParser();			
        if (!$varMetaParser->hasMultiplePanels($panels)) {
            $panels = array($this->defaultPanel=>$panels);
            $this->isMultiPanel = false;
        }				
    }

It could be correct?

Hi @heitmann,

Thanks for your feedback.

Could you provide some more info about your environment, please?

Namely what php and os version are you using? from what Iā€™ve understood its php 8.0?

System: Linux 4.19.0-24-amd64 #1 SMP Debian 4.19.282-1 (2023-04-29) x86_64 GNU/Linux
Server API: Apache 2.0 Handler
PHP Version: 8.0.29

Thank you @heitmann.

On your php.ini what is the value that you have set for error_reporting?

Hey
This is probably a better fix

       if ($this->scanForMultiPanel) {
            require_once('include/SugarFields/Parsers/MetaParser.php');
            $hasMultiplePanels=(new MetaParser())->hasMultiplePanels($panels);
            if ($setDefaultPanel || !$hasMultiplePanels) {
                $panels = array($this->defaultPanel=>$panels);
                $this->isMultiPanel = false;
            }
        }

Thereā€™s a similar code around line 696

The value error_reporting: 277

Sadly
Even in the new release 7.14 this is still the same ā€œa non static method is being used staticallyā€
So this will also not work with php version greater than and equal to 8.0

Hi @heitmann @abuzarfaris

In the new release this has been changed to:

        if ($this->scanForMultiPanel) {
            require_once('include/SugarFields/Parsers/MetaParser.php');
            if ($setDefaultPanel || !$this->hasMultiplePanels($panels)) {
                $panels = array($this->defaultPanel => $panels);
                $this->isMultiPanel = false;
            }
        }

and

    public function hasMultiplePanels($panels)
    {
        if (!isset($panels) || empty($panels) || !is_array($panels)) {
            return false;
        }

        if (is_array($panels) && (count($panels) == 0 || count($panels) == 1)) {
            return false;
        }

Related with this issue and with upgrades, some of the tests weā€™ve done before the release were:

  • Upgrade from SuiteCRM 7.13 to SuiteCRM 7.14 using php 7.4
  • Upgrade from SuiteCRM 7.13 to SuiteCRM 7.14 using php 8.0
  • Upgrade from SuiteCRM 7.13 to SuiteCRM 7.14 using php 8.2

Weā€™ve just re-tested the following scenario and it is working ok:

  • Upgrade from SuiteCRM 7.13 to SuiteCRM 7.14 using php 8.0

I think there must be something else. My hints at the moment are:

  • error_reporting
  • php caching

Iā€™m having a look at our environment to see what we have

Iā€™ll try to get feedback soon

Itā€™s an issue occuring while merging views

Hi @abuzarfaris @heitmann,

I was looking into the suite 8 code before.

The Suite 7 still has:

        if ($this->scanForMultiPanel) {
            require_once('include/SugarFields/Parsers/MetaParser.php');
            if ($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) {
                $panels = array($this->defaultPanel=>$panels);
                $this->isMultiPanel = false;
            }
        }

That needs changed.

@abuzarfaris thank you for the clue. Got it, I think Iā€™ve understood what we are missing

1 Like

Thanks. I will test it tomorrow.

With the changes, the upgrade worked. Thanks for the support.

1 Like

Does SuiteCRM 7.14.0 support PHP 8.0 after upgrading from SuiteCRM 7.12.5 using upgrade wizrad ?

@mehulsbhandari

Check compatibility matrix page.

I found this same bug upgrading from 7.12 to 7.14. This thread helped me find the error but I believe the best solution is to add ā€œstaticā€ to the method declaration in ā€œMetaParser.phpā€ before doing the upgrade. Static calls will now work without disrupting dynamic calls. No other code need be changed for this.

--- a/include/SugarFields/Parsers/MetaParser.php
+++ b/include/SugarFields/Parsers/MetaParser.php
@@ -743,7 +743,7 @@ class MetaParser
         return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html);
     }
 
-    public function hasMultiplePanels($panels)
+    public static function hasMultiplePanels($panels)
     {
         if (!isset($panels) || empty($panels) || !is_array($panels)) {
             return false;

It can be made static because there is no ā€œ$thisā€ in the method. And static methods can be called dynamically (ā€œ$metaParser->hasMultiplePanelsā€) so places that do so will still work without changes.

1 Like

Check it out!