Ticket #672 (closed defect: fixed)

Opened 19 months ago

Last modified 16 months ago

I18n update problem

Reported by: ysarazin Owned by: jwage
Priority: major Milestone: 0.10.3
Component: Other Version: 0.10.0
Severity: Keywords: I18n
Cc: Has Test:
Status: Has Patch:

Description

I'm trying to update an I18n field, based on the Documentation examples :

Schema :

NewsItem: 
  tableName: news_item
  actAs: 
    I18n:
      fields: [title]
  columns: 
    id: 
      notnull: true
      primary: true
      autoincrement: true
      type: integer(11)
    title:
      type: string(200)
    content:
      type: string

Class:

abstract class BaseNewsItem extends sfDoctrineRecord
{

  public function setTableDefinition()
  {
    $this->setTableName('news_item');
    $this->hasColumn('id', 'integer', 11, array (
  'primary' => true,
  'autoincrement' => true,
  'notnull' => true,
));

    $this->hasColumn('title', 'string', 200, array (
));
    $this->hasColumn('content', 'string', null, array (
));

  }
  
  public function setUp()
  {
    $this->actAs('I18n', array (
  'fields' => 
  array (
    0 => 'title',
  ),
));
  }
}

(I've moved $this->actAs into the setUp() method)

and I've tried to run the following code :

    $item = Doctrine_Query::create()->query('FROM NewsItem')->getFirst();    
    $item->Translation['EN']->title = 'New title';
    $item->Translation->save();

And I get the following error :

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
Doctrine_Connection->exec('UPDATE news_item_translation SET title = ? WHERE id = ? AND lang = ?', array('New title'))

The arguments "id" and "lang" are not passed to the query

Change History

  Changed 18 months ago by zYne

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

(In [3452]) added tests for updating I18n records, fixes #672

  Changed 18 months ago by nasam

  • status changed from closed to reopened
  • resolution fixed deleted

It seems that this problem is not fixed.

I get errors while trying with the latest 0.10 from SVN (rev 3560)

The error with 0.10

nathan@gamma:~/Web/coorg$ php5 doctrine_i18n_bug.php 
Some News Article
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection.php:979
Stack trace:
#0 /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection/Statement.php(244): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Statement))
#1 /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection.php(943): Doctrine_Connection_Statement->execute(Array)
#2 /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection.php(560): Doctrine_Con
nection->exec('UPDATE news_ite...', Array)
#3 /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection/UnitOfWork.php(569): Doctrine_Connection->update(Object(Doctrine_Table), Array, Array)
#4 /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection/UnitOfWork.php(172): Doctrine_Connection_UnitOfWork->update(Object(NewsItemTranslat in /home/nathan/Web/coorg/libraries/doctrine_0.10/Doctrine/Connection.php on line 979
nathan@gamma:~/Web/coorg$ 

Code used

<?php

require_once('libraries/doctrine_trunk/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));

class NewsItem extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('title', 'string', 200);
        $this->hasColumn('content', 'string');
    }

    public function setUp()
    {
        $this->actAs('I18n', array('fields' => array('title')));
    }
}

$conn = Doctrine_Manager::connection('mysql://coorg:PASSWORD@localhost:/coorg_i18n_test');

$conn->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);

$conn->export->exportClasses(array('NewsItem'));

$news = new NewsItem();
$news->Translation['en']->title = 'Some News Article';
$news->Translation['nl']->title = 'Mijn Nederlandse vertaling';
$news->content = 'My News Message';
$news->save();

$news = $conn->getTable('NewsItem')->find(1);
echo $news->Translation['en']->title; // Correct
$news->Translation['en']->title = 'Some news article'; // Change the case
$news->Translation->save(); // Error


?>

I tried also trunk, but that seems to have other major problems

  Changed 18 months ago by jwage

  • status changed from reopened to closed
  • resolution set to wontfix

This is fixed in trunk but other issues exist because of refactorings currently. I am not sure if this will be fixed in 0.9 or 0.10

  Changed 18 months ago by jwage

  • status changed from closed to reopened
  • resolution wontfix deleted
  • milestone changed from beta3 to 1.0

follow-ups: ↓ 6 ↓ 7   Changed 17 months ago by pookey

please retest on 0.9. I think I might have fixed it.. maybe ;)

in reply to: ↑ 5   Changed 17 months ago by nasam

Indeed, in the 0.9 branch it works, thanks. Any chance of having it updated too for the 0.10 branch?

Replying to pookey:

please retest on 0.9. I think I might have fixed it.. maybe ;)

in reply to: ↑ 5   Changed 17 months ago by nasam

Replying to pookey:

please retest on 0.9. I think I might have fixed it.. maybe ;)

Hi, since 0.9 branch will be unmaintaned in some weeks: is it possible that it will be fixed in 0.10.2?

  Changed 16 months ago by jwage

  • owner changed from somebody to jwage
  • status changed from reopened to new
  • version set to 0.10
  • milestone changed from 1.0 to 0.10.3

  Changed 16 months ago by jwage

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

(In [3951]) fixes #672

Note: See TracTickets for help on using tickets.