aboutsummaryrefslogtreecommitdiff
path: root/classes/File.php
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2016-01-06 19:23:38 +0100
committerMikael Nordfeldth <mmn@hethane.se>2016-01-06 19:24:03 +0100
commitf1c4c64cd976e9026af2aabf1816ffbefaa2414e (patch)
treea237e2d8d9b6a1a536eaaca7befd067370cc7545 /classes/File.php
parent346e34e543be179967a704b813883d4d12784fa2 (diff)
downloadgnu-social-f1c4c64cd976e9026af2aabf1816ffbefaa2414e.tar
gnu-social-f1c4c64cd976e9026af2aabf1816ffbefaa2414e.zip
Don't update stored URLs just because we have a filename
This would overwrite remote URLs with local verisons which removes source href... The reason one might have filenames for remote URLs is that StoreRemoteMedia plugin fetches them and uses the filename field.
Diffstat (limited to 'classes/File.php')
-rw-r--r--classes/File.php18
1 files changed, 4 insertions, 14 deletions
diff --git a/classes/File.php b/classes/File.php
index 99413adbcc..a3ded46ec9 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -55,7 +55,7 @@ class File extends Managed_DataObject
'title' => array('type' => 'text', 'description' => 'title of resource when available'),
'date' => array('type' => 'int', 'description' => 'date of resource according to http query'),
'protected' => array('type' => 'int', 'description' => 'true when URL is private (needs login)'),
- 'filename' => array('type' => 'text', 'description' => 'if a local file, name of the file'),
+ 'filename' => array('type' => 'text', 'description' => 'if file is stored locally (too) this is the filename'),
'width' => array('type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'),
'height' => array('type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'),
@@ -416,21 +416,11 @@ class File extends Managed_DataObject
return $filepath;
}
- public function getUrl()
+ public function getUrl($prefer_local=true)
{
- if (!empty($this->filename)) {
+ if ($prefer_local && !empty($this->filename)) {
// A locally stored file, so let's generate a URL for our instance.
- $url = self::url($this->filename);
- if (self::hashurl($url) !== $this->urlhash) {
- // For indexing purposes, in case we do a lookup on the 'url' field.
- // also we're fixing possible changes from http to https, or paths
- try {
- $this->updateUrl($url);
- } catch (ServerException $e) {
- //
- }
- }
- return $url;
+ return self::url($this->filename);
}
// No local filename available, return the URL we have stored