Skip to content

Commit

Permalink
Merge pull request #1147 from nextcloud/bugfix/oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Nov 30, 2020
2 parents 7206af6 + 73c624a commit e7d14e0
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 4 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/oci.yml
@@ -0,0 +1,74 @@
name: PHPUnit

on:
pull_request:
push:
branches:
- master
- stable*

env:
APP_NAME: groupfolders

jobs:
oci:
runs-on: ubuntu-latest

strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4']
databases: ['oci']
server-versions: ['master']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}

services:
oracle:
image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2"
ports:
- "1521:1521"

steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}

- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}

- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i

- name: Set up php ${{ matrix.php-versions }}
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-versions }}"
extensions: mbstring, iconv, fileinfo, intl, oci8
tools: phpunit:8.5.2
coverage: none

- name: Set up Nextcloud
run: |
mkdir data
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
php -f index.php
./occ app:enable --force ${{ env.APP_NAME }}
- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}/tests
run: phpunit -c phpunit.xml

6 changes: 4 additions & 2 deletions lib/Folder/FolderManager.php
Expand Up @@ -186,7 +186,9 @@ public function getFolder($id, $rootStorageId) {
->where($query->expr()->eq('folder_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$this->joinQueryWithFileCache($query, $rootStorageId);

$row = $query->execute()->fetch();
$result = $query->execute();
$row = $result->fetch();
$result->closeCursor();

return $row ? [
'id' => $id,
Expand Down Expand Up @@ -376,7 +378,7 @@ public function createFolder($mountPoint) {
]);
$query->execute();

return $this->connection->lastInsertId('group_folders');
return $query->getLastInsertId();
}

public function setMountPoint($folderId, $mountPoint) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Migration/Version201000Date20190212150323.php
Expand Up @@ -21,7 +21,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table = $schema->getTable('group_folders');
if (!$table->hasColumn('acl')) {
$table->addColumn('acl', 'integer', [
'notnull' => true,
// 'notnull' => true,
'notnull' => false,
'length' => 4,
'default' => 0
]);
Expand Down
1 change: 0 additions & 1 deletion lib/Migration/Version401001Date20190715092137.php
Expand Up @@ -54,7 +54,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'length' => 64,
]);
$table->setPrimaryKey(['folder_id', 'mapping_type', 'mapping_id']);
$table->addUniqueIndex(['folder_id', 'mapping_type', 'mapping_id'], 'groups_folder_manage_unique');
}

return $schema;
Expand Down
62 changes: 62 additions & 0 deletions lib/Migration/Version802000Date20201119112624.php
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\GroupFolders\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version802000Date20201119112624 extends SimpleMigrationStep {

public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$result = $this->ensureColumnIsNullable($schema, 'group_folders', 'acl');

// There might be a duplicate column group which was already indexed through being primary key in Version401001Date20190715092137
$table = $schema->getTable('group_folders_manage');
if ($table->hasIndex('groups_folder_manage_unique')) {
$table->dropIndex('groups_folder_manage_unique');
$result = true;
}

return $result ? $schema : null;
}

protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool {
$table = $schema->getTable($tableName);
$column = $table->getColumn($columnName);

if ($column->getNotnull()) {
$column->setNotnull(false);
return true;
}

return false;
}
}

0 comments on commit e7d14e0

Please sign in to comment.