server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: Comments attached to the wrong file if details sidebar left open

Open carpediem-av opened this issue 1 year ago • 11 comments

⚠️ This issue respects the following points: ⚠️

Bug description

I discovered the following bug in Nextcloud v28.0.1. Steps to reproduce the bug:

  1. Open the Activities tab for the PDF file and leave a comment.
  2. Without closing the Activities tab, close the PDF viewer.
  3. Open another PDF file from the same folder and try to leave a comment. The comment is not left, but is included in the list of comments in the first file. This bug already existed before in older versions (approximately in versions 17-20), and now you have introduced it again. This is very sad, my users wrote dozens of comments to the wrong files, all the work was ruined.

Steps to reproduce

  1. Open the Activities tab for the PDF file and leave a comment.
  2. Without closing the Activities tab, close the PDF viewer.
  3. Open another PDF file from the same folder and try to leave a comment. The comment is not left, but is included in the list of comments in the first file.

Expected behavior

The comment should have been left on the second file

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • [X] Default user-backend (database)
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

carpediem-av avatar Jan 31 '24 16:01 carpediem-av

  • Reproduced
  • Also reported on the forum: https://help.nextcloud.com/t/what-happened-to-file-comments/179964/3

joshtrichards avatar Feb 01 '24 13:02 joshtrichards

I don't know if further debugging help is needed here, but I did a little. The problem is certainly in the Javascript for the website.

After checking the POST request for adding comments, I see it has the wrong ID: I add a comment to a file with ID 148264 in the database. The website makes a post request to https:// ... /remote.php/dav/comments/files/148254. The file as listed in the browser has the apparently the correct ID data-cy-files-list-row-fileid="148264" in its HTML:

<tr data-cy-files-list-row="" data-cy-files-list-row-fileid="148264" data-cy-files-list-row-name="Monger, 4Q216 and the Jubilees Creation Account.pdf" draggable="true" class="files-list__row" index="1">

<!----> <td class="files-list__row-checkbox"><span data-v-87511acb="" class="checkbox-radio-switch checkbox-radio-switch-checkbox" style="--icon-size: 24px;"><input data-v-87511acb="" id="checkbox-radio-switch-lwbhm" aria-label="Toggle selection for file &quot;Monger, 4Q216 and the Jubilees Creation Account.pdf&quot;" type="checkbox" class="checkbox-radio-switch__input" value=""><label data-v-bc42acb7="" data-v-87511acb="" for="checkbox-radio-switch-lwbhm" class="checkbox-content checkbox-radio-switch__content checkbox-content-checkbox"><span data-v-bc42acb7="" aria-hidden="true" class="checkbox-content__icon checkbox-radio-switch__icon"><span data-v-bc42acb7="" aria-hidden="true" role="img" class="material-design-icon checkbox-blank-outline-icon"><svg fill="currentColor" width="24" height="24" viewBox="0 0 24 24" class="material-design-icon__svg"><path d="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z"><!----></path></svg></span></span><span data-v-bc42acb7="" class="checkbox-content__text checkbox-radio-switch__text"></span></label></span></td> <td data-cy-files-list-row-name="" class="files-list__row-name"><span class="files-list__row-icon"><img alt="" loading="lazy" src="https://share.qumran-digital.org/index.php/core/preview?fileId=148264&amp;x=32&amp;y=32&amp;mimeFallback=true&amp;a=0" class="files-list__row-icon-preview files-list__row-icon-preview--loaded"> <!----> <!----></span> <a data-cy-files-list-row-name-link="" title="View" tabindex="0" class="files-list__row-name-link" role="button"><span class="files-list__row-name-text"><span class="files-list__row-name-">Monger, 4Q216 and the Jubilees Creation Account</span> <span class="files-list__row-name-ext">.pdf</span></span></a></td> <td data-v-3daa457a="" data-cy-files-list-row-actions="" class="files-list__row-actions files-list__row-actions--482749712"> <div data-v-377272aa="" data-v-3daa457a="" class="action-items action-item--tertiary"><button data-v-8f4e0666="" data-v-377272aa="" aria-label="" type="button" data-cy-files-list-row-action="sharing-status" title="Show sharing options" class="button-vue button-vue--icon-only button-vue--vue-tertiary action-item action-item--single files-list__row-action-sharing-status"><span data-v-8f4e0666="" class="button-vue__wrapper"><span data-v-8f4e0666="" aria-hidden="true" class="button-vue__icon"><span data-v-6176f396="" data-v-3daa457a="" role="img" aria-hidden="true" class="icon-vue" data-v-8f4e0666=""><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M15,14C12.33,14 7,15.33 7,18V20H23V18C23,15.33 17.67,14 15,14M6,10V7H4V10H1V12H4V15H6V12H9V10M15,12A4,4 0 0,0 19,8A4,4 0 0,0 15,4A4,4 0 0,0 11,8A4,4 0 0,0 15,12Z"></path></svg></span></span></span></button><div data-v-377272aa="" class="action-item"><div data-v-377272aa="" class="v-popper v-popper--theme-dropdown"><button data-v-8f4e0666="" data-v-377272aa="" aria-label="Actions" type="button" aria-haspopup="menu" aria-expanded="false" class="button-vue button-vue--icon-only button-vue--vue-tertiary action-item__menutoggle"><span data-v-8f4e0666="" class="button-vue__wrapper"><span data-v-8f4e0666="" aria-hidden="true" class="button-vue__icon"><span data-v-377272aa="" aria-hidden="true" role="img" class="material-design-icon dots-horizontal-icon" data-v-8f4e0666=""><svg fill="currentColor" width="20" height="20" viewBox="0 0 24 24" class="material-design-icon__svg"><path d="M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z"><!----></path></svg></span></span></span></button></div></div></div></td> <td data-cy-files-list-row-size="" class="files-list__row-size" style="color: color-mix(in srgb, var(--color-main-text) 1%, var(--color-text-maxcontrast));"><span>906 KB</span></td> <td data-cy-files-list-row-mtime="" class="files-list__row-mtime" style="color: color-mix(in srgb, var(--color-main-text) 95%, var(--color-text-maxcontrast));"><span data-timestamp="Wed Jan 31 2024 23:22:58 GMT+0100 (Central European Standard Time)" title="31.01.24, 23:22:58" class="nc-datetime">vorgestern</span></td> </tr>

