Yii Framework Forum: Identified Issues - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Identified Issues Scratching your head about something in the book? Start here

#1 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 24 September 2010 - 10:38 PM

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('comment/feed', 'urlSuffix'=>'.xml', 'caseSensitive'=>false),
    				'<pid:\d+>/commentfeed'=>array('comment/feed', '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.
  • Code comment at the bottom of page 205 incorrectly references password, when it should be "role" - code is correct, but the code comment is not accurate Should be // username and role are required
  • Typo - Page 113 First paragraph under the heading "Adding a Filter", last sentence. IssueCcontroller should read: IssueController
  • Code Typo - Page 204 - in the testUserProjectAssignment() test method, 'project1' is incorrectly referenced, as it should be 'project2'. The correct method is:
    public function testUserProjectAssignment()
    {
      //since our fixture data already has the two users assigned to project 1, we'll assign user 1 to project 2
      $this->projects('project2')->associateUserToProject($this->users('user1'));
      $this->assertTrue($this->projects('project2')->isUserInProject($this->users('user1')));
    }

3

#2 User is offline   Benn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 47
  • Joined: 16-January 11
  • Location:Paris

Posted 10 February 2011 - 07:45 PM

Page 233 :
protected/components/views/renderComments.php

should be
protected/components/views/recentComments.php

...
0

#3 User is offline   Benn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 47
  • Joined: 16-January 11
  • Location:Paris

Posted 12 February 2011 - 04:14 AM

Page 296 :
 
$role->addChild("owner";


is missing a )
Should be :

$role->addChild("owner");

0

#4 User is offline   csorrows 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 27-May 11

Posted 27 May 2011 - 01:02 PM

Chapter 3, page 46/47

If using Yii 1.1.7, the Selenium test will hang on the Contact and Login screens, even though the text on the browser screen looks okay.

From other thread postings, it looks related to Yii 1.1.7 enabling client-side Javascript validation by default now.

This can be worked around for this example by editing the following two files:

.../protected/views/site/contact.php
.../protected/views/site/login.php

Change the "enableClientValidation" parameter (one in each file) to a value of "false". Tests should now complete.

EDIT: Also, to prevent IE errors when running tests on a Linux system, delete the line in .../protected/tests/phpunit.xml that references the IE browser. When I deleted this and just left the line referencing the Firefox browser, all my test errors went away.
1

#5 User is offline   Paul Secret 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 02-June 11

Posted 02 June 2011 - 07:36 AM

Another, (I think) better approach other than the one with disabling client side validation (why would you do that? since Selenium should be built to test anything (including JS validation)):

1) If you enabled nice URLs make sure you change the way the contact page gets called (you can use something similar to the way login gets called:
clickAndWait('link=Contact')
);
2) Change
clickAndWait()
to
click()
on the login and submit buttons respectively (don't change the
clickAndWait()
that is supposed to log you in though, only change the one that is supposed to throw a validation error);
3) You can use the PHP function
sleep()
to delay some parts of the execution to gain a better perspective over what gets called and when.

I still had problems with IE9 throwing weird script errors when Selenium opened it, didn't struggle to fix this yet, Chrome and FF4 work like a charm under x64 Se7en.

I hope I got everything you have to do because I struggled a bit with it and tried multiple things
0

#6 User is offline   murphaph 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 06-May 11

Posted 02 July 2011 - 12:12 PM

Hi Jeff. I'm still fairly new to PHP and web development in general and taking it one step at a time. I love the long tutorial format of your book and I'm working through it from start to finish. After that I'll look at building my own app with Yii. (we use it in work for a frontend of a large ecommerce site and it was my first exposure to a framework, so even though I'm not on that project anymore, I'm gonna stick with yii as a "first step" to learning how frameworks work.)

Anyway, your book is really helping me along the way but I thought I would let you know I ran into a spot of trouble on page 120 when trying to enter the SQL command (at the command line and in PHPMyAdmin):

