This problem just started ocurring after updating from 2.41 to 2.42 on Pantheon.

We had just installed OA2 (2.41) on Pantheon last week, but haven't done much with it yet. Then we upgraded to 2.42 this morning using the Pantheon dashboard.

Since the upgrade to 2.42, we cannot add any files to a Files section.

Here are the steps we took and the errors we see:

  1. Create a new Files section in a space
  2. Create 1 or more folders
  3. Click the gear icon next to a folder and select add file
  4. Drag & drop a jpg file into the file upload tab and click the "Start Upload" button and wait for the upload to complete
  5. Click the Next button
  6. The screen that allows you to set the title on the uploaded file comes up blank, not listing any files.
  7. Click the Process button
  8. Receive the following errors:
    Notice: Undefined index: documents in oa_files_upload_create_documents_form_submit() (line 287 of /srv/bindings/02c53c422f984dfba0ed082d43b4aae3/code/profiles/openatrium/modules/apps/oa_files/oa_files.module).
    
    Warning: Invalid argument supplied for foreach() in oa_files_upload_create_documents_form_submit() (line 287 of /srv/bindings/02c53c422f984dfba0ed082d43b4aae3/code/profiles/openatrium/modules/apps/oa_files/oa_files.module).

Comments

mpotter’s picture

Status: Active » Postponed (maintainer needs more info)

Sounds like maybe something happened during the update. Did you follow the upgrade procedure and run updates and also revert Features? I am not able to reproduce this on our sites here.

Seems like one of the tricky bits on Pantheon is that it doesn't automatically revert any features, so you might need to do that from the UI. I think the problem is the feature is still looking for a news section instead of the new document section.

shawn_smiley’s picture

I did run update.php and also reverted all features via the UI before creating the new Files section.

We don't have any production content in our new OA instance yet so I may just wipe the DB and reinstall to see if that resolves the problem.

hefox’s picture

Do you have file permissions set up correctly to allow adding files? It looks like it's getting to stage to create document stage without any files. Does media dialogue work for you in other settings (e.g. adding files via field on node/add/oa-wiki-page)?

shawn_smiley’s picture

Wiping the DB, clearing the files directory, and reinstalling didn't solve the error. :-(

I am able to upload files so it doesn't seem to be a permissions issue. For example, I can upload banner images for the space.

hefox’s picture

Are there any additional errors? The document one is bit of a red herring -- it's in submit, but the issue is the form never gets a list of files. If can observe network traffic (using developer tools), what does the full path akin to: oa-files/upload/multi/[NUMBERSSS]/js-return?render=oa-files-popup&menu_parent=[SOME NUMBER] look like?

shawn_smiley’s picture

Here is what I've been able to determine:

No other errors, warnings, or messages are logged/displayed.

The above error also occurs when selecting an existing image from the Media library (uploaded via /admin/content/file).

shawn_smiley’s picture

Also note that things do work correctly if I create a "Document" rather than a "File" in the File section. So I can attach files as documents and just uncheck the "Show page instead of file?" checkbox.

hefox’s picture

So the key url is
https://oa2.example.com/oa-files/upload/multi/97+/js-return

What happens when you visit that url directly?

  $items['oa-files/upload/multi/%oa_files_upload_multi'] = array(
    'title' => 'Create & Update Documents',
    'page callback' => 'oa_files_upload_create_documents_form_page',
    'page arguments' => array(3),
    'access callback' => 'node_access',
    'access arguments' => array('create', 'oa_wiki_page'),
    'theme callback' => 'media_dialog_get_theme_name',
  );

...
function oa_files_upload_multi_load($fids) {
  return file_load_multiple(explode(' ', $fids));
}
..

function oa_files_upload_create_documents_form_page($files) {
  ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    'title' => t('Add files'),
    'build_info' => array(
      'args' => array(
        $files,
      ),
    ),
    'no_redirect' => TRUE,
  );
...
/**
 * Form callback; Create multiple documents.
 */
function oa_files_upload_create_documents_form($form, &$form_state, $files) {
  $form = array();
  $form['documents'] = array(
    '#tree' => TRUE,
    '#theme' => 'table',
    '#header' => array(t('File Name'), t('Update'), t('Title')),
    '#rows' => array(),
    '#sticky' => FALSE,
  );
  $form['#files'] = $files;
 ...
  $has_update = FALSE;
  foreach ($files as $fid => $file) {
    // Just be sure they have access in case URL manipulation.
    if (!file_entity_access('view', $file)) {
   
      continue;
    }

These are the relevant code segments

Does the user have ability to view file 97? Is $files getting passed to the form correctly?

shawn_smiley’s picture

StatusFileSize
new6.6 KB

So the call to https://oa2.example.com/oa-files/upload/multi/97+/js-return returns the following HTML (see attached screenshot).

<form action="/oa-files/upload/multi/98+/js-return?render=oa-files-popup&amp;menu_parent=27" method="post" id="oa-files-upload-create-documents-form" accept-charset="UTF-8" role="form"><div><div class=""><table class="table table-striped table-bordered">
 <tr><th>File Name</th><th>Title</th></tr>
</table>
</div><input type="submit" id="edit-create" name="op" value="Process" class="form-submit btn btn-default" /><input type="hidden" name="form_build_id" value="form-i2M7HqMANRlmZ18B3blN1x7qpDHIjENoZhRrjt5E0mE" />
<input type="hidden" name="form_token" value="d6C-P65lKVmvpbO56ZkMPI1d6GPOkY6hjZeiLp2T17g" />
<input type="hidden" name="form_id" value="oa_files_upload_create_documents_form" />
</div></form>

Going to /file/97, does return the uploaded image.

I'll have to download/setup the site locally in order to dig into the actual form submission data with a debugger. I'll post more once I've done that.

I'm testing all of this as a user with full admin permissions on the site.

bdselves’s picture

StatusFileSize
new221.85 KB

I am also seeing the same issue on 2.42 as shown in the screen shot above (Screen Shot 2015-06-25 at 2.12.43 PM.png). I've tried a fresh install on Pantheon and set up a directory in the 'Files & Folders' area and tried uploading a file. Please see the attached screen shot to show the error notice. Thanks.

mpotter’s picture

Status: Postponed (maintainer needs more info) » Active

I have reproduced this on Pantheon. We are investigating.

hefox’s picture

Version: 7.x-2.42 » 7.x-2.x-dev
Status: Active » Fixed

So.. on my local and our development server, /oa-files/upload/multi/70+/js-return gets changed to /oa-files/upload/multi/70 /js-return and so we were checking for fids based on exploding on empty string. this isn't the case on pantheon.

Changed it to both check for + and ' '. Not sure what causes this (server config? pantheon patch?)

bdselves’s picture

Hi Hefox,
Could you elaborate please on what you did to fix this.
Thank you.

hefox’s picture

I commited a fix for it to oa_files module

bdselves’s picture

Thanks for your help - I am a bit new to this but can now see the commit :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.