Subject: Errata
Posted By: omarosa Post Date: 3/1/2005 2:00:42 PM
I'm going to keep an updated list of errors I run into, so I (and other people) have an easy place to reference to. Unlike the actual errata page, this will contain something. I haven't read the book straight through, nor have I tested everything, so anyone else feel free to add anything.




06.25.2005                                                              
Chapter 11 - class.LoggerBackend.php & class.fileLoggerBackend.php

It will complain because class.fileLoggerBackend.php's implementation of the logMessage() is not done in the same way as in class.LoggerBackend.php (the class it extends). You can simply change one method to match the other.

original:

class.fileLoggerBackend.php:
public function logMessage($msg, $logLevel = LOGGER_INFO, $module = null)
class.LoggerBackend.php:
abstract function logMessage($message, $logLevel = LOGGER_INFO, $module)

corrected:

class.fileLoggerBackend.php:
public function logMessage($msg, $logLevel = LOGGER_INFO, $module = null)
class.LoggerBackend.php:
abstract function logMessage($message, $logLevel = LOGGER_INFO, $module = null)


Chapter 11 - newclass.Logger.php

private static function manageBackends($name, LoggerBackend $objBack = null)

can be changed to the following:
private static function manageBackends($name, $objBack = null)

It will complain about the argument not being of the right type.


Chapter 5 - class.Collection.php

Fatal error: Call to private method NightClub::_loadSingers() from context 'Collection' in d:\web\book\ch05\class.Collection.php on line 91

To fix this, change the _loadSingers function from private to public in the NightClub class (ie public function _loadSingers(Collection $col))

Correction from eggspencer


03.01.2005                                                              
Chapter 13 - constraint.phpm
original:
function GetConstraintType() {
    return($this->_intContraintType);
}

corrected:
function GetConstraintType() {
    return($this->_intConstraintType);
}


Chapter 13 - request.phpm
original:
function GetPostVariables() {
    return($this->_arPostVariables);
}
function GetGetVariables() {
    return($this->_arGetVariables);
}

corrected:
function GetPostVariables() {
    return($this->_arPostVars);
}
function GetGetVariables() {
    return($this->_arGetVars);
}
Reply By: soup Reply Date: 4/18/2005 6:32:09 AM
The book is interested but.......

I'm looking at chapter 15 Sessions and Authentification

Changes made so far to make my code work
In usersession.phpm
Change 1
# $strUserAgent = $GLOBALS["HTTP_USER_AGENT"];
# changed to _SERVER
$strUserAgent = $_SERVER["HTTP_USER_AGENT"];

this also needs changing further down in the script

Change 2
usersession.phpm
$maxlifetime is called but not defined in __construct so
$maxlifetime =  $this->session_lifespan;

Change 3
usersession.phpm
also in __construct
this sql is wrong
DELETE FROM \"user_session\" WHERE (ascii_session_id = '". $this->php_session_id . "') OR (now() - created) > '".$maxlifetime."')
its missing a (
CORRECT it should be
DELETE FROM \"user_session\" WHERE (ascii_session_id = '". $this->php_session_id . "') OR ( (now() - created) > '".$maxlifetime."')

Extra in the tables sql they don't insert the user
INSERT INTO "user"(username,md5_pw,first_name,last_name) VALUES ('ed', '827ccb0eea8a706c4c34a16891f84e7b', 'Ed', 'Lecky-Thompson');

After these changes it now works at least but I still get at the bottem of my script the following ???
Fatal error: Call to private method UserSession::_session_write_method() from context '' in Unknown on line 0

Warning: Unknown: A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

PS this was the case running on a local testing maching with WindowsXP pro

Reply By: smorse@rtpi.org Reply Date: 4/26/2005 11:44:43 AM
I caught/fixed the same errors in the script and had the same entries in error_log:

Fatal error: Call to private method UserSession::_session_write_method() from context '' in Unknown on line 0

Warning: Unknown: A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

Running on a remote testing maching with PHP5

Reply By: lowsumwai Reply Date: 4/27/2005 4:32:40 AM
Chapter 3 - entities.sql - 27APRIL2005
Original
CREATE TABLE "entities" (
Corrected
CREATE TABLE "entity" (
Reason
Foreign key in other tables need to refer to it.

Chapter 5 - class.StudentFactory.php - 27APRIL2005
Original
\"course\".\"id\"
Corrected
\"course\".\"courseid\"
Reason
mismatched field name

Chapter 5 - class.Student.php - 28APRIL2005
Original
$arCourses = StudentFactory::get...
Corrected
$courses = StudentFactory::get...
Reason
mismatched variable name



Reply By: luko Reply Date: 4/27/2005 10:16:55 AM
quote:
Originally posted by smorse@rtpi.org

I caught/fixed the same errors in the script and had the same entries in error_log:

Fatal error: Call to private method UserSession::_session_write_method() from context '' in Unknown on line 0

Warning: Unknown: A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

Running on a remote testing maching with PHP5





If somebody solves this problem, please let me know. Bye the way, do the writers of this book read this forum? Or do we have to wait and wait and wait ....

Reply By: mdeering Reply Date: 4/30/2005 3:34:51 PM
Change the functions "_session_write_method" and "_session_close_method" to public and it works.  Not ideal but it will keep you moving...

Reply By: amnesiacx Reply Date: 9/6/2005 6:55:54 AM
Re CH15 Sessions, it's a nice idea, but the code is just crap, even after the fixes suggested here. The table "session_variable" is never populated, and each time I refresh the page a new user session is created (ie the first line of usersessiontest.php always comes up with "Logged in?...  No" even though I comment out the logout call).

You would think someone publishing and releasing code in a book titled "Professional" anything, would at least provide working and tested code that would be close to production ready as possible. If the authors read this maybe they can spare some time from counting their money from the sales of the book and provide a professional working version of the usersession class that would be a truer reflection of the book's intentions.

Reply By: dandri Reply Date: 10/6/2005 9:21:23 AM
As for the Ch15, I modified the code and it works fine. However, I didn't like that I had to change methods "_session_write_method" and "_session_close_method" from 'private' to 'public', as all the other methods of session handler can be 'private'. I didn't also like that I couldn't find the reason of this problem. Has anyone fixed it?


Go to topic 35464

Return to index page 458
Return to index page 457
Return to index page 456
Return to index page 455
Return to index page 454
Return to index page 453
Return to index page 452
Return to index page 451
Return to index page 450
Return to index page 449