INSERT INTO 'tbl_project_user_assignment' ('project_id', 'user_id') VALUES (1,1), (1,2);

I got syntax errors reported. So I tried:

INSERT INTO tbl_project_user_assignment (project_id, user_id) VALUES ('1','1'), ('1','2');

...and the insert worked. I don't really know if that's an error in the book but it threw me for a few minutes. Perhaps you could clarify and delete this post if neccessary. Keep up the great work and I'll be buying your next book on yii too ;-) as I love your writing style.

Bye for now,
Philip.
0

#7 User is offline   murphaph 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 06-May 11

Posted 03 July 2011 - 10:06 AM

On page 134 Theres a block of code and in the middle (still in code font) is "And also this test:" which should obviously not be included in the code block like that. Cheers.
0

#8 User is offline   nirvanaforu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 05-May 11

Posted 11 September 2011 - 07:31 PM

in page 222, the code added to view/issue/view.php,
<div id="comments">
<?php if($model->commentCount>=1): ?>
<h3>
<?php echo $model->commentCount>1 ? $model->commentCount . '
comments' : 'One comment'; ?>
</h3>
<?php $this->renderPartial('_comments',array(
'comments'=>$model->comments,
)); ?>
<?php endif; ?>
<h3>Leave a Comment</h3>
<?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>
<div class="flash-success">
<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
</div>
<?php else: ?>
<?php $this->renderPartial('/comment/_form',array(
'model'=>$comment,
)); ?>
<?php endif; ?>
</div>


at the bottom, the variable $comment is not defined. I havn't figured out what's the right variable to put there?
If I replace it with $model->comments, I will get an error
PHP Fatal error: Call to a member function isAttributeRequired() on a non-object in /var/www/html/yii/framework/web/helpers/CHtml.php on line 1166
0

#9 User is offline   fsb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 09-January 11

Posted 15 September 2011 - 09:54 AM

The book itself says:

Quote

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books maybe a mistake in the text or the code we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting hxxp://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from hxxp://www.packtpub.com/support.


It was frustrating to waste time there and then eventually find after googling around that the author is collecting corrections in this forum rather than in the support page his book says we should refer to.

Maybe I should submit a correction of Page 4 to PACKT's support so that they put an errata on their support page.
Join the happiest place on Freenode: #yii
We've got a MrFisk the bot, hilarious banter and all kinds of other groovy stuff going on.
Comparison of Internet Relay Chat clients
Web IRC client
0

#10 User is offline   Boaz 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 359
  • Joined: 23-January 11

Posted 08 January 2012 - 03:26 PM

Hi,

I've finished reading this book lately - from start to finish. Rarely do I have the time to invest, but this time I just took the time for that :-) .

Following is my list of feedback, mostly typos etc but a few comments as well.
I haven't checked if those are identified yet - forgive me in advance. I'm about to submit this errata to Packet Publishing. They should know too, despite voices saying things along the line of "its a lost battle".

Also, I'd like to comment that I liked the book a lot. I think its very good as a Yii beginner's book. Even if it has some issues and at least to me, getting the code to work on later chapters was problematic (I noted about this below...) its explanations are very good, its coverage is excellent, its depth is also good - not too much, not too shallow. Just to get intro into TDD with Yii was worth the purchase of the book. I'll submit my review of it in Amazon as well.

