X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FFile.php;h=1a29ea5107e537dec350188c4b7b323e523b2e76;hb=be0c10e8f6f9c60b1cb840cda9ac6f42c8289738;hp=1cb7eab6b856c203e6023d79e72cb98415fe538f;hpb=1d85fd35a2330a430e91a8b67b832bc2a23130d4;p=quix0rs-gnu-social.git diff --git a/classes/File.php b/classes/File.php index 1cb7eab6b8..1a29ea5107 100644 --- a/classes/File.php +++ b/classes/File.php @@ -116,14 +116,14 @@ class File extends Managed_DataObject * * @fixme refactor this mess, it's gotten pretty scary. * @param string $given_url the URL we're looking at - * @param int $notice_id (optional) + * @param Notice $notice (optional) * @param bool $followRedirects defaults to true * * @return mixed File on success, -1 on some errors * * @throws ServerException on failure */ - public static function processNew($given_url, $notice_id=null, $followRedirects=true) { + public static function processNew($given_url, Notice $notice=null, $followRedirects=true) { if (empty($given_url)) { throw new ServerException('No given URL to process'); } @@ -181,7 +181,7 @@ class File extends Managed_DataObject // // Seen in the wild with clojure.org, which redirects through // wikispaces for auth and appends session data in the URL params. - $file = self::processNew($redir_url, $notice_id, /*followRedirects*/false); + $file = self::processNew($redir_url, $notice, /*followRedirects*/false); File_redirection::saveNew($redir_data, $file->id, $given_url); } @@ -193,8 +193,8 @@ class File extends Managed_DataObject } } - if (!empty($notice_id)) { - File_to_post::processNew($file->id, $notice_id); + if ($notice instanceof Notice) { + File_to_post::processNew($file, $notice); } return $file; } @@ -488,13 +488,13 @@ class File extends Managed_DataObject throw new ServerException('URL already exists in DB'); } $sql = 'UPDATE %1$s SET urlhash=%2$s, url=%3$s WHERE urlhash=%4$s;'; - $result = $this->query(sprintf($sql, $this->__table, + $result = $this->query(sprintf($sql, $this->tableName(), $this->_quote((string)self::hashurl($url)), $this->_quote((string)$url), $this->_quote((string)$this->urlhash))); if ($result === false) { common_log_db_error($this, 'UPDATE', __FILE__); - throw new ServerException("Could not UPDATE {$this->__table}.url"); + throw new ServerException("Could not UPDATE {$this->tableName()}.url"); } return $result; @@ -510,9 +510,9 @@ class File extends Managed_DataObject function blowCache($last=false) { - self::blow('file:notice-ids:%s', $this->urlhash); + self::blow('file:notice-ids:%s', $this->id); if ($last) { - self::blow('file:notice-ids:%s;last', $this->urlhash); + self::blow('file:notice-ids:%s;last', $this->id); } self::blow('file:notice-count:%d', $this->id); }