silverstripe-asset-admin icon indicating copy to clipboard operation
silverstripe-asset-admin copied to clipboard

Upload/Replace Feature is not working as expected.

Open mckinselberg opened this issue 6 years ago • 3 comments

In Silverstripe 4, I have a problem where the upload/replace feature doesn’t automatically update the filename in the ‘filename’ field. If I upload a file with a different name and then update the filename manually, the update is successful. Otherwise, if the filename of the replacement is the same as the replaced, the file seems to upload, but the update is not successful upon publish/save.

Additionally, the upload/replace feature seems to work for files with image extensions, but not for files with document extensions, such as .pdf or .docx.

mckinselberg avatar Dec 07 '18 21:12 mckinselberg

I have just spent ~1h reproducing this.

Setup: CWP 2.2.1 Procedure:

1 [OK] Open a page for editing in the CMS 2 [OK] Highlight some text to link to 3 [OK] Select the "Insert Link" --> "Link to a file" feature of TinyMCE 4 [OK] Select the "Upload" button 5 [OK] Locate a .xlsx file to upload 6 [OK] Select "Insert file" in the assets dialogue that appears 7 [OK] Save the page 8 [OK] Preview and verify you can view/download the desired document 9 [OK] Now select the document link in the admin page view, then select "Edit Link" 10 [OK] Locate the .xlsx file you just uploaded and select it 11 [OK] Select "Details" --> "edit original file" 12 [OK] Select the triple dots icon --> "Replace file" 13 [OK] Find a different .xlsx file with a different filename, and use that for the replacement OR make a change to the same .xlsx file, and re-upload that 14 [OK] Save / Publish the file itself 15 [OK] Navigate to the page preview 16 [OK] Select the link 17 [FAIL] Observe: The old file is still shown

  1. Repeat for a .pdf file, which works as expected.
  2. Repeat for a .docx file, which works as expected.
  3. Repeat for a .png file, which works as expected.

Other:

If I change the editable "Filename" field, I am now unable to "Save" or "Publish" the file. The buttons stay highlighted as green, instead of changing. No console error, no AJAX 5xx error.

phptek avatar Mar 31 '19 21:03 phptek

@chillu if @mckinselberg and I are talking about the same issue:

Additionally, the upload/replace feature seems to work for files with image extensions, but not for files with document extensions, such as .pdf or .docx.

...then I'd suggest removing the UI-specific tags or the addition of more relevant tags as this doesn't appear to be just a UI issue, unless of course we think that a ReactJS bug counts as "frontend" or "ui".

UPDATE:

Weird..sometimes I can repro on "raw" setups, sometimes I can't. For the record, he are my findings:

Simplest reproduction steps:

  • PHP 7.1
  • Plain cwp/cwp-installer 2.2.3

Issue 1: Misleading UX Pathway

  • [OK] Login and navigate to "About us"
  • [OK] Highlight a word in TinyMCE
  • [OK] Select "Insert Link" --> "Link to a file"
  • [OK] Select "Upload" and locate a *.xlsx file from your F/S
  • [OK] Select "Insert File"
  • [OK] Select the page's "Save" button
  • [OK] Select the page's link to full-page preview
  • [OK] Observe the appropriate text is linked, the correct document metadata is shown, and on clicking the link, observe that the document is the one you uploaded
  • [OK] Go back to the CMS and open the same page for editing again
  • [OK] Select the same text from above, and select "Edit Link" in the context menu
  • [OK] Go directly to the "Upload" link
  • [OK] Locate a different *.xlsx file from your F/S
  • [OK] Select the "Update file" button in the RHS asset pane
  • [OK] Press "Save" in the page edit pane
  • [OK] Refresh the full page preview
  • [FAIL] (Obviously) Observe the appropriate text is linked, the correct replacement document metadata is shown, and on clicking the link, observe that the replaced document is the one you uploaded

Issue 2: "Replace File" Feature won't always work

  • [OK] Login and navigate to "About us"
  • [OK] Highlight a word in TinyMCE
  • [OK] Select "Insert Link" --> "Link to a file"
  • [OK] Select "Upload" and locate a *.txt file from your F/S
  • [OK] Select "Insert File"
  • [OK] Select the page's "Save" button
  • [OK] Select the page's link to full-page preview
  • [OK] Observe the appropriate text is linked, the correct document metadata is shown, and on clicking the link, observe that the document is the one you uploaded
  • [OK] Go back to the CMS and open the same page for editing again
  • [OK] Select the same text from above, and select "Edit Link" in the context menu
  • [OK] Select the "Edit original file button/control" in the RHS asset pane
  • [OK] Now select the "dot dot dot" control --> "Replace file"
  • [OK] Locate a different file with a different file-suffix, e.g. .xlsx from your F/S
  • [OK] Select the "Save" button in the RHS asset pane
  • [FAIL] Inconsistent! :-( Sometimes the "Save" button does not change colour, neither does the "Filename" field change its value.
  • [OK] Press "Save" in the page edit pane
  • [OK] Refresh the full page preview
  • [FAIL] Inconsistent! :-( Sometimes the metadata, and file-link will update, sometimes not....

I just spent another ~1h on this, and I could reproduce this sometimes on a plain 4.3.3 silverstripe/installer site, and a plain CWP 2.2.3 site.

phptek avatar Apr 01 '19 20:04 phptek

We're seeing the Replace feature not working reliably on latest 4.4.1.

The assets admin indicates the content is updated, but accessing the file via a URL or inspecting it directly from the filesystem, it presents the content of the file prior to replacing it.

michalkleiner avatar Jul 23 '19 05:07 michalkleiner