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

Allow cleaning namespace only #52

Closed
wants to merge 11 commits into from

Conversation

@aiphee
Copy link

commented Aug 4, 2017

  • bug fix? no
  • new feature? yes #40
  • BC break? no

Added option to clean only selected workspace. Repaired comments in changed files.

Jirka F

@aiphee aiphee changed the title Přidání mazání namespace Allow cleaning namespace only Aug 4, 2017

@dg

This comment has been minimized.

Copy link
Member

commented Aug 5, 2017

You changed some tabs to spaces, can you fix it and repush?

aiphee aiphee
@aiphee

This comment has been minimized.

Copy link
Author

commented Aug 5, 2017

Yeah sorry, didn't notice in my editor.

@dg

This comment has been minimized.

Copy link
Member

commented Aug 5, 2017

There are still a lot of modifications in phpDoc which are not needed.

@aiphee

This comment has been minimized.

Copy link
Author

commented Aug 5, 2017

OK, i will delete that later. I usually do that because phpStorm hints are broken when phpDoc is off, but i guess that is for different pull request anyway.

@aiphee

This comment has been minimized.

Copy link
Author

commented Aug 5, 2017

OK, comments are back as they were and i added test, i wasn't sure with SQLite test, so i didn't do that one yet.

PS: I had some problems with testing, is there some way to download whole nette package with tests?

aiphee added some commits Aug 5, 2017

aiphee aiphee
aiphee aiphee

@aiphee aiphee force-pushed the aiphee:master branch from cc81763 to 9cca089 Aug 5, 2017

}
foreach ($namespaces as $namespace) {
$dir = $this->dir . "/_$namespace";

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

It should be $dir = $this->dir . '/_' . urlencode($namespace);

foreach ($namespaces as $namespace) {
$dir = $this->dir . "/_$namespace";
if (is_dir($dir)) {
$items = Nette\Utils\Finder::findFiles('')->from($dir);

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

findFiles('*') seems more readable

foreach ($items as $item) {
$this->delete((string) $item);
}
@rmdir($dir);

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

Please add comment // may already contain new files

@@ -249,6 +249,7 @@ public function clean(array $conditions): void
{
$all = !empty($conditions[Cache::ALL]);
$collector = empty($conditions);
$namespaces = $conditions[Cache::NAMESPACE] ?? false;

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

You can convert it to array immediately, for example $namespace = (array) $conditions[Cache::NAMESPACE] ?? null;

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

Btw, probably better name is NAMESPACES to be consistent with TAGS and FILES

This comment has been minimized.

Copy link
@aiphee

aiphee Aug 11, 2017

Author

Not sure how you mean it with retyping it to array at top. It wouldn't work even if it were enclosed in brackets.

}
foreach ($namespaces as $namespace) {
$this->pdo->prepare("DELETE FROM cache WHERE key LIKE %/_$namespace/%")->execute();

This comment has been minimized.

Copy link
@dg

dg Aug 6, 2017

Member

This is sql injection, it should be

$this->pdo->prepare('DELETE FROM cache WHERE key LIKE ?)')->execute([$namespace . Cache::NAMESPACE_SEPARATOR])

@dg

This comment has been minimized.

Copy link
Member

commented Aug 6, 2017

Good work!

When you install it via Composer composer create-project nette/caching, you can run tests via vendor/bin/tester.

dg and others added some commits Aug 9, 2017

aiphee aiphee
Repair things from review,
add test for cleaning SQLite namespace
aiphee aiphee
aiphee aiphee
aiphee aiphee
cs

@aiphee aiphee force-pushed the aiphee:master branch from 44490cd to 0b2ed52 Aug 11, 2017

aiphee aiphee
cs

@aiphee aiphee force-pushed the aiphee:master branch from 4e183ff to 9fd0e39 Aug 12, 2017

@dg dg force-pushed the nette:master branch from 3db3fb1 to f1a3d53 Aug 17, 2017

@dg dg closed this in b8e5b14 Aug 18, 2017

@dg

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

Merged with a small modification, thanks!

dg added a commit that referenced this pull request Aug 18, 2017

dg added a commit that referenced this pull request Aug 18, 2017

dg added a commit that referenced this pull request Aug 18, 2017

@dg dg referenced this pull request Aug 18, 2017

Open

Cleaning namespace in SQLite #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.