diff options
author | Eric Helgeson <erichelgeson@gmail.com> | 2009-07-22 10:28:17 -0500 |
---|---|---|
committer | Eric Helgeson <erichelgeson@gmail.com> | 2009-07-22 10:28:17 -0500 |
commit | 829396106495a7b8090c31c383c0119912396cac (patch) | |
tree | 409fce658a5704024cb3d64121392485b2033799 /classes | |
parent | db19d61e68fcf8398579c2c4968e73db7f7ed93b (diff) | |
parent | abae9379478f2b87915930be81cd7be97f12ed8f (diff) |
Merge commit 'origin/0.8.x' into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r-- | classes/File.php | 4 | ||||
-rw-r--r-- | classes/Notice.php | 14 | ||||
-rw-r--r-- | classes/Session.php | 9 |
3 files changed, 15 insertions, 12 deletions
diff --git a/classes/File.php b/classes/File.php index 68d385d1e..0c4fbf7e6 100644 --- a/classes/File.php +++ b/classes/File.php @@ -122,6 +122,7 @@ class File extends Memcached_DataObject } function isRespectsQuota($user,$fileSize) { + if ($fileSize > common_config('attachments', 'file_quota')) { return sprintf(_('No file may be larger than %d bytes ' . 'and the file you sent was %d bytes. Try to upload a smaller version.'), @@ -135,8 +136,7 @@ class File extends Memcached_DataObject if ($total > common_config('attachments', 'user_quota')) { return sprintf(_('A file this large would exceed your user quota of %d bytes.'), common_config('attachments', 'user_quota')); } - - $query .= ' month(modified) = month(now()) and year(modified) = year(now())'; + $query .= ' AND EXTRACT(month FROM file.modified) = EXTRACT(month FROM now()) and EXTRACT(year FROM file.modified) = EXTRACT(year FROM now())'; $this->query($query); $this->fetch(); $total = $this->total + $fileSize; diff --git a/classes/Notice.php b/classes/Notice.php index 101fadb67..7f002d838 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -97,13 +97,21 @@ class Notice extends Memcached_DataObject function saveTags() { /* extract all #hastags */ - $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match); + $count = preg_match_all('/(?:^|\s)#([\pL\pN_\-\.]{1,64})/', strtolower($this->content), $match); if (!$count) { return true; } + + //turn each into their canonical tag + //this is needed to remove dupes before saving e.g. #hash.tag = #hashtag + $hashtags = array(); + for($i=0; $i<count($match[1]); $i++) { + $hashtags[] = common_canonical_tag($match[1][$i]); + } + /* Add them to the database */ - foreach(array_unique($match[1]) as $hashtag) { + foreach(array_unique($hashtags) as $hashtag) { /* elide characters we don't want in the tag */ $this->saveTag($hashtag); } @@ -112,8 +120,6 @@ class Notice extends Memcached_DataObject function saveTag($hashtag) { - $hashtag = common_canonical_tag($hashtag); - $tag = new Notice_tag(); $tag->notice_id = $this->id; $tag->tag = $hashtag; diff --git a/classes/Session.php b/classes/Session.php index 93fd99baa..ac80279c5 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -106,14 +106,11 @@ class Session extends Memcached_DataObject { self::logdeb("garbage collection (maxlifetime = $maxlifetime)"); - $epoch = time() - $maxlifetime; - - $qry = 'DELETE FROM session ' . - 'WHERE modified < "'.$epoch.'"'; + $epoch = common_sql_date(time() - $maxlifetime); $session = new Session(); - - $result = $session->query($qry); + $session->whereAdd('modified < "'.$epoch.'"'); + $result = $session->delete(DB_DATAOBJECT_WHEREADD_ONLY); self::logdeb("garbage collection result = $result"); } |