From 03c1cb7cc77e19cc0026e7d8d4bef99901c40ede Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 18 May 2011 23:19:47 +1200 Subject: [PATCH] Try and workaround some PHP versions not initialising static instance vars. --- inc/Principal.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/Principal.php b/inc/Principal.php index c0b29117..62157a7a 100644 --- a/inc/Principal.php +++ b/inc/Principal.php @@ -26,6 +26,7 @@ class Principal { private static $db_mandatory_fields = array( 'username', ); + public static function updateableFields() { return array( 'username', 'email', 'user_active', 'modified', 'password', 'fullname', @@ -104,6 +105,13 @@ class Principal { $this->exists = false; $this->by_email = false; $this->original_request_url = null; + + if ( !is_array($db_mandatory_fields) ) { + $db_mandatory_fields = array( + 'username', + ); + } + switch( $type ) { case 'path': $type = 'username'; @@ -430,7 +438,7 @@ class Principal { $sql_params[':'.$k] = $field_values->{$k}; } - if ( $inserting ) { + if ( $inserting && isset($this->db_mandatory_fields) ) { foreach( $this->db_mandatory_fields AS $k ) { if ( !isset($sql_params[':'.$k]) ) { throw new Exception( get_class($this).'::Create: Mandatory field "'.$k.'" is not set.');