Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly delete rows in views #826

Merged
merged 4 commits into from
Feb 9, 2024
Merged

fix: properly delete rows in views #826

merged 4 commits into from
Feb 9, 2024

Conversation

enjeck
Copy link
Contributor

@enjeck enjeck commented Feb 7, 2024

This PR fixes an issue with deleting rows in a view.

Steps to reproduce:

  • Create a view with some rows
  • Try to delete any row in the view
Error traces:
master-nextcloud-1  | {"reqId":"Tc9DQHagtkcXkVMZz29Q","level":3,"time":"2024-02-07T11:07:32+00:00","remoteAddr":"192.168.21.5","user":"admin","app":"tables","method":"DELETE","url":"/index.php/apps/tables/view/17/row/522","message":"Array","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"29.0.0.5","data":{"app":"tables"}}
master-nextcloud-1  | {"reqId":"Tc9DQHagtkcXkVMZz29Q","level":3,"time":"2024-02-07T11:07:32+00:00","remoteAddr":"192.168.21.5","user":"admin","app":"tables","method":"DELETE","url":"/index.php/apps/tables/view/17/row/522","message":"Update row is not allowed.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"29.0.0.5","exception":{"Exception":"Exception","Message":"Update row is not allowed.","Code":0,"Trace":[{"file":"/var/www/html/apps/tables/lib/Controller/RowController.php","line":133,"function":"delete","class":"OCA\\Tables\\Service\\RowService","type":"->","args":[522,17,"admin"]},{"file":"/var/www/html/apps/tables/lib/Controller/Errors.php","line":16,"function":"OCA\\Tables\\Controller\\{closure}","class":"OCA\\Tables\\Controller\\RowController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/tables/lib/Controller/RowController.php","line":134,"function":"handleError","class":"OCA\\Tables\\Controller\\RowController","type":"->","args":[["Closure"]]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":232,"function":"destroyByView","class":"OCA\\Tables\\Controller\\RowController","type":"->","args":[522,17]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":138,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Tables\\Controller\\RowController"],"destroyByView"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Tables\\Controller\\RowController"],"destroyByView"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Tables\\Controller\\RowController","destroyByView",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["17","522","tables.row.destroyByView"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/tables/view/17/row/522"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/apps/tables/lib/Service/RowService.php","Line":442,"message":"Update row is not allowed.","exception":{},"CustomMessage":"Update row is not allowed."}}
master-nextcloud-1  | {"reqId":"Tc9DQHagtkcXkVMZz29Q","level":2,"time":"2024-02-07T11:07:32+00:00","remoteAddr":"192.168.21.5","user":"admin","app":"tables","method":"DELETE","url":"/index.php/apps/tables/view/17/row/522","message":"An internal error or exception occurred: OCA\\Tables\\Service\\RowService - delete: Update row is not allowed.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"29.0.0.5","data":{"app":"tables"}}

@enjeck enjeck requested a review from juliusknorr February 7, 2024 14:54
@@ -435,8 +435,7 @@ public function delete(int $id, ?int $viewId, string $userId): Row2 {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage());
}
$rowIds = $this->mapper->getRowIdsOfView($view, $userId);
if(!in_array($id, $rowIds)) {
if(!$this->row2Mapper->isRowInViewPresent($id, $view, $userId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the last usage of $this->mapper so we could drop it from the constructor which makes it one less dependency of the class to resolve

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enjeck Could you check that? Then we can merge this :)

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Looks good and thanks for the test adjustments, small cleanup comment inline, otherwise good to go from my side 👍

@juliusknorr juliusknorr added bug Something isn't working 2. developing Work in progress labels Feb 8, 2024
@juliusknorr
Copy link
Member

Needs one small fix for the php codestyle check. 😉 You can likely autofix that by running composer run cs:fix

Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
@enjeck enjeck force-pushed the fix/delete-view-rows branch from 0656fac to 3cb2614 Compare February 9, 2024 12:53
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
@enjeck enjeck merged commit 5f0b286 into main Feb 9, 2024
46 checks passed
@enjeck enjeck deleted the fix/delete-view-rows branch February 9, 2024 14:37
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress bug Something isn't working feedback-requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants