нужна помощь по ошибке Неизвестная запись свойства / связанный компонент "разрешения" на "sfGuardUser" - PullRequest
2 голосов
/ 13 марта 2012

Я занимаюсь разработкой проекта с использованием symfony1.4.16 и Doctrine, а для аутентификации я использую sfDoctrineGuardPlugin.На моем местном хосте все работало нормально.когда я перенес свой проект на общий хост, я получаю эту ошибку (Unknown record property / related component "permissions" on "sfGuardUser") при входе в систему.когда я ищу эту ошибку в Google, многие люди рекомендуют delete all SFGuard Forms from lib/form/doctrine/base and reinstalling the plugin. Как мне переустановить ее на общем хосте?Какую процедуру я должен предпринять для удаления его на моем общем хосте?нужно ли мне переустанавливать его на моем локальном хосте и загружать его на свой сервер, или для того, чтобы использовать команду symfony plugin:uninstall sfDoctrineGuardPlugin или просто удалить файлы в lib/form/doctrine/base и загрузить его снова на мой сервер. Другие модули, не связанные сsfDoctrineGuardPlugin работает нормально. Любой, пожалуйста, помогите мне ...

Дополнительная информация

при входе в систему я получаю сообщение об ошибке Unknown record property / related component "permissions" on "sfGuardUser" и когда я обновляю страницуошибка исчезла, и я перенаправил на домашнюю страницу.На домашней странице у меня есть ссылки для

  1. добавить пользователя, группу, разрешение
  2. редактировать пользователя, группу, разрешение
  3. перечислить пользователя, группу, разрешение прия пытаюсь получить доступ к добавлению или редактированию части, я получаю ошибку, как это.Список и удалить часть работает нормально

    здесь я прилагаю скриншоты ошибок и журнала ошибок.

    1. страница ошибок 2. журнал ошибок

**

BaseSfGuardUser.class

**

<?php
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('SfGuardUser', 'doctrine');

