nextcloud / files_lock

GNU Affero General Public License v3.0
24 stars 8 forks source link

The "*.md" files (Nextcloud Text) are also locked to their owners (NC24 manual file locking feature) #70

Closed Jerome-Herbinet closed 1 year ago

Jerome-Herbinet commented 2 years ago

Hello,

Here is an issue found on Nextcloud NC 24.0.0 with Temporary files lock 24.0.0.

Problem reproduction stage :

  1. Create a text file (.md file after clicking on the [+])
  2. Share the file with another user
  3. Lock the file
  4. The problem : You, as the owner of the file, cannot edit your own file after locking, whereas locking should allow only you to edit the file (and not other users). Here we see that the file is locked for everyone, including you, the creator of the file. Like other users, you will get the following warning message: "This file is opened read-only as it is currently locked by {file owner}."

PS : You will find that the problem remains the same, even if you have not shared the file with anyone.

Unless I had not understood some of the subtleties of the tool, it seems to me that the tool is a bit overzealous.

I remain at your disposal for any further technical information.

Best regards, Jérôme

Jerome-Herbinet commented 2 years ago

Additional information:

It occurs under : Nextcloud 24.0.0 + "Temporary files lock" 24.0.0 + "Text" 3.5.1 It does not occur under : Nextcloud 21.0.9 + "Temporary files lock" 20.1.0 + "Text" 3.2.0 Nextcloud 22.2.7 + "Temporary files lock" 20.1.0 + "Text" 3.3.1 Nextcloud 23.0.4 + "Temporary files lock" 20.1.0 + "Text" 3.4.1

Jerome-Herbinet commented 2 years ago

It is difficult in this story to know whether the problem is with "Temporary Files Lock", "Nextcloud Text" or deeper layers of Nextcloud. Thank you in advance for the time you could give to solve this problem. What's annoying is that this very interesting and relevant feature was really highlighted when Nextcloud 24 was publicly unveiled...

ThibautPlg commented 2 years ago

Hello, while trying to debug this feature with Jérôme, I've come across some issues in the occ command.

When the file is unlocked, there is no problem :

[root@nextcloud](/var/www/html/nextcloud/)# sudo -u nginx php occ files:lock 1213 --status
File #1213 is not locked

But after being locked, the same occ command gives a result then an error :

[root@nextcloud](/var/www/html/nextcloud/)# sudo -u nginx php occ files:lock 1213 --status
File #1213 is locked by user
An unhandled exception has been thrown:
Error: Call to undefined method OCA\FilesLock\Model\FileLock::getCreation() in /var/www/html/nextcloud//apps/files_lock/lib/Command/Lock.php:171
Stack trace:
#0 /var/www/html/nextcloud//apps/files_lock/lib/Command/Lock.php(137): OCA\FilesLock\Command\Lock->getStatus(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 1213)
#1 /var/www/html/nextcloud//3rdparty/symfony/console/Command/Command.php(255): OCA\FilesLock\Command\Lock->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/nextcloud//core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/nextcloud//3rdparty/symfony/console/Application.php(1009): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/nextcloud//3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(OCA\FilesLock\Command\Lock), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/nextcloud//3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/nextcloud/nc24.test.arawar.f/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/nextcloud//console.php(99): OC\Console\Application->run()
#8 /var/www/html/nextcloud//occ(11): require_once('/var/www/html/n...')

Best regards,

hc-compal commented 2 years ago

I found the bug. it can be solved by renaming getCreation() to getCreatedAt() in /var/www/html/nextcloud//apps/files_lock/lib/Command/Lock.php:171

                        $output->writeln(
                                // ' - Locked at: ' . date('c', $lock->getCreation())
                                ' - Locked at: ' . date('c', $lock->getCreatedAt())
                        );