We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    HI all,

    I have upgraded all the sites on my server to php7 - all fine apart from one.
    Certain resources are showing up totally blank - it seems to be template related, as when I choose another template, the content shows up.

    But the original template is so basic, and uses many of the same elements as the one I switched it to for testing.

    Has anyone come across issues such as this?

    In the server error logs I have this:

    Stack trace:
    #0 /home/user/public_html/site/core/components/formz/processors/mgr/tv/output/formz.class.php(15): modX->runSnippet('fmzForms', NULL)
    #1 /home/user/public_html/site/core/model/modx/modtemplatevar.class.php(1140): FormzOutputRender->process('', Array)
    #2 /home/user/public_html/site/core/model/modx/modtemplatevar.class.php(442): modTemplateVarRender->render('', Array)
    #3 /home/user/public_html/site/core/model/modx/modtemplatevar.class.php(281): modTemplateVar->getRender(Array, '', Array, 'output', 6784, 'formz')
    #4 /home/user/public_html/site/core/model/modx/modresource.class.php(834): modTemplateVar->renderOut in /home/user/public_html/site/core/model/modx/modx.class.php on line 1794
    
    


    In the Modx errors i have this:

    [2017-06-13 13:10:12] (ERROR @ /home/user/public_html/site/core/model/modx/modx.class.php : 1794) Recoverable error: Argument 2 passed to modX::runSnippet() must be of the type array, null given, called in /home/user/public_html/site/core/components/formz/processors/mgr/tv/output/formz.class.php on line 15 and defined
    
    
    


    not sure where to start to diagnose - I have switched back to php5.6 and it's fine again - but obviously php7 is MUCH faster!


    Thanks
    Andy

    This question has been answered by multiple community members. See the first response.

    [ed. note: tm2000 last edited this post 9 years, 3 months ago.]
      • 17301
      • 932 Posts
      It sounds like you likely have an incompatible snippet (relating to forms?) that is executing on the templates that result in a blank resource. Try to remove the snippet(s) to iscolate the problem until you find the faulty one and then update the code accordingly.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 17301
        • 932 Posts
        Also it might be a good idea to just omit the admin path and site url for your own security when posting here.
          ■ email: [email protected] | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • 51020
          • 670 Posts
          Quote from: lkfranklin at Jun 13, 2017, 09:31 AM
          It sounds like you likely have an incompatible snippet (relating to forms?) that is executing on the templates that result in a blank resource. Try to remove the snippet(s) to iscolate the problem until you find the faulty one and then update the code accordingly.

          yes - thanks - I just disabled the [[*forms]] TV and it's working again. Not sure why - the Forms extra is all up to date...
            • 51020
            • 670 Posts
            Quote from: lkfranklin at Jun 13, 2017, 09:32 AM
            Also it might be a good idea to just omit the admin path and site url for your own security when posting here.

            oops - I thought I had already done that - updated it now - thanks for that. Schoolboy error!
            • discuss.answer
              • 17301
              • 932 Posts
              By the looks of github the formz extra hasn't been updated in years.
                ■ email: [email protected] | ■ website: https://alienbuild.uk

                The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                • 17301
                • 932 Posts
                If you need a UI interface for your forms rather than using formit then I think Sterc/Modmore released formalicious to do exactly that.
                  ■ email: [email protected] | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                  • 51020
                  • 670 Posts
                  Quote from: lkfranklin at Jun 13, 2017, 09:54 AM
                  If you need a UI interface for your forms rather than using formit then I think Sterc/Modmore released formalicious to do exactly that.

                  OK cheers - will take a look.
                    • 3749
                    • 24,544 Posts
                    This is the problem code:
                        public function process($value,array $params = array()) {
                            $options = array();
                            foreach($params as $key => $val) {
                                if (!empty($val)) {
                                    $options[$key] = $val;
                                }
                            }
                            $mainOptions = array_merge(array('id' => $value), $options);
                    	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                        }
                    }


                    Replacing the return line with this could possibly fix it, but see better fixes below:

                    return $this->modx->runSnippet('fmzForms', (array) array_merge($mainOptions, $this->tv->_properties));


                    Probably a better fix would be to change the function to this:

                        public function process($value,array $params = array()) {
                            $options = array();
                            foreach($params as $key => $val) {
                                if (!empty($val)) {
                                    $options[$key] = $val;
                                }
                            }
                            $mainOptions = array_merge(array('id' => $value), $options);
                            $properties = $this->tv->properties;
                            $properties = $properties === null? array() : $properties;
                    	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                        }
                    }



                    Another fix (the best if it works) would be to use the original code and change:

                    $this->tv->_properties


                    to

                    $this->tv->getProperties()



                    [Update] Did some quick testing, and I think the final solution above would solve things. If there are no properties, $tv->_properties is null, but $tv->getProperties() returns an empty array, which should satisfy runSnippet().

                    BTW, I think this may not be a PHP 7 problem, but rather a change in the error level settings when you switched. The code is a problem for any version of PHP with the current version of MODX, but a different error level may have hidden that. [ed. note: BobRay last edited this post 9 years, 3 months ago.]
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                    • discuss.answer
                      • 51020
                      • 670 Posts
                      Quote from: BobRay at Jun 13, 2017, 06:05 PM
                      This is the problem code:
                          public function process($value,array $params = array()) {
                              $options = array();
                              foreach($params as $key => $val) {
                                  if (!empty($val)) {
                                      $options[$key] = $val;
                                  }
                              }
                              $mainOptions = array_merge(array('id' => $value), $options);
                      	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                          }
                      }


                      Replacing the return line with this could possibly fix it, but see better fixes below:

                      return $this->modx->runSnippet('fmzForms', (array) array_merge($mainOptions, $this->tv->_properties));


                      Probably a better fix would be to change the function to this:

                          public function process($value,array $params = array()) {
                              $options = array();
                              foreach($params as $key => $val) {
                                  if (!empty($val)) {
                                      $options[$key] = $val;
                                  }
                              }
                              $mainOptions = array_merge(array('id' => $value), $options);
                              $properties = $this->tv->properties;
                              $properties = $properties === null? array() : $properties;
                      	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                          }
                      }



                      Another fix (the best if it works) would be to use the original code and change:

                      $this->tv->_properties


                      to

                      $this->tv->getProperties()



                      [Update] Did some quick testing, and I think the final solution above would solve things. If there are no properties, $tv->_properties is null, but $tv->getProperties() returns an empty array, which should satisfy runSnippet().

                      BTW, I think this may not be a PHP 7 problem, but rather a change in the error level settings when you switched. The code is a problem for any version of PHP with the current version of MODX, but a different error level may have hidden that.

                      This is amazing - I will put this into place and see what happens. Thanks again for your input and time.

                      A