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

Can't erase table #1188

Closed
barbayellow opened this issue Jul 9, 2024 · 14 comments · Fixed by #1196
Closed

Can't erase table #1188

barbayellow opened this issue Jul 9, 2024 · 14 comments · Fixed by #1196
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working

Comments

@barbayellow
Copy link

barbayellow commented Jul 9, 2024

Steps to reproduce

  1. Create a table using web interface
  2. Try to erase it using occ:tables:erase id
  3. Get an error : OCA\Tables\Db\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\Tables\Db\Column, null given
  4. Can't create any more tables

Expected behavior

The table should be erased and new tables should be able to be created

Actual behavior

When trying to erase a table using using occ:tables:erase tableid, I get stuck with an error :
OCA\Tables\Db\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\Tables\Db\Column, null given

Tables app version

0.7.4

Browser

Firefox 127.0.2

Client operating system

Linux Elementary OS

Operating system

Ubuntu 20.04.6 LTS

Web server

Apache

PHP engine version

PHP 8.1

Database

MySQL

Additional info

No response

@barbayellow barbayellow added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Jul 9, 2024
@blizzz
Copy link
Member

blizzz commented Jul 10, 2024

@barbayellow could you provide the complete log line please? There should be a stack trace.

@barbayellow
Copy link
Author

barbayellow commented Jul 10, 2024

Here is the full output:

root@hostname:/var/www/nextcloud# sudo -u www-data php occ tables:remove 2

An unhandled exception has been thrown:
TypeError: OCA\Tables\Db\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\Tables\Db\Column, null given, called in /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php on line 286 and defined in /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php:310
Stack trace:
#0 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(286): OCA\Tables\Db\Row2Mapper->getFilterExpression()
#1 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(263): OCA\Tables\Db\Row2Mapper->getFilter()
#2 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(241): OCA\Tables\Db\Row2Mapper->getFilterGroups()
#3 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(143): OCA\Tables\Db\Row2Mapper->addFilterToQuery()
#4 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(825): OCA\Tables\Db\Row2Mapper->getWantedRowIds()
#5 /var/www/nextcloud/apps/tables/lib/Service/RowService.php(535): OCA\Tables\Db\Row2Mapper->countRowsForView()
#6 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(413): OCA\Tables\Service\RowService->getViewRowsCount()
#7 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(90): OCA\Tables\Service\ViewService->enhanceView()
#8 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(462): OCA\Tables\Service\ViewService->findAll()
#9 /var/www/nextcloud/apps/tables/lib/Service/TableService.php(420): OCA\Tables\Service\ViewService->deleteAllByTable()
#10 /var/www/nextcloud/apps/tables/lib/Command/RemoveTable.php(67): OCA\Tables\Service\TableService->delete()
#11 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OCA\Tables\Command\RemoveTable->execute()
#12 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run()
#13 /var/www/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#14 /var/www/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#15 /var/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#16 /var/www/nextcloud/console.php(100): OC\Console\Application->run()
#17 /var/www/nextcloud/occ(11): require_once('...')

@blizzz
Copy link
Member

blizzz commented Jul 12, 2024

@barbayellow thank you for reporting =)

Quick fix in #1196

@barbayellow
Copy link
Author

Hi thx for the fix. I applied it manually (wget the modified files directly on github + change owner and rights afterwards on our nextcloud instance). Unfortunately, I still have the same error :

