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: Export empty view array when exporting shared tables #1620

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

enjeck
Copy link
Contributor

@enjeck enjeck commented Feb 17, 2025

When a table is shared, the export code can't retrieve the views. So we return an empty array. Otherwise, we get the error:

  "message": "OCA\\Tables\\Model\\TableScheme::__construct(): Argument #4 ($view) must be of type array, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/tables/lib/Service/TableService.php on line 531 in file '/var/www/cloud.nextcloud.com/nextcloud/apps/tables/lib/Model/TableScheme.php' line 27",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0",
  "version": "31.0.0.15",
  "exception": {
    "Exception": "Exception",
    "Message": "OCA\\Tables\\Model\\TableScheme::__construct(): Argument #4 ($view) must be of type array, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/tables/lib/Service/TableService.php on line 531 in file '/var/www/cloud.nextcloud.com/nextcloud/apps/tables/lib/Model/TableScheme.php' line 27",
    "Code": 0,
    "Trace": [

Signed-off-by: Cleopatra Enjeck M. <patrathewhiz@gmail.com>
@enjeck enjeck self-assigned this Feb 17, 2025
@enjeck enjeck requested a review from blizzz as a code owner February 17, 2025 09:52
@enjeck
Copy link
Contributor Author

enjeck commented Feb 17, 2025

When we do it this way, that means that when you export a shared table, the "views" array is empty. This is fine, right? @blizzz

@blizzz
Copy link
Member

blizzz commented Feb 17, 2025

When we do it this way, that means that when you export a shared table, the "views" array is empty. This is fine, right? @blizzz

Empty array is fine, but if some or all of the views are accessible those should be exported all along.

@enjeck
Copy link
Contributor Author

enjeck commented Feb 17, 2025

When we do it this way, that means that when you export a shared table, the "views" array is empty. This is fine, right? @blizzz

Empty array is fine, but if some or all of the views are accessible those should be exported all along.

I would expect getViews() to automatically do this, but it seems it doesn't

@blizzz
Copy link
Member

blizzz commented Feb 17, 2025

When we do it this way, that means that when you export a shared table, the "views" array is empty. This is fine, right? @blizzz

Empty array is fine, but if some or all of the views are accessible those should be exported all along.

I would expect getViews() to automatically do this, but it seems it doesn't

Views are null, because they are not set yet.

* @method getViews(): array
is misleading, should also indicate that null is possible. $this->enhanceTable($table) would need to be called previously so that views are set (they still might be null without proper permissions –
if (!$table->getIsShared() || $table->getOnSharePermissions()->manage) {
// add the corresponding views if it is an own table, or you have table manage rights
$table->setViews($this->viewService->findAll($table));
}
).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🧭 Planning evaluation (don't pick)
Development

Successfully merging this pull request may close these issues.

2 participants