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

[stable20] Run unit tests against oracle #24049

Merged
merged 19 commits into from Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a35b095
Add github action for oci8
juliushaertl Nov 3, 2020
f58ffad
Use a different column for the primary key as we can not insert it on…
nickvergessen Nov 4, 2020
3ec48cd
Easier debugging and spell fix
nickvergessen Nov 4, 2020
e3b3ff6
Skip the insertIfNotExists() tests on Oracle because it doesn't work …
nickvergessen Nov 4, 2020
48c2f6d
Make the test pass on repeating calls
nickvergessen Nov 6, 2020
fcef3c0
Fix "Invalid fetch style: 12" on Oracle
nickvergessen Nov 6, 2020
8ff0523
Make sure columns with an empty default are nullable for Oracle
nickvergessen Nov 9, 2020
b6ce689
Fix public calendars as they are stored with null on oracle
nickvergessen Nov 9, 2020
97b0402
Empty string is returned as null, but empty string in file cache is t…
nickvergessen Nov 9, 2020
a66591e
Fix comparing the empty string for global credentials
nickvergessen Nov 9, 2020
dee4202
Don't try to update on NotNullConstraintViolationException, only on u…
nickvergessen Nov 9, 2020
f3c183b
Replace the credentials table with one that can have empty user
nickvergessen Nov 10, 2020
bb52911
Create primary keys on all tables and add a command to create the aft…
nickvergessen Nov 10, 2020
cd76043
Fix CS
nickvergessen Nov 10, 2020
07c28f1
Fix naming of jobs and steps
nickvergessen Nov 10, 2020
dabed84
Fix unique key in test table
nickvergessen Nov 10, 2020
d09a220
Update baseline, I'm sorry
nickvergessen Nov 11, 2020
388b310
fix migration of oc_credentials table
icewind1991 Nov 12, 2020
9497dca
Update psalm-baseline
MorrisJobke Nov 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/oci.yml
@@ -0,0 +1,56 @@
name: PHPUnit

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

jobs:
phpunit-oci8:
runs-on: ubuntu-latest

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

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

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

steps:
- name: Checkout server
uses: actions/checkout@v2

- 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: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, 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

- name: PHPUnit
working-directory: tests
run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB
2 changes: 1 addition & 1 deletion apps/accessibility/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
2 changes: 1 addition & 1 deletion apps/admin_audit/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
2 changes: 1 addition & 1 deletion apps/contactsinteraction/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Expand Up @@ -5,7 +5,7 @@
<name>WebDAV</name>
<summary>WebDAV endpoint</summary>
<description>WebDAV endpoint</description>
<version>1.16.0</version>
<version>1.16.1</version>
<licence>agpl</licence>
<author>owncloud.org</author>
<namespace>DAV</namespace>
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_classmap.php
Expand Up @@ -230,6 +230,7 @@
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir . '/../lib/Migration/Version1011Date20190725113607.php',
'OCA\\DAV\\Migration\\Version1011Date20190806104428' => $baseDir . '/../lib/Migration/Version1011Date20190806104428.php',
'OCA\\DAV\\Migration\\Version1012Date20190808122342' => $baseDir . '/../lib/Migration/Version1012Date20190808122342.php',
'OCA\\DAV\\Migration\\Version1016Date20201109085907' => $baseDir . '/../lib/Migration/Version1016Date20201109085907.php',
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_static.php
Expand Up @@ -245,6 +245,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190725113607.php',
'OCA\\DAV\\Migration\\Version1011Date20190806104428' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190806104428.php',
'OCA\\DAV\\Migration\\Version1012Date20190808122342' => __DIR__ . '/..' . '/../lib/Migration/Version1012Date20190808122342.php',
'OCA\\DAV\\Migration\\Version1016Date20201109085907' => __DIR__ . '/..' . '/../lib/Migration/Version1016Date20201109085907.php',
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',
Expand Down
46 changes: 34 additions & 12 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Expand Up @@ -241,8 +241,13 @@ public function getCalendarsForUserCount($principalUri, $excludeBirthday = true)
$principalUri = $this->convertPrincipal($principalUri, true);
$query = $this->db->getQueryBuilder();
$query->select($query->func()->count('*'))
->from('calendars')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
->from('calendars');

if ($principalUri === '') {
$query->where($query->expr()->emptyString('principaluri'));
} else {
$query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
}

