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 7 Compatibility #98

Closed
stackcoder opened this issue Aug 11, 2016 · 4 comments
Closed

PHP 7 Compatibility #98

stackcoder opened this issue Aug 11, 2016 · 4 comments

Comments

@stackcoder
Copy link

FormIt isn't PHP 7 ready. I'm not sure exactly which functionality is broken if you execute this extra in a PHP 7 environment, but if you depend on it you should not update right now.

Result of php7cc v1.1.0

File: /core/components/formit/model/recaptcha/formitrecaptcha.class.php
> Line 46: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;


File: /core/components/formit/model/formit/fihooks.class.php
> Line 86: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;
> Line 430: Possible adding to array on the last iteration of a by-reference foreach loop
    $fields[$vKey] = $vValue;


File: /core/components/formit/model/formit/module/fimodule.class.php
> Line 42: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;


File: /core/components/formit/model/formit/fidictionary.class.php
> Line 54: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;


File: /core/components/formit/model/formit/fivalidator.class.php
> Line 66: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;
> Line 421: Removed function "ereg" called
    ereg($pattern, $value);
> Line 433: Removed function "ereg" called
    ereg($pattern, $local_array[$i]);
> Line 443: Removed function "ereg" called
    ereg($pattern, $email_array[1]);
> Line 454: Removed function "ereg" called
    ereg($pattern, $domain_array[$i]);


File: /core/components/formit/model/formit/firequest.class.php
> Line 68: Possible object property creation during by-reference assignment
    $this->modx =& $formit->modx;


File: /core/components/formit/elements/snippets/snippet.formitautoresponder.php
> Line 57: Possible adding to array on the last iteration of a by-reference foreach loop
    $fields[$k] = $v['name'];
> Line 63: Possible adding to array on the last iteration of a by-reference foreach loop
    $fields[$vKey] = $vValue;
> Line 70: Possible adding to array on the last iteration of a by-reference foreach loop
    $fields[$k] = $newValue;

Further I did some code search and noticed:

File: /core/components/formit/elements/snippets/snippet.formitsaveform.ph

Line 83: list() no longer assigns variables in reverse order

@@ -80,8 +80,8 @@ if($fieldNames){
     $fieldLabels = array();
     $formFieldNames = explode(',', $fieldNames);
     foreach($formFieldNames as $formFieldName){
-        list($name, $label) = explode('==', $formFieldName);
-        $fieldLabels[trim($name)] = trim($label);
+        $parts = explode('==', $formFieldName);
+        $fieldLabels[trim($parts[0])] = trim($parts[1]);
     }
     foreach ($dataArray as $key => $value) {
         if($fieldLabels[$key]){

File: /core/components/formit/model/formit/module/fistateoptions.class.php

Line 78: Changes to the handling of indirect variables, properties, and methods

foreach ($this->states as $stateKey => $stateName) {
    $stateArray = array(
        'text' => $stateName,
        'value' => $$selectedKey,
        'selected' => '',
    );
    if ($selected == $$selectedKey) {
        $stateArray['selected'] = $selectedAttribute;
    }
    $this->list[] = $this->formit->getChunk($tpl,$stateArray);
}

List of Backward incompatible changes: https://secure.php.net/manual/de/migration70.incompatible.php

@hugopeek
Copy link

@joeke I see this issue just celebrated its 1st birthday. Has this been investigated already, together with #92? Seems like a pretty serious flaw if FormIt is not fully compatible with PHP 7, as more and more people will be making that switch now..

@joeke
Copy link

joeke commented Aug 30, 2017

@hugopeek I'm afraid this issue lost our attention a bit. I did apply the fix for formitsaveform by removing the list() function (thanks for that @stackcoder). I'm looking into the other compatibility issues now.

@joeke
Copy link

joeke commented Sep 4, 2017

@stackcoder @hugopeek All the PHP7 compatibility issues should be resolved now (See 4c72875, d063635 and a4fbd70).
All fixes will be included in the upcoming 3.0.3 release.

@joeke joeke closed this as completed Sep 4, 2017
@hugopeek
Copy link

hugopeek commented Sep 6, 2017

Excellent work @joeke! It's these little invisible fixes that keep things running safely and smoothly for everyone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants