From 34ce75c71d37754fa941233c805c042a47910184 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 27 Aug 2009 20:09:07 -0700 Subject: remove duplicate save of Notice and streamline attachment detection --- classes/Notice.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index e59712864..28d5b8ddf 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -58,7 +58,7 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - /* Notice types */ + /* Notice types */ const LOCAL_PUBLIC = 1; const REMOTE_OMB = 0; const LOCAL_NONPUBLIC = -1; @@ -248,17 +248,6 @@ class Notice extends Memcached_DataObject $notice->saveUrls(); - // FIXME: why do we have to re-render the content? - // Remove this if it's not necessary. - - $orig2 = clone($notice); - - $notice->rendered = common_render_content($final, $notice); - if (!$notice->update($orig2)) { - common_log_db_error($notice, 'UPDATE', __FILE__); - return _('Problem saving notice.'); - } - $notice->query('COMMIT'); Event::handle('EndNoticeSave', array($notice)); -- cgit v1.2.3-54-g00ecf From c0d03fc2799c7b0c57d05166b404a3d13427f497 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 27 Aug 2009 20:23:31 -0700 Subject: make URL analyzer save new info on URLs --- classes/File.php | 8 +++++--- lib/util.php | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'classes') diff --git a/classes/File.php b/classes/File.php index 0cebfc55e..f4d0a3a48 100644 --- a/classes/File.php +++ b/classes/File.php @@ -85,7 +85,7 @@ class File extends Memcached_DataObject return $x; } - function processNew($given_url, $notice_id) { + function processNew($given_url, $notice_id=null) { if (empty($given_url)) return -1; // error, no url to process $given_url = File_redirection::_canonUrl($given_url); if (empty($given_url)) return -1; // error, no url to process @@ -96,7 +96,7 @@ class File extends Memcached_DataObject $redir_data = File_redirection::where($given_url); $redir_url = $redir_data['url']; // TODO: max field length - if ($redir_url === $given_url || strlen($redir_url) > 255) { + if ($redir_url === $given_url || strlen($redir_url) > 255) { $x = File::saveNew($redir_data, $given_url); $file_id = $x->id; } else { @@ -119,7 +119,9 @@ class File extends Memcached_DataObject } } - File_to_post::processNew($file_id, $notice_id); + if (!empty($notice_id)) { + File_to_post::processNew($file_id, $notice_id); + } return $x; } diff --git a/lib/util.php b/lib/util.php index 070b4232c..8a56be55d 100644 --- a/lib/util.php +++ b/lib/util.php @@ -520,7 +520,7 @@ function common_linkify($url) { // functions $url = htmlspecialchars_decode($url); - if(strpos($url, '@')!==false && strpos($url, ':')===false){ + if(strpos($url, '@') !== false && strpos($url, ':') === false) { //url is an email address without the mailto: protocol return XMLStringer::estring('a', array('href' => "mailto:$url", 'rel' => 'external'), $url); } @@ -544,19 +544,24 @@ function common_linkify($url) { // Check to see whether this is a known "attachment" URL. - $localfile = File::staticGet('url', $longurl); + $f = File::staticGet('url', $longurl); - if (!empty($localfile)) { - if (isset($localfile->filename)) { + if (empty($f)) { + // XXX: this writes to the database. :< + $f = File::processNew($longurl); + } + + if (!empty($f)) { + if (isset($f->filename)) { $is_attachment = true; - $attachment_id = $localfile->id; + $attachment_id = $f->id; } else { // if it has OEmbed info, it's an attachment, too - $foe = File_oembed::staticGet('file_id', $localfile->id); + $foe = File_oembed::staticGet('file_id', $f->id); if (!empty($foe)) { $is_attachment = true; - $attachment_id = $localfile->id; + $attachment_id = $f->id; - $thumb = File_thumbnail::staticGet('file_id', $localfile->id); + $thumb = File_thumbnail::staticGet('file_id', $f->id); if (!empty($thumb)) { $has_thumb = true; } -- cgit v1.2.3-54-g00ecf From e277c856d65885a487b4d7f090a10cf817da836a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:00:55 +1200 Subject: fix for SQL error: ERROR: syntax error at or near ")" at character 45 http://laconi.ca/trac/ticket/1735 --- classes/Notice.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 28d5b8ddf..89afe9d1d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -732,6 +732,10 @@ class Notice extends Memcached_DataObject return new ArrayWrapper($notices); } else { $notice = new Notice(); + if (empty($ids)) { + //if no IDs requested, just return the notice object + return $notice; + } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); $notice->orderBy('id DESC'); -- cgit v1.2.3-54-g00ecf From c628029ef124698fe39522a5038af3f3e1a11a26 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 28 Aug 2009 10:42:34 -0700 Subject: Status_network had wrong ini file --- classes/Status_network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Status_network.php b/classes/Status_network.php index d526cb4d6..fe4f0b0c5 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -54,7 +54,7 @@ class Status_network extends DB_DataObject global $config; $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname"; - $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/statusnet.ini'; + $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini'; $config['db']['table_status_network'] = $dbname; self::$cache = new Memcache(); -- cgit v1.2.3-54-g00ecf From efcfd209ef737f4dbe99401df282e7a341176ea7 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 1 Sep 2009 23:02:03 -0400 Subject: Check "Files" of type 'application/xhtml+xml' for oEmbed in addition to just text/html --- classes/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/File.php b/classes/File.php index f4d0a3a48..96a4de6e8 100644 --- a/classes/File.php +++ b/classes/File.php @@ -78,7 +78,7 @@ class File extends Memcached_DataObject $file_id = $x->insert(); if (isset($redir_data['type']) - && ('text/html' === substr($redir_data['type'], 0, 9)) + && (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21))) && ($oembed_data = File_oembed::_getOembed($given_url))) { File_oembed::saveNew($oembed_data, $file_id); } -- cgit v1.2.3-54-g00ecf