sudo -u www-data php /var/www/nextcloud/occ tables:remove 2
An unhandled exception has been thrown:
TypeError: OCA\Tables\Db\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\Tables\Db\Column, null given, called in /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php on line 286 and defined in /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php:310
Stack trace:
#0 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(286): OCA\Tables\Db\Row2Mapper->getFilterExpression()
#1 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(263): OCA\Tables\Db\Row2Mapper->getFilter()
#2 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(241): OCA\Tables\Db\Row2Mapper->getFilterGroups()
#3 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(143): OCA\Tables\Db\Row2Mapper->addFilterToQuery()
#4 /var/www/nextcloud/apps/tables/lib/Db/Row2Mapper.php(825): OCA\Tables\Db\Row2Mapper->getWantedRowIds()
#5 /var/www/nextcloud/apps/tables/lib/Service/RowService.php(535): OCA\Tables\Db\Row2Mapper->countRowsForView()
#6 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(413): OCA\Tables\Service\RowService->getViewRowsCount()
#7 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(90): OCA\Tables\Service\ViewService->enhanceView()
#8 /var/www/nextcloud/apps/tables/lib/Service/ViewService.php(462): OCA\Tables\Service\ViewService->findAll()
#9 /var/www/nextcloud/apps/tables/lib/Service/TableService.php(420): OCA\Tables\Service\ViewService->deleteAllByTable()
#10 /var/www/nextcloud/apps/tables/lib/Command/RemoveTable.php(67): OCA\Tables\Service\TableService->delete()
#11 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OCA\Tables\Command\RemoveTable->execute()
#12 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run()
#13 /var/www/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#14 /var/www/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#15 /var/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#16 /var/www/nextcloud/console.php(100): OC\Console\Application->run()
#17 /var/www/nextcloud/occ(11): require_once('...')

Hope it helps.

@blizzz
Copy link
Member

blizzz commented Jul 15, 2024

@barbayellow May I ask how you replaced the files? Also, would you be comfortable running a database query?

@PlaryWasTaken
Copy link

@blizzz I could run a database query, just had this problem happen to me, some users are now unable to load tables and im unable to delete these affected tables

@PlaryWasTaken
Copy link

PlaryWasTaken commented Jul 16, 2024

