Thứ Sáu, 8 tháng 7, 2011

Yii Issues

NOTE: All of the examples provided in the book were completed with Yii version 1.1.2. Many readers are using the latest stable version of Yii (currently 1.1.5) to following along with the examples in the book. There are some subtle API/method signature differences (esp in some of the Gii auto-generated code) between these two versions. If you are using any version other than 1.1.2 to following along, you may have to make some adjustments to the examples used in the book.



  • Typo/Printing: Preface, Page 1 -
    The first section title reads: "What this book cover" it should read: "What this book covers" or "What is covered in this book"
  • Typo/Printing: Preface, Page 3 -
    Under the Conventions section, it is describing how code words in the text are shown and it uses the sentence: "You can type in help to see a list of commands available to you within his shell" It should be "...this shell" (i.e. 'his' should be 'this')
  • Style Formatting: Page 20 -
    The sentence:
    "Your application has been created successfully under /Webroot/demo/"
    should still be in code format style, as it is still part of the output from running the shell command.
  • Code Fragment: Page 105 -
    The code does not explicitly include the class in which the method should reside. The function is fine, but it could be misleading. The public function
    testGetTypes()
    needs to reside in a class. The full code is
    class IssueTest extends CDbTestCase { 
            public function testGetTypes() 
            { 
                    $options = Issue::model()->typeOptions; $this->assertTrue(is_array($options)); 
            } } 
  • Typo/Printing: Page 131 - The following line is missing a closing > bracket to delimit the end of the php statement:

    <b><?php echo CHtml::encode($data->getAttributeLabel('status_id')); ?:</b>
    It should be:

    <b><?php echo CHtml::encode($data->getAttributeLabel('status_id')); ?>:</b>
  • Typo/Printing: Page 142 -
    The very beginning sentence on this page has several issues. The sentence as it is printed is impossible to understand. The entire sentence should read: "As these links originate from the issue details page, we can take advantage of the associated project, and alter the links to pass in the specific project id. We can then use that project id as the criteria to limit the Issues returned by the query in both the IssueController::actionIndex(), and IssueController::actionAdmin() methods."
  • Type/Printing: Page 142 -
    There is a word 1/2 way down the page that is printed as "conssue", it should be "context": "...implemented a filter to enforce a valid project context"
  • Dated Code Snippet: Page 163 -
    The auto-generated code displayed for the
    UserIdentity::authenticate()
    method is from a version of the yiic webapp command that is prior to 1.1.2. It should be:
    public function authenticate()
            {
                    $users=array(
                            // username => password
                            'demo'=>'demo',
                            'admin'=>'admin',
                    );
                    if(!isset($users[$this->username]))
                            $this->errorCode=self::ERROR_USERNAME_INVALID;
                    else if($users[$this->username]!==$this->password)
                            $this->errorCode=self::ERROR_PASSWORD_INVALID;
                    else
                            $this->errorCode=self::ERROR_NONE;
                    return !$this->errorCode;
            }
  • Code Typo: Page 190 -
    sql query line
    primary key (projectId,userId,role)
    should be
    primary key (project_id,user_id,role)
  • Code Typo: Page 193 -
    $command->execute
    is missing the parentheses. It should be
    $command->execute()
  • Informational Note: Page 198 -
    You might need to define the foreign key relationship on tbl_project_user_role.project_id to automatically handle deletes of rows in the project table. Otherwise, you might get a constraint violation error when the unit test ProjectTest::testDelete() is run.
    in MySQL, something like
    ON DELETE CASCADE ON UPDATE CASCADE

    NOTE: The book is attempting to stay database independent, and the low level DDL statements for tables are intended to be general (i.e. not MySQL specific). However, the code available for download does have all of the MySQL specific statements used.
  • Code Typo: Page 249 -
    In url manager configuration, site/commentFeed is printed, but it should be just comment/feed:
    'urlManager'=>array(
                            'urlFormat'=>'path',
                            'rules'=>array(
                                    'commentfeed'=>array('[b]comment/feed[/b]', 'urlSuffix'=>'.xml', 'caseSensitive'=>false),
                                    '<pid:\d+>/commentfeed'=>array('[b]comment/feed[/b]', 'urlSuffix'=>'.xml', 'caseSensitive'=>false),
                                    ), 
                            'showScriptName'=>false,   
                    ),      
  • Typo: Page 210 -
    In the 3rd paragraph down, it refers to the view file as show.php but should be view.php.
  • Code/Yii version mismatch: Page 210 - The example 1/2 way down the page of creating the link is not consistent with the other menu items. It should be:
    $this->menu[] = array('label'=>'Add User To Project', 'url'=>array('adduser', 'id'=>$model->id)); 
    rather than using the CHtml::link method directly. (this format will still work, but is not consistent with the other menu items)
  • Code Typo: Page 91 - In the listed testCreate() function, the project column fields names need to be updated: 'createTime' should be 'create_time', 'createUser' should be 'create_user_id', 'updateTime' should be 'update_time' and 'updateUser' should be 'update_user_id'. The code still works and the test passes because the database will accept null values for these. But the names should be corrected.

