Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove some useless code.

  • Loading branch information...
commit 91185e47b27c0bea6ee959a1e334ae2930b5882a 1 parent fc64ee7
@gabordemooij authored
Showing with 21 additions and 36 deletions.
  1. +21 −36 RedBean/OODBBean.php
View
57 RedBean/OODBBean.php
@@ -384,53 +384,39 @@ public function &__get( $property ) {
}
if (!isset($this->properties[$property])) {
$fieldLink = $property.'_id';
- /**
- * All this magic can be become very complex quicly. For instance,
- * my PHP CLI produced a segfault while testing this code. Turns out that
- * if fieldlink equals idfield, scripts tend to recusrively load beans and
- * instead of giving a clue they simply crash and burn isnt that nice?
- */
if (isset($this->$fieldLink) && $fieldLink != $this->getMeta('sys.idfield')) {
$this->setMeta('tainted',true);
$type = $this->getAlias($property);
$targetType = $this->properties[$fieldLink];
$bean = $toolbox->getRedBean()->load($type,$targetType);
- //return $bean;
$this->properties[$property] = $bean;
return $this->properties[$property];
}
if (strpos($property,'own')===0) {
- $firstCharCode = ord(substr($property,3,1));
- if ($firstCharCode>=65 && $firstCharCode<=90) {
- $type = (__lcfirst(str_replace('own','',$property)));
- if ($this->aliasName) {
- $myFieldLink = $this->aliasName.'_id';
- $this->setMeta('sys.alias.'.$type,$this->aliasName);
- $this->aliasName = null;
- }
- else {
- $myFieldLink = $this->getMeta('type').'_id';
- }
- $beans = $toolbox->getRedBean()->find($type,array(),array(" $myFieldLink = ? ".$this->withSql,array($this->getID())));
- $this->withSql = '';
- $this->properties[$property] = $beans;
- $this->setMeta('sys.shadow.'.$property,$beans);
- $this->setMeta('tainted',true);
- return $this->properties[$property];
+ $type = (__lcfirst(str_replace('own','',$property)));
+ if ($this->aliasName) {
+ $myFieldLink = $this->aliasName.'_id';
+ $this->setMeta('sys.alias.'.$type,$this->aliasName);
+ $this->aliasName = null;
+ } else {
+ $myFieldLink = $this->getMeta('type').'_id';
}
+ $beans = $toolbox->getRedBean()->find($type,array(),array(" $myFieldLink = ? ".$this->withSql,array($this->getID())));
+ $this->withSql = '';
+ $this->properties[$property] = $beans;
+ $this->setMeta('sys.shadow.'.$property,$beans);
+ $this->setMeta('tainted',true);
+ return $this->properties[$property];
}
if (strpos($property,'shared')===0) {
- $firstCharCode = ord(substr($property,6,1));
- if ($firstCharCode>=65 && $firstCharCode<=90) {
- $type = (__lcfirst(str_replace('shared','',$property)));
- $keys = $toolbox->getRedBean()->getAssociationManager()->related($this,$type);
- if (!count($keys)) $beans = array(); else
- $beans = $toolbox->getRedBean()->batch($type,$keys);
- $this->properties[$property] = $beans;
- $this->setMeta('sys.shadow.'.$property,$beans);
- $this->setMeta('tainted',true);
- return $this->properties[$property];
- }
+ $type = (__lcfirst(str_replace('shared','',$property)));
+ $keys = $toolbox->getRedBean()->getAssociationManager()->related($this,$type);
+ if (!count($keys)) $beans = array(); else
+ $beans = $toolbox->getRedBean()->batch($type,$keys);
+ $this->properties[$property] = $beans;
+ $this->setMeta('sys.shadow.'.$property,$beans);
+ $this->setMeta('tainted',true);
+ return $this->properties[$property];
}
return $this->null;
}
@@ -646,7 +632,6 @@ public function isEmpty() {
if ($key=='id') continue;
if (!empty($value)) {
$empty = false;
-
}
}
return $empty;
Please sign in to comment.
Something went wrong with that request. Please try again.