Here's the error log when trying to access:
{"reqId":"IWQUKugpKOnrxoovMdpp","level":3,"time":"2024-07-16T16:54:53+00:00","remoteAddr":"x.x.x.x","user":"admin","app":"index","method":"GET","url":"/apps/tables/view","message":"OCA\\Tables\\Db\\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\\Tables\\Db\\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286 in file '/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php' line 310","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0","version":"29.0.3.4","exception":{"Exception":"Exception","Message":"OCA\\Tables\\Db\\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\\Tables\\Db\\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286 in file '/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php' line 310","Code":0,"Trace":[{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Tables\\Controller\\ViewController"],"indexSharedWithMe"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":338,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Tables\\Controller\\ViewController","indexSharedWithMe",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["tables.view.indexsharedwithme"]]},{"file":"/var/www/html/lib/base.php","line":1050,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/tables/view"]},{"file":"/var/www/html/index.php","line":49,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","Line":170,"Previous":{"Exception":"TypeError","Message":"OCA\\Tables\\Db\\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\\Tables\\Db\\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","line":286,"function":"getFilterExpression","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":[["OC\\DB\\QueryBuilder\\QueryBuilder"],null,null,""]},{"file":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","line":263,"function":"getFilter","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":[["OC\\DB\\QueryBuilder\\QueryBuilder"],[[null,null,""]]]},{"file":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","line":241,"function":"getFilterGroups","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":[["OC\\DB\\QueryBuilder\\QueryBuilder"],[[[null,null,""]]]]},{"file":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","line":143,"function":"addFilterToQuery","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":[["OC\\DB\\QueryBuilder\\QueryBuilder"],[[[null,null,""]]],"admin"]},{"file":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","line":825,"function":"getWantedRowIds","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":["admin",3,[[[null,null,""]]]]},{"file":"/var/www/html/custom_apps/tables/lib/Service/RowService.php","line":535,"function":"countRowsForView","class":"OCA\\Tables\\Db\\Row2Mapper","type":"->","args":[["OCA\\Tables\\Db\\View",4],"admin",[["OCA\\Tables\\Db\\Column",14],["OCA\\Tables\\Db\\Column",15],["OCA\\Tables\\Db\\Column",16],["OCA\\Tables\\Db\\Column",17],["OCA\\Tables\\Db\\Column",18]]]},{"file":"/var/www/html/custom_apps/tables/lib/Service/ViewService.php","line":413,"function":"getViewRowsCount","class":"OCA\\Tables\\Service\\RowService","type":"->","args":[["OCA\\Tables\\Db\\View",4],"admin"]},{"file":"/var/www/html/custom_apps/tables/lib/Service/ViewService.php","line":139,"function":"enhanceView","class":"OCA\\Tables\\Service\\ViewService","type":"->","args":[["OCA\\Tables\\Db\\View",4],"admin"]},{"file":"/var/www/html/custom_apps/tables/lib/Service/ViewService.php","line":171,"function":"find","class":"OCA\\Tables\\Service\\ViewService","type":"->","args":[4,false,"admin"]},{"file":"/var/www/html/custom_apps/tables/lib/Controller/ViewController.php","line":62,"function":"findSharedViewsWithMe","class":"OCA\\Tables\\Service\\ViewService","type":"->","args":["admin"]},{"file":"/var/www/html/custom_apps/tables/lib/Controller/Errors.php","line":16,"function":"OCA\\Tables\\Controller\\{closure}","class":"OCA\\Tables\\Controller\\ViewController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/custom_apps/tables/lib/Controller/ViewController.php","line":61,"function":"handleError","class":"OCA\\Tables\\Controller\\ViewController","type":"->","args":[["Closure"]]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":232,"function":"indexSharedWithMe","class":"OCA\\Tables\\Controller\\ViewController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":138,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Tables\\Controller\\ViewController"],"indexSharedWithMe"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Tables\\Controller\\ViewController"],"indexSharedWithMe"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":338,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Tables\\Controller\\ViewController","indexSharedWithMe",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["tables.view.indexsharedwithme"]]},{"file":"/var/www/html/lib/base.php","line":1050,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/tables/view"]},{"file":"/var/www/html/index.php","line":49,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php","Line":310},"message":"OCA\\Tables\\Db\\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\\Tables\\Db\\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286 in file '/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php' line 310","exception":[],"CustomMessage":"OCA\\Tables\\Db\\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\\Tables\\Db\\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286 in file '/var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php' line 310"},"id":"6696a74ae2040"}
And when trying to remove directly with occ:

An unhandled exception has been thrown:
TypeError: OCA\Tables\Db\Row2Mapper::getFilterExpression(): Argument #2 ($column) must be of type OCA\Tables\Db\Column, null given, called in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php on line 286 and defined in /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php:310
Stack trace:
#0 /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php(286): OCA\Tables\Db\Row2Mapper->getFilterExpression(Object(OC\DB\QueryBuilder\QueryBuilder), NULL, NULL, '')
#1 /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php(263): OCA\Tables\Db\Row2Mapper->getFilter(Object(OC\DB\QueryBuilder\QueryBuilder), Array)
#2 /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php(241): OCA\Tables\Db\Row2Mapper->getFilterGroups(Object(OC\DB\QueryBuilder\QueryBuilder), Array)
#3 /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php(143): OCA\Tables\Db\Row2Mapper->addFilterToQuery(Object(OC\DB\QueryBuilder\QueryBuilder), Array, '')
#4 /var/www/html/custom_apps/tables/lib/Db/Row2Mapper.php(825): OCA\Tables\Db\Row2Mapper->getWantedRowIds('', 3, Array)
#5 /var/www/html/custom_apps/tables/lib/Service/RowService.php(535): OCA\Tables\Db\Row2Mapper->countRowsForView(Object(OCA\Tables\Db\View), '', Array)
#6 /var/www/html/custom_apps/tables/lib/Service/ViewService.php(413): OCA\Tables\Service\RowService->getViewRowsCount(Object(OCA\Tables\Db\View), '')
#7 /var/www/html/custom_apps/tables/lib/Service/ViewService.php(90): OCA\Tables\Service\ViewService->enhanceView(Object(OCA\Tables\Db\View), '')
#8 /var/www/html/custom_apps/tables/lib/Service/ViewService.php(462): OCA\Tables\Service\ViewService->findAll(Object(OCA\Tables\Db\Table), '')
#9 /var/www/html/custom_apps/tables/lib/Service/TableService.php(420): OCA\Tables\Service\ViewService->deleteAllByTable(Object(OCA\Tables\Db\Table), '')
#10 /var/www/html/custom_apps/tables/lib/Command/RemoveTable.php(67): OCA\Tables\Service\TableService->delete(3, '')
#11 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OCA\Tables\Command\RemoveTable->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Tables\Command\RemoveTable), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/console.php(102): OC\Console\Application->run()
#17 /var/www/html/occ(11): require_once('/var/www/html/c...')```
Listing all tables via OCC does list all of them