/**
 * BaseSfGuardUser
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @property integer $id
 * @property string $first_name
 * @property string $last_name
 * @property string $email_address
 * @property string $username
 * @property string $algorithm
 * @property string $salt
 * @property string $password
 * @property integer $is_active
 * @property integer $is_super_admin
 * @property timestamp $last_login
 * @property timestamp $created_at
 * @property timestamp $updated_at
 * @property Doctrine_Collection $SfGuardForgotPassword
 * @property Doctrine_Collection $SfGuardRememberKey
 * @property Doctrine_Collection $SfGuardUserGroup
 * @property Doctrine_Collection $SfGuardUserPermission
 * 
 * @method integer             getId()                    Returns the current record's "id" value
 * @method string              getFirstName()             Returns the current record's "first_name" value
 * @method string              getLastName()              Returns the current record's "last_name" value
 * @method string              getEmailAddress()          Returns the current record's "email_address" value
 * @method string              getUsername()              Returns the current record's "username" value
 * @method string              getAlgorithm()             Returns the current record's "algorithm" value
 * @method string              getSalt()                  Returns the current record's "salt" value
 * @method string              getPassword()              Returns the current record's "password" value
 * @method integer             getIsActive()              Returns the current record's "is_active" value
 * @method integer             getIsSuperAdmin()          Returns the current record's "is_super_admin" value
 * @method timestamp           getLastLogin()             Returns the current record's "last_login" value
 * @method timestamp           getCreatedAt()             Returns the current record's "created_at" value
 * @method timestamp           getUpdatedAt()             Returns the current record's "updated_at" value
 * @method Doctrine_Collection getSfGuardForgotPassword() Returns the current record's "SfGuardForgotPassword" collection
 * @method Doctrine_Collection getSfGuardRememberKey()    Returns the current record's "SfGuardRememberKey" collection
 * @method Doctrine_Collection getSfGuardUserGroup()      Returns the current record's "SfGuardUserGroup" collection
 * @method Doctrine_Collection getSfGuardUserPermission() Returns the current record's "SfGuardUserPermission" collection
 * @method SfGuardUser         setId()                    Sets the current record's "id" value
 * @method SfGuardUser         setFirstName()             Sets the current record's "first_name" value
 * @method SfGuardUser         setLastName()              Sets the current record's "last_name" value
 * @method SfGuardUser         setEmailAddress()          Sets the current record's "email_address" value
 * @method SfGuardUser         setUsername()              Sets the current record's "username" value
 * @method SfGuardUser         setAlgorithm()             Sets the current record's "algorithm" value
 * @method SfGuardUser         setSalt()                  Sets the current record's "salt" value
 * @method SfGuardUser         setPassword()              Sets the current record's "password" value
 * @method SfGuardUser         setIsActive()              Sets the current record's "is_active" value
 * @method SfGuardUser         setIsSuperAdmin()          Sets the current record's "is_super_admin" value
 * @method SfGuardUser         setLastLogin()             Sets the current record's "last_login" value
 * @method SfGuardUser         setCreatedAt()             Sets the current record's "created_at" value
 * @method SfGuardUser         setUpdatedAt()             Sets the current record's "updated_at" value
 * @method SfGuardUser         setSfGuardForgotPassword() Sets the current record's "SfGuardForgotPassword" collection
 * @method SfGuardUser         setSfGuardRememberKey()    Sets the current record's "SfGuardRememberKey" collection
 * @method SfGuardUser         setSfGuardUserGroup()      Sets the current record's "SfGuardUserGroup" collection
 * @method SfGuardUser         setSfGuardUserPermission() Sets the current record's "SfGuardUserPermission" collection
 * 
 * @package    ticketsystem
 * @subpackage model
 * @author     Your name here
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
abstract class BaseSfGuardUser extends sfDoctrineRecord
{
    public function setTableDefinition()
    {
        $this->setTableName('sf_guard_user');
        $this->hasColumn('id', 'integer', 8, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => true,
             'autoincrement' => true,
             'length' => 8,
             ));
        $this->hasColumn('first_name', 'string', 255, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => 255,
             ));
        $this->hasColumn('last_name', 'string', 255, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => 255,
             ));
        $this->hasColumn('email_address', 'string', 255, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             'length' => 255,
             ));
        $this->hasColumn('username', 'string', 128, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             'length' => 128,
             ));
        $this->hasColumn('algorithm', 'string', 128, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'default' => 'sha1',
             'notnull' => true,
             'autoincrement' => false,
             'length' => 128,
             ));
        $this->hasColumn('salt', 'string', 128, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => 128,
             ));
        $this->hasColumn('password', 'string', 128, array(
             'type' => 'string',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => 128,
             ));
        $this->hasColumn('is_active', 'integer', 1, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'default' => '1',
             'notnull' => false,
             'autoincrement' => false,
             'length' => 1,
             ));
        $this->hasColumn('is_super_admin', 'integer', 1, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'default' => '0',
             'notnull' => false,
             'autoincrement' => false,
             'length' => 1,
             ));
        $this->hasColumn('last_login', 'timestamp', 25, array(
             'type' => 'timestamp',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => 25,
             ));
        $this->hasColumn('created_at', 'timestamp', 25, array(
             'type' => 'timestamp',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             'length' => 25,
             ));
        $this->hasColumn('updated_at', 'timestamp', 25, array(
             'type' => 'timestamp',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             'length' => 25,
             ));
    }

    public function setUp()
    {
        parent::setUp();
        $this->hasMany('SfGuardForgotPassword', array(
             'local' => 'id',
             'foreign' => 'user_id',
             'onDelete' => 'CASCADE'));

        $this->hasMany('SfGuardRememberKey', array(
             'local' => 'id',
             'foreign' => 'user_id',
             'onDelete' => 'CASCADE'));

        $this->hasMany('SfGuardUserGroup', array(
             'local' => 'id',
             'foreign' => 'user_id',
             'onDelete' => 'CASCADE'));

        $this->hasMany('SfGuardUserPermission', array(
             'local' => 'id',
             'foreign' => 'user_id',
             'onDelete' => 'CASCADE'));
    }
}

**

BaseSfGuardUserForm.class

**

<?php

/**
 * SfGuardUser form base class.
 *
 * @method SfGuardUser getObject() Returns the current form's model object
 *
 * @package    ticketsystem
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseSfGuardUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'first_name'       => new sfWidgetFormInputText(),
      'last_name'        => new sfWidgetFormInputText(),
      'email_address'    => new sfWidgetFormInputText(),
      'username'         => new sfWidgetFormInputText(),
      'algorithm'        => new sfWidgetFormInputText(),
      'salt'             => new sfWidgetFormInputText(),
      'password'         => new sfWidgetFormInputText(),
      'is_active'        => new sfWidgetFormInputCheckbox(),
      'is_super_admin'   => new sfWidgetFormInputCheckbox(),
      'last_login'       => new sfWidgetFormDateTime(),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
      'groups_list'      => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup')),
      'permissions_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardPermission')),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'first_name'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'last_name'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email_address'    => new sfValidatorString(array('max_length' => 255)),
      'username'         => new sfValidatorString(array('max_length' => 128)),
      'algorithm'        => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'salt'             => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'password'         => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'is_active'        => new sfValidatorBoolean(array('required' => false)),
      'is_super_admin'   => new sfValidatorBoolean(array('required' => false)),
      'last_login'       => new sfValidatorDateTime(array('required' => false)),
      'created_at'       => new sfValidatorDateTime(),
      'updated_at'       => new sfValidatorDateTime(),
      'groups_list'      => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup', 'required' => false)),
      'permissions_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardPermission', 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'SfGuardUser', 'column' => array('email_address'))),
        new sfValidatorDoctrineUnique(array('model' => 'SfGuardUser', 'column' => array('username'))),
      ))
    );

    $this->widgetSchema->setNameFormat('sf_guard_user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'SfGuardUser';
  }

  public function updateDefaultsFromObject()
  {
    parent::updateDefaultsFromObject();

    if (isset($this->widgetSchema['groups_list']))
    {
      $this->setDefault('groups_list', $this->object->Groups->getPrimaryKeys());
    }

    if (isset($this->widgetSchema['permissions_list']))
    {
      $this->setDefault('permissions_list', $this->object->Permissions->getPrimaryKeys());
    }

  }

  protected function doSave($con = null)
  {
    $this->saveGroupsList($con);
    $this->savePermissionsList($con);

    parent::doSave($con);
  }

  public function saveGroupsList($con = null)
  {
    if (!$this->isValid())
    {
      throw $this->getErrorSchema();
    }

    if (!isset($this->widgetSchema['groups_list']))
    {
      // somebody has unset this widget
      return;
    }

    if (null === $con)
    {
      $con = $this->getConnection();
    }

    $existing = $this->object->Groups->getPrimaryKeys();
    $values = $this->getValue('groups_list');
    if (!is_array($values))
    {
      $values = array();
    }

    $unlink = array_diff($existing, $values);
    if (count($unlink))
    {
      $this->object->unlink('Groups', array_values($unlink));
    }

    $link = array_diff($values, $existing);
    if (count($link))
    {
      $this->object->link('Groups', array_values($link));
    }
  }

  public function savePermissionsList($con = null)
  {
    if (!$this->isValid())
    {
      throw $this->getErrorSchema();
    }

    if (!isset($this->widgetSchema['permissions_list']))
    {
      // somebody has unset this widget
      return;
    }

    if (null === $con)
    {
      $con = $this->getConnection();
    }

    $existing = $this->object->Permissions->getPrimaryKeys();
    $values = $this->getValue('permissions_list');
    if (!is_array($values))
    {
      $values = array();
    }

    $unlink = array_diff($existing, $values);
    if (count($unlink))
    {
      $this->object->unlink('Permissions', array_values($unlink));
    }

    $link = array_diff($values, $existing);
    if (count($link))
    {
      $this->object->link('Permissions', array_values($link));
    }
  }

}

здесь я тоже присоединяю свою схему базы данных

**

schema.yml

**

SfGuardForgotPassword:
  connection: doctrine
  tableName: sf_guard_forgot_password
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    unique_key:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    expires_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
SfGuardGroup:
  connection: doctrine
  tableName: sf_guard_group
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    description:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardGroupPermission:
      local: id
      foreign: group_id
      type: many
    SfGuardUserGroup:
      local: id
      foreign: group_id
      type: many
SfGuardGroupPermission:
  connection: doctrine
  tableName: sf_guard_group_permission
  columns:
    group_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    permission_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardGroup:
      local: group_id
      foreign: id
      type: one
    SfGuardPermission:
      local: permission_id
      foreign: id
      type: one
SfGuardPermission:
  connection: doctrine
  tableName: sf_guard_permission
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    description:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardGroupPermission:
      local: id
      foreign: permission_id
      type: many
    SfGuardUserPermission:
      local: id
      foreign: permission_id
      type: many
SfGuardRememberKey:
  connection: doctrine
  tableName: sf_guard_remember_key
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    remember_key:
      type: string(32)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    ip_address:
      type: string(50)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false

      notnull: true
      autoincrement: false
  relations:
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
SfGuardUser:
  connection: doctrine
  tableName: sf_guard_user
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    first_name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    last_name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    email_address:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    username:
      type: string(128)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    algorithm:
      type: string(128)
      fixed: false
      unsigned: false
      primary: false
      default: sha1
      notnull: true
      autoincrement: false
    salt:
      type: string(128)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    password:
      type: string(128)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    is_active:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      default: '1'
      notnull: false
      autoincrement: false
    is_super_admin:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      default: '0'
      notnull: false
      autoincrement: false
    last_login:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardForgotPassword:
      local: id
      foreign: user_id
      type: many
    SfGuardRememberKey:
      local: id
      foreign: user_id
      type: many
    SfGuardUserGroup:
      local: id
      foreign: user_id
      type: many
    SfGuardUserPermission:
      local: id
      foreign: user_id
      type: many
SfGuardUserGroup:
  connection: doctrine
  tableName: sf_guard_user_group
  columns:
    user_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    group_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardGroup:
      local: group_id
      foreign: id
      type: one
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
SfGuardUserPermission:
  connection: doctrine
  tableName: sf_guard_user_permission
  columns:
    user_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    permission_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SfGuardPermission:
      local: permission_id
      foreign: id
      type: one
    SfGuardUser:
      local: user_id
      foreign: id
      type: one

Спасибо

Ответы [ 2 ]

4 голосов
/ 14 марта 2012
  1. очистить кэш Symfony
  2. удалить базовые модели sfDoctrineGuardPlugin:

lib/model/doctrine/sfDoctrineGuardPLugin/base/

  1. перестройте ваши модели с помощью командной строки:

$ php symfony doctrine:build-model

  1. восстановить вашу БД с помощью командной строки

$ php symfony doctrine:build-sql<br> $ php symfony doctrine:insert-sql

0 голосов
/ 01 апреля 2017

Во время перенастройки сервера я обнаружил ту же ошибку по другой причине. На новом сервере работал PHP 7.0, но я получил его, опустив до PHP 5.6 (следуя инструкциям здесь ).

...