I did not test further yet, but I would note that the ID in the POST request (148254) is the ID of the file directly before the file I am trying to comment on.

Bronson-Brown-deVost avatar Feb 02 '24 14:02 Bronson-Brown-deVost

I did a test on another file and the comment was again POSTed to https:// ... /remote.php/dav/comments/files/148254 even though the file I commented on has an ID of 148279.

I notice that 148254 is ID of the first file in my list of files.

I am using: Nextcloud v28.0.2 Postgres 14.10 Apache with PHP 8.1

Bronson-Brown-deVost avatar Feb 02 '24 14:02 Bronson-Brown-deVost

  • Reproduced

    • Also reported on the forum: https://help.nextcloud.com/t/what-happened-to-file-comments/179964/3

Thank you for linking this. We have many other issues with the comments, hopefully they will be fixed as well soon. See forum

nikobe123 avatar Feb 02 '24 14:02 nikobe123

It's sad to see that a serious bug has not yet been fixed by the developer. Apparently I need to take matters into my own hands. I'm not a developer and I don't know much about web development. I did this in the Sidebar.vue file to fix the bug:

line 467:	async open(path) {
			//!!! BUGFIX >>>
			this.close();
			//!!! BUGFIX <<<
			
			if (!path || path.trim() === '') {
				throw new Error(`Invalid path '${path}'`)
			}

			// Only focus the tab when the selected file/tab is changed in already opened sidebar
			// Focusing the sidebar on first file open is handled by NcAppSidebar
			const focusTabAfterLoad = !!this.Sidebar.file

			// update current opened file
			this.Sidebar.file = path

			// reset data, keep old fileInfo to not reload all tabs and just hide them
			this.error = null
			this.loading = true

			try {
				this.fileInfo = await FileInfo(this.davPath)
				// adding this as fallback because other apps expect it
				this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')

				// DEPRECATED legacy views
				// TODO: remove
				this.views.forEach(view => {
					view.setFileInfo(this.fileInfo)
				})

				await this.$nextTick()

				this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)

				this.loading = false

				await this.$nextTick()

				if (focusTabAfterLoad) {
					this.$refs.sidebar.focusActiveTabContent()
				}
			} catch (error) {
				this.loading = false
				this.error = t('files', 'Error while loading the file data')
				console.error('Error while loading the file data', error)

				throw new Error(error)
			}
		},

The decision is controversial, but now comments are published on the correct files.

carpediem-av avatar Mar 19 '24 20:03 carpediem-av

This bug happens not only in Nextcloud 28 but also in Nextcloud 29.0.4

PW-RTR avatar Jul 19 '24 08:07 PW-RTR

Cc @susnux does https://github.com/nextcloud/server/pull/44868 fix this?

solracsf avatar Jul 29 '24 09:07 solracsf