Stuff:
• pg 106, the big notice paragraph:I think the right magic function that relates to firing the 'non-defined' getOptions() method is __call() and not __get(). Yes, __get() is being used by Yii as well, when dereferencing AR model attributes that are not even defined in "our" model class but that's not the case at hand.
• pg. 109, second paragraph (starts with "This line is using the CActiveForm::labelEx()...". On the second line's beginning there's an extra "a" (seems like extra to me).
• pg. 118 - a link to the project 'view' view was added to create an issue for that project. all nice and dandy but the link to create a new issues that appears in multiple other issue-views needs to be commented out.
• pg 129. Yes, this actionView() code section has many mentions on the web. obviously - its faulty. I wonder why its not listed on the official errata page when so much time has passed since the error has been reported. i used actionView($id) (as it was from previous steps of the apps) and therefore simply used "array(':projectId' => $id),..." on the line that caused the problem.
• pg. 202 second bullet, mentions table "tbl_project_use_assignment". Should be "tbl_project_user_assignment".
• pg. 202 : this is a suggestion rather than typo or the like: the book isn't taking a tutorial with exercises approach so I would have slightly changed the approach of the text to lightly mention the option of implementation by the reader before reading the implementation ahead.
• chapter 9: beginning this chapter, I was unable to make your supplied code work with your supplied schema. By "supplied" I refer to what is available for download from Packet Publishing site. Every chapter's material should be working on its own and by chapter 9, where i dropped my old code in favor of your code (for reasons i describe in next issue), I was unable to make the code + (your) DB sing along. There was some problem in feeding in new projects - the create_user_id wasn't updated which led to other problems along the way. Due to time constraints I didn't debug this. Assuming that its not my fault, IMHO, you have to make sure that each chapter's material is self contained and "decoupled" from previous chapter's material if there's such a dependency. In specific - the data fed in previous chapters should not be relied upon in subsequent chapters. I'm not sure this is directly causing the problem I faced but In the supplied schema file there's only a couple of user's created and previous chapter's data was dropped, which led indirectly to a problem when creating new data (projects, issues...).
• Regarding the trackstar application database schema, I think that since this book is for Yii newcomers you should drop the tbl_* prefix where it was used in some tables names. Keep it simple and appropriate for the beginner nature of the learning state. I think that there's no need to overload the user with table name prefixes. That's an easy piece of the puzzle to catch up with later when the need arise. Its a nag to add the 'tbl_' prefix while using the book and querying using command line mysql client... .
• pg. 227, first paragraph. It says there that "the second parameter will allow us... to display *all* comments for a project...". That's not accurate. It will allow us to display *a limited* number of comments based on given $limit var, with defautl number of such comments as defined in the first parameter - $limit.
• pg. 230, first disc-bullet - same comment as above - there's no "get ALL comments" but rather "get all comments based on the default 'limit' (in findRecentComments()).
• pg. 228, first quoted code section: It says "...with('issues')" while I think it should be "with('issue')" as the relation name defined in Comment class is issue and not issues (singular vs. plural).
• pg. 233, the sentence right before the second code block: should state the path of the widget view as protected/components/view/recentComment.php and not renderComments.php. Similarly, in the bottom paragraph, it states the widget name to be RenderComments while its RecentComments.
• pg. 246, line 6 before page end - there's "set the set the". one "set" of "set the" should be deleted :-) .
• pg. 247, second paragraph: URL has a typo in the form of a mistyped space char:" localhost/trackstar /index.php.../ (note the bad space char...).
Therapeutic PHP sessions My LinkedIn Profile
0

#11 User is offline   Javier Lozano 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 01-May 12

Posted 01 May 2012 - 09:27 PM

¡This is an important one!

On Page 207, code says:

public function actionAdduser()
    {
        $form=new ProjectUserForm;
        $project = $this->loadModel();


And it should be:

public function actionAdduser($id)
    {
        $form=new ProjectUserForm;
        $project = $this->loadModel($id);

0

#12 User is offline   ridgerunner 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 31-March 11

Posted 17 June 2012 - 12:56 PM

I am starting to work through this book. I have the recommended Yii version 1.1.2 but which versions of PHPunit and Selenium should be used for maximum compatibility/least pain? (I assume it would be best to use the versions that were active back when yii-1.1.2 was current?)

(All required software recommended versions should be posted in the first post here, yes?)

Also: Is Jeff still around here?

So far, loving yii!
0

#13 User is offline   dhimes 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 07-August 12

Posted 19 August 2012 - 03:08 PM

RE 11-NOTE: the code available for download from the packt site doesn't have any sql scripts at all. Is there another source for the code?
0

#14 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 20 August 2012 - 10:29 PM

View Postdhimes, on 19 August 2012 - 03:08 PM, said:

RE 11-NOTE: the code available for download from the packt site doesn't have any sql scripts at all. Is there another source for the code?


You can download from github: https://github.com/jefftulsa/TrackStar
0

#15 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 20 August 2012 - 10:32 PM

View Postridgerunner, on 17 June 2012 - 12:56 PM, said:

I am starting to work through this book. I have the recommended Yii version 1.1.2 but which versions of PHPunit and Selenium should be used for maximum compatibility/least pain? (I assume it would be best to use the versions that were active back when yii-1.1.2 was current?)

(All required software recommended versions should be posted in the first post here, yes?)

Also: Is Jeff still around here?

So far, loving yii!


I believe the versions used at the time of writing (now 2 years ago) were
PHPUnit 3.5.3
and
Selenium Server 1.0.3

FYI, I have just now completed all first drafts of a 2nd Edition of this book. The Second Edition will correct all of the errata published in the first book as well as brings everything up-to-date with latest version of Yii 1.1.12. Hopefully it will be released within the next month.
0

#16 User is offline   TheSchaef 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 27-July 12
  • Location:Columbus, OH

Posted 19 September 2012 - 09:05 AM

I know it's not like you have any control over what the publishers do once they have the material, but we're a month on now from this last statement, and I'm sure I'm not the only one checking this thread (and board) almost daily for news of an updated release.

As a resource it is tremendous, and a much-needed helping hand into Yii, but I desperately need current-version examples so I can understand what's going on under the hood.
0

#17 User is offline   Ash_R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 22-January 12
  • Location:India

Posted 28 September 2012 - 05:41 AM

You could use following IssueController::loadModel() method instead of one mentioned on page no. 231

public function loadModel($id, $withComments=false)
	{
		if(isset($id))
		{
			if($withComments)
			{
				$model = Issue::model()->with(array('comments' => array('with' => 'author')))->findbyPk($id);
			}
			else
			{
				$model = Issue::model()->findbyPk($id);
			}
		}
		if($model === null)
			throw new CHttpException(404, 'The requested page does not exist.');
		return $model;
	}


along with call to the actionView() method as -

$issue=$this->loadModel($id, true);

0

#18 User is offline   dkeeling 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 11-October 12

Posted 11 October 2012 - 01:31 PM

Page 220

public function actionView()
{
	$issue=$this->loadModel();
	$comment=$this->createComment($issue);
		
	$this->render('view',array(
		'model'=>$issue,
		'comment'=>$comment,
	));
}


Should be:

public function actionView($id)
{
	$issue=$this->loadModel($id);
	$comment=$this->createComment($issue);
		
	$this->render('view',array(
		'model'=>$issue,
		'comment'=>$comment,
	));
}

0

#19 User is offline   nkd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 28-September 12

Posted 29 October 2012 - 10:55 AM

View PostTheSchaef, on 19 September 2012 - 09:05 AM, said:

I know it's not like you have any control over what the publishers do once they have the material, but we're a month on now from this last statement, and I'm sure I'm not the only one checking this thread (and board) almost daily for news of an updated release.

As a resource it is tremendous, and a much-needed helping hand into Yii, but I desperately need current-version examples so I can understand what's going on under the hood.



I found out that you can already buy the book in a "RAW" version directly from the publisher.

The book title changed to: Web Application Development with Yii and PHP

Here is the link:

http://www.packtpub....nd-edition/book



0

#20 User is offline   dhimes 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 07-August 12

Posted 17 November 2012 - 10:46 AM

View Postnkd, on 29 October 2012 - 10:55 AM, said:

I found out that you can already buy the book in a "RAW" version directly from the publisher.

The book title changed to: Web Application Development with Yii and PHP

Here is the link:

http://www.packtpub....nd-edition/book



Did they deliver it? That sites looks like a pre-order- with delivery (hopefully) sometime in December 2012.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users