if ($excludeBirthday) {
$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
Expand Down Expand Up @@ -292,13 +297,21 @@ public function getCalendarsForUser($principalUri) {

// Making fields a comma-delimited list
$query = $this->db->getQueryBuilder();
$query->select($fields)->from('calendars')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
->orderBy('calendarorder', 'ASC');
$stmt = $query->execute();
$query->select($fields)
->from('calendars')
->orderBy('calendarorder', 'ASC');

if ($principalUri === '') {
$query->where($query->expr()->emptyString('principaluri'));
} else {
$query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
}

$result = $query->execute();

$calendars = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
while ($row = $result->fetch()) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
Expand All @@ -325,8 +338,7 @@ public function getCalendarsForUser($principalUri) {
$calendars[$calendar['id']] = $calendar;
}
}

$stmt->closeCursor();
$result->closeCursor();

// query for shared calendars
$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
Expand All @@ -346,17 +358,19 @@ public function getCalendarsForUser($principalUri) {
$fields[] = 'a.transparent';
$fields[] = 's.access';
$query = $this->db->getQueryBuilder();
$result = $query->select($fields)
$query->select($fields)
->from('dav_shares', 's')
->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
->setParameter('type', 'calendar')
->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
->execute();
->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);

$result = $query->execute();

$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
while ($row = $result->fetch()) {
$row['principaluri'] = (string) $row['principaluri'];
if ($row['principaluri'] === $principalUri) {
continue;
}
Expand Down Expand Up @@ -427,6 +441,7 @@ public function getUsersOwnCalendars($principalUri) {
$stmt = $query->execute();
$calendars = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
Expand Down Expand Up @@ -496,6 +511,7 @@ public function getPublicCalendars() {
->execute();

while ($row = $result->fetch()) {
$row['principaluri'] = (string) $row['principaluri'];
list(, $name) = Uri\split($row['principaluri']);
$row['displayname'] = $row['displayname'] . "($name)";
$components = [];
Expand Down Expand Up @@ -562,6 +578,7 @@ public function getPublicCalendar($uri) {
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}

$row['principaluri'] = (string) $row['principaluri'];
list(, $name) = Uri\split($row['principaluri']);
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
$components = [];
Expand Down Expand Up @@ -618,6 +635,7 @@ public function getCalendarByUri($principal, $uri) {
return null;
}

$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
Expand Down Expand Up @@ -668,6 +686,7 @@ public function getCalendarById($calendarId) {
return null;
}

$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
Expand Down Expand Up @@ -717,6 +736,7 @@ public function getSubscriptionById($subscriptionId) {
return null;
}

$row['principaluri'] = (string) $row['principaluri'];
$subscription = [
'id' => $row['id'],
'uri' => $row['uri'],
Expand Down Expand Up @@ -964,6 +984,7 @@ public function getCalendarObjects($calendarId, $calendarType=self::CALENDAR_TYP
'classification'=> (int)$row['classification']
];
}
$stmt->closeCursor();

return $result;
}
Expand Down Expand Up @@ -994,6 +1015,7 @@ public function getCalendarObject($calendarId, $objectUri, $calendarType=self::C
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
$stmt = $query->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();

if (!$row) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Migration/Version1012Date20190808122342.php
Expand Up @@ -69,7 +69,7 @@ public function changeSchema(IOutput $output,
'length' => 11,
]);
$table->addColumn('is_recurring', Types::SMALLINT, [
'notnull' => true,
'notnull' => false,
'length' => 1,
]);
$table->addColumn('uid', Types::STRING, [
Expand Down
61 changes: 61 additions & 0 deletions apps/dav/lib/Migration/Version1016Date20201109085907.php
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @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\DAV\Migration;

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

class Version1016Date20201109085907 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring');

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;
}
}
7 changes: 5 additions & 2 deletions apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
Expand Up @@ -110,10 +110,13 @@ protected function getProps(string $user, string $path) {
->where($query->expr()->eq('userid', $query->createNamedParameter($user)))
->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path))));


$result = $query->execute();
$data = $result->fetchAll(\PDO::FETCH_KEY_PAIR);
$data = [];
while ($row = $result->fetch()) {
$data[$row['propertyname']] = $row['propertyvalue'];
}
$result->closeCursor();

return $data;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/encryption/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
Expand Up @@ -52,7 +52,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'notnull' => true,
'length' => 4,
]);
$table->addUniqueIndex(['share_id'], 'share_id_index');
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
// $table->addUniqueIndex(['share_id'], 'share_id_index');
}
return $schema;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/federation/composer/composer/ClassLoader.php
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down