Referencing to the file used in the field is not allowed

После обновления безопасности модуля FileField до версии 6.x-3.13 вылетает ошибка при сохранении нод в админке, с филдами файлов.

Полный тред можно почитать по ссылке https://www.drupal.org/node/2305969 .

У меня заработало с патчем filefield-2305969-39-fix-predicate-with-19.patch #40.

diff --git a/filefield.module b/filefield.module
--- a/filefield.module
+++ b/filefield.module
@@ -191,9 +191,10 @@ function filefield_file_download($filepath) {
           // If revision is the current revision, grant access.
           $revision_access = TRUE;
         }
-        elseif (!$denied && $revision_node = node_load($content['nid'], $revision_id) && _node_revision_access($revision_node, 'view')) {
+        elseif (!$denied) {
+          $revision_node = node_load($content['nid'], $revision_id);
           // You have access to the node as well as that particular revision.
-          $revision_access = TRUE;
+          $revision_access = _node_revision_access($revision_node, 'view');
         }
 
         // If node access denied, skip other revisions; or if we have node
diff --git a/filefield_widget.inc b/filefield_widget.inc
--- a/filefield_widget.inc
+++ b/filefield_widget.inc
@@ -381,7 +381,7 @@ function filefield_widget_process($element, $edit, &$form_state, $form) {
   );
 
   if ($item['fid'] != 0) {
-    if (function_exists('file_download_access') && $item['status'] && !file_download_access($item['filepath'])) {
+    if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE && function_exists('file_download_access') && $item['status'] && !file_download_access($item['filepath'])) {
       $element['preview'] = array(
         '#type' => 'markup',
         '#value' => t('Access denied'),
@@ -466,7 +466,7 @@ function filefield_widget_validate(&$element, &$form_state) {
     if ($file = field_file_load($element['fid']['#value'])) {
       $file = (object) $file;
       if ($file->status == FILE_STATUS_PERMANENT) {
-        if (field_file_references($file) == 0 || (function_exists('file_download_access') && !file_download_access($file->filepath))) {
+        if (field_file_references($file) == 0 || (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE && function_exists('file_download_access') && !file_download_access($file->filepath))) {
           form_error($element, t('Referencing to the file used in the %field field is not allowed.', array('%field' => $element['#title'])));
         }
       }

Комментарии

Добавить комментарий