Permalink
Browse files

BackwardsCompatibilityBreak - fActiveRecord::has() was renamed to fAc…

…tiveRecord::hasOld() and fActiveRecord::retrieve() was renamed to fActiveRecord::retrieveOld()
  • Loading branch information...
wbond committed Oct 26, 2008
1 parent 08f818f commit c92bb99c85adca5aabbf92f808843a26856462b5
Showing with 20 additions and 20 deletions.
  1. +7 −7 classes/fActiveRecord.php
  2. +1 −1 classes/fORMDate.php
  3. +2 −2 classes/fORMFile.php
  4. +1 −1 classes/fORMMoney.php
  5. +6 −6 classes/fORMOrdering.php
  6. +3 −3 classes/fORMValidation.php
View
@@ -23,8 +23,8 @@
const assign = 'fActiveRecord::assign';
const changed = 'fActiveRecord::changed';
const forceConfigure = 'fActiveRecord::forceConfigure';
const has = 'fActiveRecord::has';
const retrieve = 'fActiveRecord::retrieve';
const hasOld = 'fActiveRecord::hasOld';
const retrieveOld = 'fActiveRecord::retrieveOld';
/**
@@ -111,7 +111,7 @@ static public function forceConfigure($class)
* @param string $column The column to set
* @return boolean If an old value for that column exists
*/
static public function has(&$old_values, $column)
static public function hasOld(&$old_values, $column)
{
return array_key_exists($column, $old_values);
}
@@ -128,7 +128,7 @@ static public function has(&$old_values, $column)
* @param boolean $return_all Return the array of all old values for this column instead of just the oldest
* @return mixed The old value for the column
*/
static public function retrieve(&$old_values, $column, $default=NULL, $return_all=FALSE)
static public function retrieveOld(&$old_values, $column, $default=NULL, $return_all=FALSE)
{
if (!isset($old_values[$column])) {
return $default;
@@ -805,7 +805,7 @@ public function exists()
$pk_columns = fORMSchema::retrieve()->getKeys(fORM::tablize($this), 'primary');
foreach ($pk_columns as $pk_column) {
if ((self::has($this->old_values, $pk_column) && self::retrieve($this->old_values, $pk_column) === NULL) || $this->values[$pk_column] === NULL) {
if ((self::hasOld($this->old_values, $pk_column) && self::retrieveOld($this->old_values, $pk_column) === NULL) || $this->values[$pk_column] === NULL) {
return FALSE;
}
}
@@ -1599,8 +1599,8 @@ public function store()
$this->related_records
);
if ($new_autoincrementing_record && self::has($this->old_values, $pk_column)) {
$this->values[$pk_column] = self::retrieve($this->old_values, $pk_column);
if ($new_autoincrementing_record && self::hasOld($this->old_values, $pk_column)) {
$this->values[$pk_column] = self::retrieveOld($this->old_values, $pk_column);
unset($this->old_values[$pk_column]);
}
View
@@ -369,7 +369,7 @@ static public function objectifyTimestampWithTimezone(&$values, &$old_values, $t
$value = new fTimestamp($value, $timezone);
if (fActiveRecord::has($old_values, $timezone_column) && !fActiveRecord::has($old_values, $timestamp_column)) {
if (fActiveRecord::hasOld($old_values, $timezone_column) && !fActiveRecord::hasOld($old_values, $timestamp_column)) {
fActiveRecord::assign($values, $old_values, $timestamp_column, $value);
} else {
$values[$timestamp_column] = $value;
View
@@ -431,7 +431,7 @@ static public function delete($object, &$values, &$old_values, &$related_records
}
// Remove the old files for the column
foreach (fActiveRecord::retrieve($old_values, $column, array(), TRUE) as $file) {
foreach (fActiveRecord::retrieveOld($old_values, $column, array(), TRUE) as $file) {
if ($file instanceof fFile) {
$file->delete();
}
@@ -457,7 +457,7 @@ static public function deleteOld($object, &$values, &$old_values, &$related_reco
// Remove the old files for the column
foreach (self::$file_upload_columns[$class] as $column => $directory) {
foreach (fActiveRecord::retrieve($old_values, $column, array(), TRUE) as $file) {
foreach (fActiveRecord::retrieveOld($old_values, $column, array(), TRUE) as $file) {
if ($file instanceof fFile) {
$file->delete();
}
View
@@ -315,7 +315,7 @@ static public function objectifyMoneyWithCurrency(&$values, &$old_values, $value
$value = new fMoney($value, $currency);
if (fActiveRecord::has($old_values, $currency_column) && !fActiveRecord::has($old_values, $value_column)) {
if (fActiveRecord::hasOld($old_values, $currency_column) && !fActiveRecord::hasOld($old_values, $value_column)) {
fActiveRecord::assign($values, $old_values, $value_column, $value);
} else {
$values[$value_column] = $value;
View
@@ -130,7 +130,7 @@ static private function createOldOtherFieldsWhereClause($table, $other_columns,
{
$conditions = array();
foreach ($other_columns as $other_column) {
$other_value = fActiveRecord::retrieve($old_values, $other_column, $values[$other_column]);
$other_value = fActiveRecord::retrieveOld($old_values, $other_column, $values[$other_column]);
$conditions[] = $other_column . fORMDatabase::escapeBySchema($table, $other_column, $other_value, '=');
}
@@ -177,7 +177,7 @@ static public function delete($object, &$values, &$old_values, &$related_records
$other_columns = self::$ordering_columns[$class]['other_columns'];
$current_value = $values[$column];
$old_value = fActiveRecord::retrieve($old_values, $column, $current_value);
$old_value = fActiveRecord::retrieveOld($old_values, $column, $current_value);
// Figure out the range we are dealing with
$sql = "SELECT max(" . $column . ") FROM " . $table;
@@ -271,8 +271,8 @@ static public function inspect($object, &$values, &$old_values, &$related_record
static private function isInNewSet($ordering_column, $other_columns, &$values, &$old_values)
{
$value_empty = !$values[$ordering_column];
$old_value_empty = !fActiveRecord::retrieve($old_values, $ordering_column, TRUE);
$no_old_value_set = !fActiveRecord::has($old_values, $ordering_column);
$old_value_empty = !fActiveRecord::retrieveOld($old_values, $ordering_column, TRUE);
$no_old_value_set = !fActiveRecord::hasOld($old_values, $ordering_column);
// If the value appears to be new, the record must be new to the order
if ($old_value_empty || ($value_empty && $no_old_value_set)) {
@@ -355,7 +355,7 @@ static public function reorder($object, &$values, &$old_values, &$related_record
$other_columns = self::$ordering_columns[$class]['other_columns'];
$current_value = $values[$column];
$old_value = fActiveRecord::retrieve($old_values, $column);
$old_value = fActiveRecord::retrieveOld($old_values, $column);
// Figure out the range we are dealing with
$sql = "SELECT max(" . $column . ") FROM " . $table;
@@ -518,7 +518,7 @@ static public function validate($object, &$values, &$old_values, &$related_recor
$other_columns = self::$ordering_columns[$class]['other_columns'];
$current_value = $values[$column];
$old_value = fActiveRecord::retrieve($old_values, $column);
$old_value = fActiveRecord::retrieveOld($old_values, $column);
$sql = "SELECT max(" . $column . ") FROM " . $table;
if ($other_columns) {
@@ -502,10 +502,10 @@ static private function checkPrimaryKeys($object, &$values, &$old_values)
$different = FALSE;
foreach ($primary_keys as $primary_key) {
if (!fActiveRecord::has($old_values, $primary_key)) {
if (!fActiveRecord::hasOld($old_values, $primary_key)) {
continue;
}
$old_value = fActiveRecord::retrieve($old_values, $primary_key);
$old_value = fActiveRecord::retrieveOld($old_values, $primary_key);
$value = $values[$primary_key];
if (self::isCaseInsensitive($class, $primary_key) && fCore::stringlike($value) && fCore::stringlike($old_value)) {
if (strtolower($value) != strtolower($old_value)) {
@@ -614,7 +614,7 @@ static private function checkUniqueConstraints($object, $column, &$values, &$old
if ($object->exists()) {
foreach ($primary_keys as $primary_key) {
$value = fActiveRecord::retrieve($old_values, $primary_key, $values[$primary_key]);
$value = fActiveRecord::retrieveOld($old_values, $primary_key, $values[$primary_key]);
$sql .= ' AND ' . $primary_key . fORMDatabase::escapeBySchema($table, $primary_key, $value, '<>');
}
}

0 comments on commit c92bb99

Please sign in to comment.