Development

#5457 (Routing problem in admin generator (route has some missing mandatory parameters))

You must first sign up to be able to contribute.

Ticket #5457 (new defect)

Opened 6 months ago

Last modified 4 weeks ago

Routing problem in admin generator (route has some missing mandatory parameters)

Reported by: nest_d Assigned to: Kris.Wallsmith
Priority: major Milestone:
Component: routing Version: 1.2.7
Keywords: Cc:
Qualification: Unreviewed

Description

I created a rounting:

administratorAdmin:
  class: sfPropelRouteCollection
  options:
    model:                Admin
    module:               administratorAdmin
    prefix_path:          administratorAdmin
    column:               id
    with_wildcard_routes: true

And defined generator.yml

generator:
  class: sfPropelGenerator
  param:
    model_class:           Admin
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          administratorAdmin
    with_propel_route:     1

    config:
      actions: ~
      fields:  ~
      list:
        title: Administrators
        display: [full_name, credential, email, created_at, updated_at, is_active]
        max_per_page: 20
        object_actions: 
          _edit:          ~
          _delete:        ~
          reset_password: 
            name:         Reset password
            action:       resetPassword
            icon:         /admin/images/actions/reset_password.png
            params:       confirm=Are you sure want reset password for this administrator?
        fields:
          created_at:
            date_format: dd/mm/yyyy
          updated_at:
            date_format: dd/mm/yyyy
      filter:
        class: false
      form:    ~
      edit:
        title: Edit administrator "%%email%%"
      new:
        title: New administrator

If try to get access to page modul administratorAdmin in prod enviroment, the exception will appear

The "/administratorAdmin/:id/edit.:sf_format" route has some missing mandatory parameters (:id).

But it is ok, if try to get access in dev enviroment.

Change History

12/24/08 13:59:23 changed by nest_d

  • priority changed from minor to major.

01/06/09 15:06:55 changed by pookey

also effects doctrine's route collection - so isn't propel specific.

01/07/09 03:59:07 changed by davidlin

it IS also propel specific ! rules are generated by Admin generator, and only affect the prod env.




The "/client_login/:id/edit.:sf_format" route has some missing mandatory parameters (:id).
stack trace

    * at ()
      in SF_ROOT_DIR/lib/vendor/symfony/lib/routing/sfRoute.class.php line 216 ...
             213.     // all params must be given
             214.     if ($diff = array_diff_key($this->variables, $tparams))
             215.     {
             216.       throw new InvalidArgumentException(sprintf('The "%s" route has some missing mandatory parameters (%s).', $this->pattern, implode(', ', $diff)));
             217.     }
             218.
             219.     if ($this->options['generate_shortest_url'] || $this->customToken)

If change the condition test (to walk around the exception) from

if ($diff = array_diff_key($this->variables, $tparams)) 

to

if (flase)

The page shows properly but you can not do update any more because the form's action url has been added one '/' slash at the end

01/09/09 09:13:22 changed by Amlu

  • milestone set to 1.2.3.

01/17/09 16:10:35 changed by erangaj

This issue is in sfPropelRoute->doConvertObjectToArray().

As a workaround I added the following method to /lib/symfony/plugins/sfPropelPlugin/lib/vendor/propel/om/BaseObject.

public function toParams() {

return array('id' => $this->getId());

}

01/23/09 15:25:35 changed by pookey

the issue can also be fixed this was in doctrine:

# svn diff ../classes/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php 
Index: ../classes/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php
===================================================================
--- ../classes/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php	(revision 14930)
+++ ../classes/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php	(working copy)
@@ -41,6 +41,11 @@
     }
   }
 
+  public function toParams()
+  {
+    return $this->identifier();
+  }
+
   /**
    * Initialize I18n culture from symfony sfUser instance
    * Add event listener to change default culture whenever the user changes culture
@@ -190,4 +195,4 @@
       return parent::__call($method, $arguments);
     }
   }
-}
\ No newline at end of file
+}

for doctrine, this change was made in r13270 - not sure why.

01/27/09 16:12:37 changed by Joaquin.Bravo

  • version changed from 1.2.1 to 1.2.2.

I see this error too, but only when I change my web/index.php file to enable debugging (3rd parameter of ProjectConfiguration::getApplicationConfiguration()). Otherwise everything works just fine. If I change the parameter and enable debuggin I get the same error.

01/31/09 22:34:15 changed by FabianLange

  • milestone deleted.

02/10/09 13:54:36 changed by floplus

  • version changed from 1.2.2 to 1.2.4.

I have the same/similar error on 1.2.4. using the sfGuardPlugin I get the error when editing a user:

/sf_guard_user/1/edit.html

I found another 'solution':

when I enable the cache in the prod environment

prod:
  .settings:
    no_script_name:         on
    logging_enabled:        off
    cache:                  on

it works. In the dev environment it works regardless of the cache setting.

03/24/09 11:27:08 changed by David.Stendardi

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

hi, Just installed a small admin generator app, and i encountered the problem described here. After applying settings described by flopus and patch by pookey, it was fixed. Hope this will be fixed soon in the repository !

cheers.

03/24/09 11:28:01 changed by David.Stendardi

  • status changed from closed to reopened.
  • resolution deleted.

accidentally mark it as resolved ...

04/16/09 12:25:51 changed by syam

  • version changed from 1.2.4 to 1.2.5.
  • milestone set to 1.2.6.

Have the same issue in 1.2.5 in prod mode, just back to dev mode in the web/backend.php and it work perfectly.

04/16/09 13:32:14 changed by FabianLange

  • owner changed from fabien to Kris.Wallsmith.
  • status changed from reopened to new.
  • milestone deleted.

Kris, was this covered by your routing change in 1.2.6?

05/29/09 17:35:48 changed by gray

  • version changed from 1.2.5 to 1.2.7.

same issue in 1.2.7

06/08/09 00:24:46 changed by kamil.biela

I had this problem when using custom form class and overwriting save method in form and NOT returning value of parent save.

example:

// this is bad 
public function save($con = null)
{
  //stuff here
  parent::save($con)
}
// this works

public function save($con = null)
{
  //stuff here
  return parent::save($con)
}

06/08/09 14:06:42 changed by Marc.Carlucci

You should try this changeset:18835

Worked for us.

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.