Consider these two classes. Class Accepter in
placement_class es.inc.php works as a form validation object, and it
works like a charm:
PHP:
// placement_class es.inc.php - THIS ONE WORKS!
class Accepter {
function Accepter() {
$this->dbAP =& new DBActionPerform er();
$this->dbAP->connect();
$this->validate();
$this->dbAP->disconnect() ;
$this->dbAP = null;
}
/**
* Perform validation
*
* @access private
*/
function &validate() {
// STATIC VOID METHOD
foreach ($_POST as $key => $val) if (!isset(${$key} ))
${$key} = $val;
$varErrArray = array();
array_push($var ErrArray,
'placement_name |setMandatory~s etMinLength~set MaxLe
ngth~setPattern |You must enter a location name~Your location name
must be 2 or more characters~Your location name must be 50 or fewer
characters in length~^(?!.*<[^>]+> )|Your location name configuration
is unrecognizable by our system, please re-enter with legitimate
characters|');
array_push($var ErrArray, 'unique_key|set Mandatory|You must
have a unique key prior to posting||');
/*---------------------------------------------------------------------------------------------------------------------
createErrorMsgC ollection function from
formvalidation. inc standalone function returns an array of
ErrorMsgCollect ion
objects
-----------------------------------------------------------------------------------------------------------------------*/
$this->errorMsgObjArr ay =&
createErrorMsgC ollection($varE rrArray);
// CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS
PARAMETER
$this->formValidato r =& new FormValidator(' ',
$this->errorMsgObjArr ay);
$this->isValid = $this->formValidato r->isValid();
$this->setErrorArray( $this->formValidato r->getErrorArray( ));
$this->formValidato r = null;
$this->errorMsgObjArr ay = null;
/*
if (strcmp(strtolo wer($action), 'add') == 0 ||
(strcmp(strtolo wer($action), 'edit') == 0 && $placement_name !==
$origPlacementN ame))
$this->checkDuplicate Placement($plac ement_name);
// CHECK FOR DUPLICATE PLACEMENT
*/
}
}
This is the class Accepter from contacts_classe s.inc.php and while it
is now identical in code structure to the Accepter classe in
placement_class es.inc.php, whenever this class method is invoked, all
processes stop (no errors), arrays are unfinished, objects are
unfinished, HTTP never produces, Apache goes down, literally
everything crashes!
PHP:
// contacts_classe s.inc.php - THIS ONE PRODUCES A POSSIBLE SEG
FAULT!
class Accepter {
function Accepter() {
// NEW 8/17/2004: SURROUND validate() METHOD WITH
INSTANTIATION OF $this->dbAP OBJECT PROPERTY
$this->dbAP =& new DBActionPerform er();
$this->dbAP->connect();
$this->validate();
$this->dbAP->disconnect() ;
$this->dbAP = null;
}
/**
* Main method. Will perform all other validation methods and
set isValid boolean property
*
* @access public
*/
function &validate() { //
STATIC VOID METHOD
foreach ($_POST as $key => $val) if (!isset(${$key} ))
${$key} = $val;
$varErrArray = array();
array_push($var ErrArray,
'placement_name |setMandatory~s etMinLength~set MaxLe
ngth~setPattern |You must enter a location name~Your location name
must be 2 or more characters~Your location name must be 50 or fewer
characters in length~^(?!.*<[^>]+> )|Your location name configuration
is unrecognizable by our system, please re-enter with legitimate
characters|');
array_push($var ErrArray, 'unique_key|set Mandatory|You must
have a unique key prior to posting||');
/*---------------------------------------------------------------------------------------------------------------------
createErrorMsgC ollection function from
formvalidation. inc standalone function returns an array of
ErrorMsgCollect ion
objects
-----------------------------------------------------------------------------------------------------------------------*/
$this->errorMsgObjArr ay =&
createErrorMsgC ollection($varE rrArray);
// CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS
PARAMETER
$this->formValidato r =& new FormValidator(' ',
$this->errorMsgObjArr ay);
$this->isValid = $this->formValidato r->isValid();
$this->setErrorArray( $this->formValidato r->getErrorArray( ));
$this->formValidato r = null;
$this->errorMsgObjArr ay = null;
/*
if (strcmp(strtolo wer($action), 'delete_select' ) == 0 &&
@sizeof($delete _selected) == 0) {
$this->isValid = false;
$this->setErrorArray( array('action' => 'You must select
at least one contact for deletion'));
}
*/
}
}
I've been trying to debug this for days now to no avail. I can verify
every object property is present and accounted for (and identical in
every way), but if you evoke one it's fine, the other and a segfault!
Help!
Thanx
Phil
placement_class es.inc.php works as a form validation object, and it
works like a charm:
PHP:
// placement_class es.inc.php - THIS ONE WORKS!
class Accepter {
function Accepter() {
$this->dbAP =& new DBActionPerform er();
$this->dbAP->connect();
$this->validate();
$this->dbAP->disconnect() ;
$this->dbAP = null;
}
/**
* Perform validation
*
* @access private
*/
function &validate() {
// STATIC VOID METHOD
foreach ($_POST as $key => $val) if (!isset(${$key} ))
${$key} = $val;
$varErrArray = array();
array_push($var ErrArray,
'placement_name |setMandatory~s etMinLength~set MaxLe
ngth~setPattern |You must enter a location name~Your location name
must be 2 or more characters~Your location name must be 50 or fewer
characters in length~^(?!.*<[^>]+> )|Your location name configuration
is unrecognizable by our system, please re-enter with legitimate
characters|');
array_push($var ErrArray, 'unique_key|set Mandatory|You must
have a unique key prior to posting||');
/*---------------------------------------------------------------------------------------------------------------------
createErrorMsgC ollection function from
formvalidation. inc standalone function returns an array of
ErrorMsgCollect ion
objects
-----------------------------------------------------------------------------------------------------------------------*/
$this->errorMsgObjArr ay =&
createErrorMsgC ollection($varE rrArray);
// CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS
PARAMETER
$this->formValidato r =& new FormValidator(' ',
$this->errorMsgObjArr ay);
$this->isValid = $this->formValidato r->isValid();
$this->setErrorArray( $this->formValidato r->getErrorArray( ));
$this->formValidato r = null;
$this->errorMsgObjArr ay = null;
/*
if (strcmp(strtolo wer($action), 'add') == 0 ||
(strcmp(strtolo wer($action), 'edit') == 0 && $placement_name !==
$origPlacementN ame))
$this->checkDuplicate Placement($plac ement_name);
// CHECK FOR DUPLICATE PLACEMENT
*/
}
}
This is the class Accepter from contacts_classe s.inc.php and while it
is now identical in code structure to the Accepter classe in
placement_class es.inc.php, whenever this class method is invoked, all
processes stop (no errors), arrays are unfinished, objects are
unfinished, HTTP never produces, Apache goes down, literally
everything crashes!
PHP:
// contacts_classe s.inc.php - THIS ONE PRODUCES A POSSIBLE SEG
FAULT!
class Accepter {
function Accepter() {
// NEW 8/17/2004: SURROUND validate() METHOD WITH
INSTANTIATION OF $this->dbAP OBJECT PROPERTY
$this->dbAP =& new DBActionPerform er();
$this->dbAP->connect();
$this->validate();
$this->dbAP->disconnect() ;
$this->dbAP = null;
}
/**
* Main method. Will perform all other validation methods and
set isValid boolean property
*
* @access public
*/
function &validate() { //
STATIC VOID METHOD
foreach ($_POST as $key => $val) if (!isset(${$key} ))
${$key} = $val;
$varErrArray = array();
array_push($var ErrArray,
'placement_name |setMandatory~s etMinLength~set MaxLe
ngth~setPattern |You must enter a location name~Your location name
must be 2 or more characters~Your location name must be 50 or fewer
characters in length~^(?!.*<[^>]+> )|Your location name configuration
is unrecognizable by our system, please re-enter with legitimate
characters|');
array_push($var ErrArray, 'unique_key|set Mandatory|You must
have a unique key prior to posting||');
/*---------------------------------------------------------------------------------------------------------------------
createErrorMsgC ollection function from
formvalidation. inc standalone function returns an array of
ErrorMsgCollect ion
objects
-----------------------------------------------------------------------------------------------------------------------*/
$this->errorMsgObjArr ay =&
createErrorMsgC ollection($varE rrArray);
// CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS
PARAMETER
$this->formValidato r =& new FormValidator(' ',
$this->errorMsgObjArr ay);
$this->isValid = $this->formValidato r->isValid();
$this->setErrorArray( $this->formValidato r->getErrorArray( ));
$this->formValidato r = null;
$this->errorMsgObjArr ay = null;
/*
if (strcmp(strtolo wer($action), 'delete_select' ) == 0 &&
@sizeof($delete _selected) == 0) {
$this->isValid = false;
$this->setErrorArray( array('action' => 'You must select
at least one contact for deletion'));
}
*/
}
}
I've been trying to debug this for days now to no avail. I can verify
every object property is present and accounted for (and identical in
every way), but if you evoke one it's fine, the other and a segfault!
Help!
Thanx
Phil
Comment