mervick / yii2-mthaml

The MtHaml integration for the Yii2 framework.
MIT License
8 stars 1 forks source link

PHP 7.1: HAML fails on Heroku: Error: Cannot re-assign $this #8

Open starrychloe opened 7 years ago

starrychloe commented 7 years ago

It works locally. Here is error from Heroku:

2017-01-12T20:28:14.292734+00:00 app[web.1]: 2017-01-12 20:28:14 [10.164.78.133][-][-][error][Error] Error: Cannot re-assign $this in /app/runtime/Haml/cache/cc/43/3995979b4da50126888f0a9ef174a5b817ada40a0ace2fb66becc8bfa541__newsletter.haml.php:5
2017-01-12T20:28:14.292756+00:00 app[web.1]: Stack trace:
2017-01-12T20:28:14.292868+00:00 app[web.1]: #0 /app/runtime/Haml/cache/cc/43/3995979b4da50126888f0a9ef174a5b817ada40a0ace2fb66becc8bfa541__newsletter.haml.php(5): extract(Array)
2017-01-12T20:28:14.293025+00:00 app[web.1]: #1 /app/vendor/mervick/yii2-mthaml/src/override/Executor.php(38): __MtHamlTemplate_cc433995979b4da50126888f0a9ef174a5b817ada40a0ace2fb66becc8bfa541(Array)
2017-01-12T20:28:14.293169+00:00 app[web.1]: #2 /app/vendor/mervick/yii2-mthaml/src/override/Executor.php(50): mervick\mthaml\override\Executor->display('/app/views/site...', Array)
2017-01-12T20:28:14.293544+00:00 app[web.1]: #3 /app/vendor/mervick/yii2-mthaml/src/AbstractMtHamlViewRenderer.php(507): mervick\mthaml\override\Executor->render('/app/views/site...', Array)
2017-01-12T20:28:14.293633+00:00 app[web.1]: #4 /app/vendor/yiisoft/yii2/base/View.php(246): mervick\mthaml\AbstractMtHamlViewRenderer->render(Object(yii\web\View), '/app/views/site...', Array)
2017-01-12T20:28:14.293691+00:00 app[web.1]: #5 /app/vendor/yiisoft/yii2/base/View.php(150): yii\base\View->renderFile('/app/views/site...', Array, NULL)
2017-01-12T20:28:14.293736+00:00 app[web.1]: #6 /app/views/site/index.php(44): yii\base\View->render('_newsletter.ham...', Array)
2017-01-12T20:28:14.293794+00:00 app[web.1]: #7 /app/vendor/yiisoft/yii2/base/View.php(326): require('/app/views/site...')

Here is _newsletter.haml. No mention of $this.

-use \yii\bootstrap\ActiveForm
.sub-scrip
  .container
    -$form = ActiveForm::begin(['id' => 'subscriber-form', 'action' => ['subscriber/subscribe'], 'options' => ['class' => 'form-inline']])
    .row
      .col-md-5
        %h1#newsletter Subscribe to Our Newsletter
        %p Subscribe and be the first to receive notice for special deals and savings!
      .col-md-7
        -echo $form->field($subscriber, 'name')->textInput(['placeholder'=>'Name'])
        -echo $form->field($subscriber, 'email')->input('email', ['placeholder'=>'Email'])
        -#echo $form->field($subscriber, 'phone')->input('tel', ['placeholder'=>'Phone'])
        .form-group
          %button.btn.btn-primary{type: 'submit', style:'margin-bottom:10px;'} Subscribe!
    -ActiveForm::end() 

Here are the versions used on Heroku:

remote:          - Installing yiisoft/yii2 (2.0.10)
remote:            Downloading: 100%
remote:
remote:          - Installing mthaml/mthaml (1.8.0)
remote:            Downloading: 100%
remote:
remote:          - Installing mervick/yii2-mthaml (0.1.3)
remote:            Downloading: 100%

Here are the versions used locally (Yii 2.0.10)

$ grep mthaml composer*
composer.json:        "mervick/yii2-mthaml": "*",
composer.lock:            "name": "mervick/yii2-mthaml",
composer.lock:                "url": "https://github.com/mervick/yii2-mthaml.git",
composer.lock:                "url": "https://api.github.com/repos/mervick/yii2-mthaml/zipball/1abf80b6d92841840a99c9046a67e6494eb8a3db",
composer.lock:                "mthaml/mthaml": "~1.7",
composer.lock:                    "mervick\\mthaml\\": "src/"
composer.lock:                "mthaml",
composer.lock:            "name": "mthaml/mthaml",
composer.lock:                "mthaml/mthaml-bundle": "<1.1.0"

Here is a compiled _newsletter.haml from my local machine. It's impossible to get the compiled file from Heroku because it uses ephemeral file systems. No way to access.

$ cat runtime/Haml/cache/42/3d/91bd8b041c10692b0203de214a1022f5d137a59f139b43c8548dee680fa6__newsletter.haml.php
<?php
use \yii\bootstrap\ActiveForm;
function __MtHamlTemplate_423d91bd8b041c10692b0203de214a1022f5d137a59f139b43c8548dee680fa6($__variables)
{
    extract($__variables);
?><div class="sub-scrip">
  <div class="container">
    <?php $form = ActiveForm::begin(['id' => 'subscriber-form', 'action' => ['subscriber/subscribe'], 'options' => ['class' => 'form-inline']]); ?>
    <div class="row">
      <div class="col-md-5">
        <h1 id="newsletter">Subscribe to Our Newsletter</h1>
        <p>Subscribe and be the first to receive notice for special deals and savings!</p>
      </div>
      <div class="col-md-7">
        <?php echo $form->field($subscriber, 'name')->textInput(['placeholder'=>'Name']); ?>
        <?php echo $form->field($subscriber, 'email')->input('email', ['placeholder'=>'Email']); ?>
        <div class="form-group">
          <button <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-primary')), array('type', ('submit')), array('style', ('margin-bottom:10px;'))), 'html5', 'UTF-8'); ?>>Subscribe!</button>
        </div>
      </div>
    </div>
    <?php ActiveForm::end() ; ?>
  </div>
</div>
<?php
}

PHP 7.0.14 locally, php (7.1.0) on Heroku

Not sure this is enough info.

starrychloe commented 7 years ago

It WAS because of the PHP version! I locked it to 7.0 and it fixed it.

    "require": {
        "php": "~7.0.0",`