@barbayellow
Copy link
Author

barbayellow commented Jul 16, 2024 via email

@blizzz
Copy link
Member

blizzz commented Jul 18, 2024

@PlaryWasTaken Could you run select id, filter from oc_tables_views where id = 4; ?

@barbayellow and could you run select id, filter from oc_tables_views where table_id = 2; ?

If there is stuff in the result you do not want public it is totally fine to obfuscate it. Just keep the data types in place, please :)

@PlaryWasTaken
Copy link

PlaryWasTaken commented Jul 18, 2024

@PlaryWasTaken Could you run select id, filter from oc_tables_views where id = 4; ?

@barbayellow and could you run select id, filter from oc_tables_views where table_id = 2; ?

If there is stuff in the result you do not want public it is totally fine to obfuscate it. Just keep the data types in place,

I couldnt let the company just stop, so i ended up deleting the offending view directly in the database, although i have the result of the query select * from oc_tables_views would that be fine?

@PlaryWasTaken
Copy link

id | columns | sort | filter
----+---------------------+---------------------------------+---------------------------------------------------------
1 | [1,2,3,4] | [] | []
2 | [17,14,15,-4,16,18] | [] | [[{"columnId":-2,"operator":"is-equal","value":"@me"}]]
4 | [17,16,18,14,15,-1] | [{"columnId":-4,"mode":"DESC"}] | [[{"columnId":null,"operator":null,"value":""}]]

Heres the result with all the views included and some of the columns removed (But id and filter are still there)

@blizzz
Copy link
Member

blizzz commented Jul 19, 2024

@PlaryWasTaken the issue is the empty column in the filter of id 4. This should definitely be fixed with #1196 however.

@barbayellow
Copy link
Author

MariaDB [mynextclouddatabasename]> select id, filter from oc_tables_views where table_id = 2;
+----+--------------------------------------------------+
| id | filter                                           |
+----+--------------------------------------------------+
|  6 | [[{"columnId":null,"operator":null,"value":""}]] |
|  7 | [[{"columnId":null,"operator":null,"value":""}]] |
+----+--------------------------------------------------+
2 rows in set (0,000 sec)

@blizzz
Copy link
Member

blizzz commented Jul 22, 2024

Sure, I pulled the modified files directly from github using wget and copied it in their destination directory. I then gave the ownership back to www-data, gave the according rights, delete the previous files and renamed the newly downloaded files with the original names. No pb to run a database query. We don't have any sensitive data (yet) in the tables application.

Okay, please try this:

  1. Revert back to the original files, respectively tables 0.7.4
  2. Get the patch: https://patch-diff.githubusercontent.com/raw/nextcloud/tables/pull/1196.diff
  3. Apply the patch:
    1. cd /path/to/nextcloud/apps/tables/
    2. patch -p1 < /path/to/1196.diff
  4. And retry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants