Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
1601867c
Commit
1601867c
authored
10 years ago
by
Morris Jobke
Browse files
Options
Downloads
Patches
Plain Diff
Remove unneeded getetag entries in properties table
* fixes #13281
parent
160d8003
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/private/repair.php
+2
-0
2 additions, 0 deletions
lib/private/repair.php
lib/repair/removegetetagentries.php
+59
-0
59 additions, 0 deletions
lib/repair/removegetetagentries.php
tests/lib/repair/removegetetagentriestest.php
+77
-0
77 additions, 0 deletions
tests/lib/repair/removegetetagentriestest.php
with
138 additions
and
0 deletions
lib/private/repair.php
+
2
−
0
View file @
1601867c
...
...
@@ -33,6 +33,7 @@ use OC\Repair\AssetCache;
use
OC\Repair\CleanTags
;
use
OC\Repair\Collation
;
use
OC\Repair\DropOldJobs
;
use
OC\Repair\RemoveGetETagEntries
;
use
OC\Repair\SqliteAutoincrement
;
use
OC\Repair\DropOldTables
;
use
OC\Repair\FillETags
;
...
...
@@ -108,6 +109,7 @@ class Repair extends BasicEmitter {
new
CleanTags
(
\OC_DB
::
getConnection
()),
new
DropOldTables
(
\OC_DB
::
getConnection
()),
new
DropOldJobs
(
\OC
::
$server
->
getJobList
()),
new
RemoveGetETagEntries
(
\OC_DB
::
getConnection
()),
);
}
...
...
This diff is collapsed.
Click to expand it.
lib/repair/removegetetagentries.php
0 → 100644
+
59
−
0
View file @
1601867c
<?php
/**
* @author Morris Jobke <hey@morrisjobke.de>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace
OC\Repair
;
use
OC\Hooks\BasicEmitter
;
use
OCP\IDBConnection
;
class
RemoveGetETagEntries
extends
BasicEmitter
{
/**
* @var IDBConnection
*/
protected
$connection
;
/**
* @param IDBConnection $connection
*/
public
function
__construct
(
IDBConnection
$connection
)
{
$this
->
connection
=
$connection
;
}
public
function
getName
()
{
return
'Remove getetag entries in properties table'
;
}
/**
* Removes all entries with the key "{DAV:}getetag" from the table properties
*/
public
function
run
()
{
$sql
=
'DELETE FROM `*PREFIX*properties`'
.
' WHERE `propertyname` = ?'
;
$deletedRows
=
$this
->
connection
->
executeUpdate
(
$sql
,
[
'{DAV:}getetag'
]);
$this
->
emit
(
'\OC\Repair'
,
'info'
,
[
'Removed '
.
$deletedRows
.
' unneeded "{DAV:}getetag" entries from properties table.'
]
);
}
}
This diff is collapsed.
Click to expand it.
tests/lib/repair/removegetetagentriestest.php
0 → 100644
+
77
−
0
View file @
1601867c
<?php
/**
* @author Morris Jobke <hey@morrisjobke.de>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace
Test\Repair
;
use
OC\Repair\RemoveGetETagEntries
;
use
Test\TestCase
;
class
RemoveGetETagEntriesTest
extends
TestCase
{
/** @var \OCP\IDBConnection */
protected
$connection
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connection
=
\OC
::
$server
->
getDatabaseConnection
();
}
public
function
testRun
()
{
$userName
=
'removePropertiesUser'
;
$data
=
[
[
$userName
,
'/abc.def.txt'
,
'{DAV:}getetag'
,
'abcdef'
],
[
$userName
,
'/abc.def.txt'
,
'{DAV:}anotherRandomProperty'
,
'ghi'
],
];
// insert test data
$sqlToInsertProperties
=
'INSERT INTO `*PREFIX*properties` (`userid`, `propertypath`, `propertyname`, `propertyvalue`) VALUES (?, ?, ? ,?)'
;
foreach
(
$data
as
$entry
)
{
$this
->
connection
->
executeUpdate
(
$sqlToInsertProperties
,
$entry
);
}
// check if test data is written to DB
$sqlToFetchProperties
=
'SELECT `userid`, `propertypath`, `propertyname`, `propertyvalue` FROM `*PREFIX*properties` WHERE `userid` = ?'
;
$stmt
=
$this
->
connection
->
executeQuery
(
$sqlToFetchProperties
,
[
$userName
]);
$entries
=
$stmt
->
fetchAll
(
\PDO
::
FETCH_NUM
);
$this
->
assertCount
(
2
,
$entries
,
'Asserts that two entries are returned as we have inserted two'
);
foreach
(
$entries
as
$entry
)
{
$this
->
assertTrue
(
in_array
(
$entry
,
$data
),
'Asserts that the entries are the ones from the test data set'
);
}
// run repair step
$repair
=
new
RemoveGetETagEntries
(
$this
->
connection
);
$repair
->
run
();
// check if test data is correctly modified in DB
$stmt
=
$this
->
connection
->
executeQuery
(
$sqlToFetchProperties
,
[
$userName
]);
$entries
=
$stmt
->
fetchAll
(
\PDO
::
FETCH_NUM
);
$this
->
assertCount
(
1
,
$entries
,
'Asserts that only one entry is returned after the repair step - the other one has to be removed'
);
$this
->
assertSame
(
$data
[
1
],
$entries
[
0
],
'Asserts that the returned entry is the correct one from the test data set'
);
// remove test data
$sqlToRemoveProperties
=
'DELETE FROM `*PREFIX*properties` WHERE `userid` = ?'
;
$this
->
connection
->
executeUpdate
(
$sqlToRemoveProperties
,
[
$userName
]);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment