fuel / oil

Fuel PHP Framework - Fuel v1.x Oil command-line package
http://fuelphp.com/docs/packages/oil/intro.html
106 stars 67 forks source link

Problem in files generated by fromdb task #178

Closed okhayat closed 11 years ago

okhayat commented 11 years ago

When setting 'output_filter' => array('Security::htmlentities') in app/config.php and using fromdb task scaffolding, the output files are encoded. This shouldn't happen regardless of application configuration.

WanWizard commented 11 years ago

Do you have the same issue when you use regular oil scaffolding? fromdb calls the same methods to generate the code.

okhayat commented 11 years ago

Yes, I didn't notice it before. This is a problem with oil scaffolding then

WanWizard commented 11 years ago

Can you give the exact oil command that you gave, so I can try to reproduce it? If have the output filter always on, but haven't observed this issue...

okhayat commented 11 years ago

php oil r fromdb:scaffold tablename php oil g scaffold games name:string notes:text Both generated encoded files!

WanWizard commented 11 years ago

Looks fine here (1.6/develop). I've double checked, and I do have that output filter defined. This doesn't really suprise me, I would have expected a lot more complaints when this would be seriously broken.

What exactly is encoded when you use php oil g scaffold games name:string notes:text? Can you paste an example? At no point is HTML passed to a view, so I don't see what there is to escape.

okhayat commented 11 years ago

Here are the steps I've done:

  1. Download the latest files from git
  2. php composer.phar update
  3. php oil g scaffold games name:string notes:text Creating migration: /home/ossama/www/fueltest/fuel/app/migrations/001_create_games.php Creating model: /home/ossama/www/fueltest/fuel/app/classes/model/game.php Creating controller: /home/ossama/www/fueltest/fuel/app/classes/controller/games.php Creating view: /home/ossama/www/fueltest/fuel/app/views/games/index.php Creating view: /home/ossama/www/fueltest/fuel/app/views/games/view.php Creating view: /home/ossama/www/fueltest/fuel/app/views/games/create.php Creating view: /home/ossama/www/fueltest/fuel/app/views/games/edit.php Creating view: /home/ossama/www/fueltest/fuel/app/views/games/_form.php Creating view: /home/ossama/www/fueltest/fuel/app/views/template.php

files generated fine

  1. Now copy core config.php to application config and add: 'output_filter' => array('Security::htmlentities'),
  2. Regenerate scaffold: php oil g scaffold games name:string notes:text -f

BOOM: http://pastie.org/6411919

Here's my ENV info: ossama@okstation:~/www/fueltest$ php -v PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

WanWizard commented 11 years ago

ok, what I've done to try to reproduce it:

  1. cd /tmp
  2. oil create test
  3. cd test
  4. php oil g scaffold games name:string notes:text Creating migration: /tmp/test/fuel/app/migrations/001_create_games.php Creating model: /tmp/test/fuel/app/classes/model/game.php Creating controller: /tmp/test/fuel/app/classes/controller/games.php Creating view: /tmp/test/fuel/app/views/games/index.php Creating view: /tmp/test/fuel/app/views/games/view.php Creating view: /tmp/test/fuel/app/views/games/create.php Creating view: /tmp/test/fuel/app/views/games/edit.php Creating view: /tmp/test/fuel/app/views/games/_form.php Creating view: /tmp/test/fuel/app/views/template.php After this, the controller looks fine (this is on 1.5/master).

Second test:

  1. cd /tmp
  2. oil create test
  3. cd test
  4. git checkout 1.6/develop
  5. git submodule foreach git checkout 1.6/develop
  6. php composer.phar update
  7. php oil g scaffold games name:string notes:text Creating migration: /tmp/test/fuel/app/migrations/001_create_games.php Creating model: /tmp/test/fuel/app/classes/model/game.php Creating controller: /tmp/test/fuel/app/classes/controller/games.php Creating view: /tmp/test/fuel/app/views/games/index.php Creating view: /tmp/test/fuel/app/views/games/view.php Creating view: /tmp/test/fuel/app/views/games/create.php Creating view: /tmp/test/fuel/app/views/games/edit.php Creating view: /tmp/test/fuel/app/views/games/_form.php Creating view: /tmp/test/fuel/app/views/template.php After this, again the controller looks fine (now on 1.6/develop).

Both 1.5/master and 1.6/develop have the output filter defined by default, so there should not be a reason to have to set it manually.

My local environment: PHP 5.4.11 (cli) (built: Jan 16 2013 16:46:12) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

okhayat commented 11 years ago

Ok. It's fixed now.