Skip to content

Add a repair step to clean up orphan tags and tag entries - #13344

Merged
MorrisJobke merged 1 commit into
masterfrom
issue/13334-cleanup-tags-repairstep
Jan 14, 2015
Merged

MorrisJobke merged 1 commit into
masterfrom
issue/13334-cleanup-tags-repairstep

Conversation

@nickvergessen

Copy link
Copy Markdown
Contributor

@PVince81

Fix #13334

We could even setup a Background job for this Repairstep, so it is cleaned once in a while, before growing to big.

Comment thread lib/repair/cleantags.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enforce type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@PVince81

Copy link
Copy Markdown
Contributor

Nice one. Please add unit tests for the different cases 😄
Also add asserts to verify that non-orphaned entries are still there.
Thanks!

Comment thread lib/repair/cleantags.php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha - 🚀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw the method is missing from OCP\IDBConnection should be added, or is that intentional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for exposing it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - it will expose a 3rdparty interface and you all know my intention on this.

let's keep it for now and see how far we get with the querybuild in the next weeks - from my pov we even might want to write a wrapper which takes care about proper quoting for table and column names.

so 👎 for at least 8.0

Thanks for bringing this up!

@DeepDiver1975 DeepDiver1975 added this to the 8.0-current milestone Jan 14, 2015
Comment thread lib/repair/cleantags.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is potentially a dangerous actions.

Now $items may not contain any user controllable input. But as soon as it does this may potentially lead to a SQL injection.

This needs either to get parameterized (not sure if possible here) or you need to verify the type.

See:

foreach ($orphanItemsBatch as $items) {
    $items = [0 =>  "3); INSERT INTO `oc_users` VALUES ('inject', 'inject', 'inject'); #"];

    $qb->delete('`' . $deleteTable . '`')
        ->where($qb->expr()->in('`' . $deleteId . '`', $items));
    var_dump($qb->getSQL());
    $qb->execute();

    exit();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially considering that people are fans of copying code fragements here – I'd prefer a failsafe example that makes shooting yourself in your knee hard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@nickvergessen
nickvergessen force-pushed the issue/13334-cleanup-tags-repairstep branch 2 times, most recently from 1018749 to c7c9b6d Compare January 14, 2015 15:15
@nickvergessen

Copy link
Copy Markdown
Contributor Author

@PVince81 @LukasReschke added tests

@nickvergessen
nickvergessen force-pushed the issue/13334-cleanup-tags-repairstep branch from c7c9b6d to a22068c Compare January 14, 2015 15:49
@ghost

ghost commented Jan 14, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/6770/
👍 Test PASSed. 👍

@LukasReschke

Copy link
Copy Markdown
Contributor

👍

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 8 new issues, 14 updated code elements

@MorrisJobke

Copy link
Copy Markdown
Contributor

Works 👍

MorrisJobke added a commit that referenced this pull request Jan 14, 2015
…irstep

Add a repair step to clean up orphan tags and tag entries
@MorrisJobke
MorrisJobke merged commit 64d7463 into master Jan 14, 2015
@MorrisJobke
MorrisJobke deleted the issue/13334-cleanup-tags-repairstep branch January 14, 2015 19:43
Comment thread lib/repair/cleantags.php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tables and column names have to be quoted

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repair step to cleanup orphaned tags

6 participants