From 5e54e7b55d8474779b0d458e51ba5311b1a42708 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 19 Mar 2010 12:38:14 -0700 Subject: Throw an exception when an undefined method is called on one of our DB_DataObjects, instead of failing silently. The magic __call() method is used to implement a getter and setter interface, and simply didn't bother to throw an error for things it didn't recognize. This may expose a number of existing errors where mistyped method names are called and we're not noticing that they're failing. --- classes/Safe_DataObject.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/classes/Safe_DataObject.php b/classes/Safe_DataObject.php index 08bc6846f..e926cb0d5 100644 --- a/classes/Safe_DataObject.php +++ b/classes/Safe_DataObject.php @@ -96,6 +96,30 @@ class Safe_DataObject extends DB_DataObject $this->_link_loaded = false; } + /** + * Magic function called when someone attempts to call a method + * that doesn't exist. DB_DataObject uses this to implement + * setters and getters for fields, but neglects to throw an error + * when you just misspell an actual method name. This leads to + * silent failures which can cause all kinds of havoc. + * + * @param string $method + * @param array $params + * @return mixed + * @throws Exception + */ + function __call($method, $params) + { + $return = null; + // Yes, that's _call with one underscore, which does the + // actual implementation. + if ($this->_call($method, $params, $return)) { + return $return; + } else { + throw new Exception('Call to undefined method ' . + get_class($this) . '::' . $method); + } + } /** * Work around memory-leak bugs... -- cgit v1.2.3-54-g00ecf From 2097e6a2939a9a5c3f49a4c978ab9c01784943d6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 19 Mar 2010 12:50:34 -0700 Subject: Fix typo in public tag cloud query setup which caused the cutoff to get skipped. --- actions/publictagcloud.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index 9993b2d3f..70c356659 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -109,7 +109,7 @@ class PublictagcloudAction extends Action $cutoff = sprintf("notice_tag.created > '%s'", common_sql_date(time() - common_config('tag', 'cutoff'))); $tags->selectAdd($calc . ' as weight'); - $tags->addWhere($cutoff); + $tags->whereAdd($cutoff); $tags->groupBy('tag'); $tags->orderBy('weight DESC'); -- cgit v1.2.3-54-g00ecf