Development

#4985 ([PATCH] Fix for doubled list.batch_actions in sfModelGeneratorConfiguration->compile)

You must first sign up to be able to contribute.

Ticket #4985 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

[PATCH] Fix for doubled list.batch_actions in sfModelGeneratorConfiguration->compile

Reported by: joes Assigned to: fabien
Priority: major Milestone: 1.2.0 RC1
Component: generator Version: 1.2.0 DEV
Keywords: Cc:
Qualification: Unreviewed

Description

Any list.batch_action starting with an _ (underscore), for instance _delete, processed by sfModelGeneratorConfiguration->compile will lead to that two list actions are created. For instance, if the compile method encounters an batch_action named _delete it will create one batch action named 'batch_delete' and one named 'batchDelete' of which the second one, batchDelete, will also have faulty parameters.

The effect of this bug can be seen in the index view of modules generated with doctrine:generate-admin where one can see that the batch actions list will include two options for deletion: one which displays the label 'Delete' but won't work if you try to use it and a one with a blank label but which has the correct value for the action (i.e batchDelete) and works if you try to use it.

The below patch fixes this bug:

  • a/lib/vendors/symfony/lib/generator/sfModelGeneratorConfiguration.class.php

    old new  
    102102    $this->configuration['list']['batch_actions'] = array(); 
    103103    foreach ($this->getListBatchActions() as $action => $parameters) 
    104104    { 
    105       $this->configuration['list']['batch_actions'][$action] = $this->fixActionParameters($action, $parameters); 
    106  
    107       $action = 'batch'.ucfirst(0 === strpos($action, '_') ? substr($action, 1) : $action); 
    108  
    109       $this->configuration['list']['batch_actions'][$action] = $parameters; 
     105      $this->configuration['list']['batch_actions']['batch'.ucfirst(0 === strpos($action, '_') ? substr($action, 1) : $action)] = $this->fixActionParameters($action, $parameters); 
    110106    } 
    111107 
    112108    // list object actions 

Change History

11/18/08 14:14:26 changed by joes

  • summary changed from [PATCH] Doubled list.batch_actions in sfModelGeneratorConfiguration->compile to [PATCH] sfModelGeneratorConfiguration->compile generates doubled list.batch_actions.

11/18/08 14:15:39 changed by joes

  • summary changed from [PATCH] sfModelGeneratorConfiguration->compile generates doubled list.batch_actions to [PATCH] Fix for doubled list.batch_actions in sfModelGeneratorConfiguration->compile.

11/18/08 14:25:08 changed by joes

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

Nevermind, already fixed in [13119].

11/18/08 14:27:48 changed by joes

Although, one could argue that one line is better than three ;)

$this->configuration['list']['batch_actions']['batch'.ucfirst(0 === strpos($action, '_') ? substr($action, 1) : $action)] = $this->fixActionParameters($action, $parameters);

11/18/08 14:59:11 changed by nicolas

I prefer 3 lines, by far more readable ;)

11/18/08 16:04:10 changed by fabien

  • milestone set to 1.2.0 RC1.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.