3

#2 User is offline   DG Esteban A. Pérez 

  • Newbie
  • Yii
  • Add as Friend
  • Group: Members
  • Posts: 15
  • Joined: 16-September 10
  • Location:Bs. As., Argentina
Posted 30 September 2010 - 07:25 AM
Hi Jeff...

I'm reading your book... 2nd time... Yep... (first the digital, and now the paper one)

Yesterday I needed to understand how to use beforeSave, so I searched for it in your book.. I found "beforeValidate", it will help... Page 217... Bingo!...

But some one stolen the example!... And in the first reading I just didn´t see this :$

Pls... Could you paste it here?

Thanks.. Great work!!!

Esteban A. Pérez
(from Argentina)
0

#3 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Add as Friend
  • Group: Yii Dev Team
  • Posts: 139
  • Joined: 06-October 08
  • Location:Austin, TX
Posted 01 October 2010 - 08:17 AM
View PostDG Esteban A. Pérez, on 30 September 2010 - 07:25 AM, said:
Hi Jeff...

I'm reading your book... 2nd time... Yep... (first the digital, and now the paper one)

Yesterday I needed to understand how to use beforeSave, so I searched for it in your book.. I found "beforeValidate", it will help... Page 217... Bingo!...

But some one stolen the example!... And in the first reading I just didn´t see this :$

Pls... Could you paste it here?

Thanks.. Great work!!!

Esteban A. Pérez
(from Argentina)


Hello Esteban,

I believe the example of using the
beforeValidate()
method starts on page 152 of the printed book.
0

#4 User is offline   Backslider 

  • Junior Member
  • Pip
  • Yii
  • Add as Friend
  • Group: Members
  • Posts: 96
  • Joined: 23-July 09
Posted 24 October 2010 - 10:27 AM
Thanks for a fantastic book, extremely helpful!

Will you be updating this book in further edtions?

In my opinion the TDD would have been best left to a single chapter (or another book), rather than clouding most chapters. Many people do not wish to use this approach and it makes things difficult for newbies.

I was somewhat disappointed that the RBAC was not completely implemented throughout the application. That is, with the final result any user could create, edit or delete any project, thus negating the access control elsewhere. There was no provision for giving users global permissions when creating/editing users or any indication as to how to use access control at this level. This was only implemented for issues. I didn't see any comment about this being left up to the reader and with such an important aspect of development I think the reader should have been walked right through.

Encountered a few problems due to Yii version (I use SVN latest version), however these were easily overcome.
0

#5 User is offline   Backslider 

  • Junior Member
  • Pip
  • Yii
  • Add as Friend
  • Group: Members
  • Posts: 96
  • Joined: 23-July 09
Posted 25 October 2010 - 09:07 AM
Chapter 8, page 197 uses the following:

Yii::app()->user->getId()


which should just be:

Yii::app()->user->id

0

#6 User is offline   Backslider 

  • Junior Member
  • Pip
  • Yii
  • Add as Friend
  • Group: Members
  • Posts: 96
  • Joined: 23-July 09
Posted 25 October 2010 - 10:17 AM
My understanding of the RBAC for this was that users would be assigned a global role, plus individual roles for projects. The table 'authassignment' (which should be AuthAssignment) however has 'itemname' and 'userid' as a primary keys, thus causing a MySQL error when trying to assign a user to a project.

1 nhận xét:

  1. P218 should be:
    'author' => array(self::BELONGS_TO, 'User', 'id'),
    p233: should be
    recentComments.php.

    Trả lờiXóa