#4522 (generateFile = true - dangerous implementation)

You must first sign up to be able to contribute.

Ticket #4522 (closed defect: invalid)

Opened 8 years ago

Last modified 8 years ago

generateFile = true - dangerous implementation

Reported by: rande Assigned to: Jonathan.Wage
Priority: major Milestone:
Component: sfDoctrinePlugin Version:
Keywords: Cc:
Qualification: Unreviewed


Let's use this schema as an example

  tableName: sw_cms_pages
    route: string(255)
    title: string(255)
    format: string(10)
    content: clob
    script: clob
    css: clob
      tableName: sw_cms_page_translations
      fields: [content, title, slug]
      generateFiles: true
      generatePath: <?php echo sfConfig::get('sf_lib_dir') ?>/model/doctrine/translations
         field: [title]
         builder: [ swTranslationPage, buildUrl ]
      hasManyRoots: true

The result of ./symfony doctrine:build-model is 2 files : swPage and swPageTable.

When fetching the first page:

    $sw_page = Doctrine_Query::Create()
      ->where('swPageTranslation.lang = ? and swPageTranslation.slug = ?', array($culture, $slug))

Doctrine generated 2 files : swPageTranslation and BaseswPageTranslation?. The last file is overwritten at every request when the model is loaded. Of course just after, symfony bugs as the sfAutoloader does not known where BaseswPageTranslation? is ... a 'symfony cc' fix this problem.

Anothers problems :

  • the generatePath is hardcoded (maybe my example is wrong, but how can I do differently ?)
  • the generated files have webserver permission.

So I think the implementation is wrong :

  • the symfony task (or doctrine sub task) should create all files (with translation when generateFiles is set to true)
  • the webserver should not recreated files at every request !
  • the generatedPath should be optional at the symfony layer and not hardcoded into the model (which breaks deployment)

Change History

10/01/08 14:05:10 changed by rande

  • owner changed from jwage to Jonathan.Wage.

10/03/08 09:20:38 changed by rande

There is another issue while working with generated file in this case. The Translation key are not the 'lang' field but an integer. To fix that I have to add this piece of code :

class swPageTranslation extends BaseswPageTranslation
  public function construct()
    $this->bindQueryParts(array('indexBy' => 'lang'));

Note : the setup method is not called.

11/06/08 21:21:38 changed by Jonathan.Wage

This belongs in the Doctrine trac.

11/06/08 21:21:47 changed by Jonathan.Wage

  • status changed from new to closed.
  • resolution set to invalid.