diff --git a/includes/FeedsBatch.inc b/includes/FeedsBatch.inc index 99d71500b9fc6b743b1c480588fa5c0175aaf1d9..59144c4bf3f3600494e75da1f4853c19e334a3c9 100644 --- a/includes/FeedsBatch.inc +++ b/includes/FeedsBatch.inc @@ -142,6 +142,7 @@ class FeedsBatch { * @see FeedsHTTPBatch */ class FeedsImportBatch extends FeedsBatch { + protected $file_path; protected $title; protected $description; protected $link; @@ -159,6 +160,7 @@ class FeedsImportBatch extends FeedsBatch { FEEDS_PARSING => FEEDS_BATCH_COMPLETE, FEEDS_PROCESSING => FEEDS_BATCH_COMPLETE, ); + $this->file_path = NULL; $this->title = ''; $this->description = ''; $this->link = ''; @@ -189,15 +191,17 @@ class FeedsImportBatch extends FeedsBatch { */ public function getFilePath() { if (!isset($this->file_path)) { - $dir = file_directory_path() .'/feeds'; + $dir = 'public://feeds'; if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { throw new Exception(t('Feeds directory either cannot be created or is not writable.')); } $dest = file_destination($dir . '/' . get_class($this) .'_'. drupal_get_token($this->url) .'_'. time(), FILE_EXISTS_RENAME); - $this->file_path = file_save_data($this->getRaw(), $dest); - if($this->file_path === 0) { + $this->file_path = FALSE; + $file = file_save_data($this->getRaw(), $dest); + if ($file === FALSE) { throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest))); } + $this->file_path = $file->uri; } return $this->file_path; } diff --git a/plugins/FeedsFileFetcher.inc b/plugins/FeedsFileFetcher.inc index 0385458d314e2be09fb6a0e0911a6b628100a8a5..a582671525203edd3e1e1343e5c1ef1bc2f85ce5 100644 --- a/plugins/FeedsFileFetcher.inc +++ b/plugins/FeedsFileFetcher.inc @@ -11,8 +11,6 @@ * FeedsFileFetcher. */ class FeedsFileBatch extends FeedsImportBatch { - protected $file_path; - /** * Constructor. */ @@ -87,8 +85,8 @@ class FeedsFileFetcher extends FeedsFetcher { * Override parent::sourceFormValidate(). */ public function sourceFormValidate(&$values) { - $feed_dir = file_directory_path() .'/feeds'; - file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + $feed_dir = 'public://feeds'; + file_prepare_directory($feed_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); // If there is a file uploaded, save it, otherwise validate input on // file. diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc index a7b0acd3f6e4a7d2e5d040c3cf9d87effc22a198..254f2897ef71eb6b254bde47fb51af72c3d09009 100644 --- a/plugins/FeedsParser.inc +++ b/plugins/FeedsParser.inc @@ -247,7 +247,7 @@ class FeedsEnclosure extends FeedsElement { if(empty($this->file) && $this->getValue()) { // Check if this enclosure contains a local file. if (!parse_url($this->getValue(), PHP_URL_SCHEME)) { - if (file_check_location($this->getValue(), file_directory_path())) { + if (strpos($this->getValue(), 'public://') === 0) { if (file_exists($this->getValue())) { $this->file = $this->getValue(); return $this->file; @@ -265,7 +265,8 @@ class FeedsEnclosure extends FeedsElement { $this->file = copy($this->getValue(), $dest) ? $dest : 0; } else { - $this->file = file_save_data($this->getContent(), $dest); + $file = file_save_data($this->getContent(), $dest); + $this->file = $file ? $file->uri : 0; } if ($this->file === 0) { throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest)));