cosmetic harmonized vars names

This commit is contained in:
Jean-Christian Paul Denis 2023-05-09 11:42:36 +02:00
parent ad765c30da
commit 58a903a7c6
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
9 changed files with 78 additions and 67 deletions

View File

@ -74,15 +74,15 @@ class Caches extends CleanerParent
public function values(): array public function values(): array
{ {
$res = []; $stack = [];
foreach (self::getDirs(DC_TPL_CACHE) as $path => $count) { foreach (self::getDirs(DC_TPL_CACHE) as $path => $count) {
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: $path, ns: $path,
count: $count count: $count
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -74,20 +74,22 @@ class Logs extends CleanerParent
->where($sql->orGroup(['blog_id IS NULL', 'blog_id IS NOT NULL'])) ->where($sql->orGroup(['blog_id IS NULL', 'blog_id IS NOT NULL']))
->group('log_table'); ->group('log_table');
$rs = $sql->select(); $record = $sql->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($record) || $record->isEmpty()) {
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($record->fetch()) {
$res[] = new ValueDescriptor( if (is_string($record->f('log_table')) && is_numeric($record->f('counter'))) {
ns: (string) $rs->f('log_table'), $stack[] = new ValueDescriptor(
count: (int) $rs->f('counter') ns: $record->f('log_table'),
count: (int) $record->f('counter')
); );
} }
}
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -61,15 +61,15 @@ class Plugins extends CleanerParent
$dirs = self::getDirs(DC_PLUGINS_ROOT); $dirs = self::getDirs(DC_PLUGINS_ROOT);
sort($dirs); sort($dirs);
$res = []; $stack = [];
foreach ($dirs as $path => $count) { foreach ($dirs as $path => $count) {
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: $path, ns: $path,
count: $count count: $count
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -105,20 +105,22 @@ class Preferences extends CleanerParent
->where($sql->orGroup(['user_id IS NULL', 'user_id IS NOT NULL'])) ->where($sql->orGroup(['user_id IS NULL', 'user_id IS NOT NULL']))
->group('pref_ws'); ->group('pref_ws');
$rs = $sql->select(); $record = $sql->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($record) || $record->isEmpty()) {
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($record->fetch()) {
$res[] = new ValueDescriptor( if (is_string($record->f('pref_ws')) && is_numeric($record->f('counter'))) {
ns: (string) $rs->f('pref_ws'), $stack[] = new ValueDescriptor(
count: (int) $rs->f('counter') ns: $record->f('pref_ws'),
count: (int) $record->f('counter')
); );
} }
}
return $res; return $stack;
} }
public function related(string $ns): array public function related(string $ns): array
@ -133,20 +135,22 @@ class Preferences extends CleanerParent
->and('pref_ws = ' . $sql->quote($ns)) ->and('pref_ws = ' . $sql->quote($ns))
->group('pref_id'); ->group('pref_id');
$rs = $sql->select(); $record = $sql->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($record) || $record->isEmpty()) {
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($record->fetch()) {
$res[] = new ValueDescriptor( if (is_string($record->f('pref_id')) && is_numeric($record->f('counter'))) {
id: (string) $rs->f('pref_id'), $stack[] = new ValueDescriptor(
count: (int) $rs->f('counter') id: $record->f('pref_id'),
count: (int) $record->f('counter')
); );
} }
}
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -109,20 +109,22 @@ class Settings extends CleanerParent
->where($sql->orGroup(['blog_id IS NULL', 'blog_id IS NOT NULL'])) ->where($sql->orGroup(['blog_id IS NULL', 'blog_id IS NOT NULL']))
->group('setting_ns'); ->group('setting_ns');
$rs = $sql->select(); $record = $sql->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($record) || $record->isEmpty()) {
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($record->fetch()) {
$res[] = new ValueDescriptor( if (is_string($record->f('setting_ns')) && is_numeric($record->f('counter'))) {
ns: (string) $rs->f('setting_ns'), $stack[] = new ValueDescriptor(
count: (int) $rs->f('counter') ns: $record->f('setting_ns'),
count: (int) $record->f('counter')
); );
} }
}
return $res; return $stack;
} }
public function related(string $ns): array public function related(string $ns): array
@ -137,20 +139,22 @@ class Settings extends CleanerParent
->and('setting_ns = ' . $sql->quote($ns)) ->and('setting_ns = ' . $sql->quote($ns))
->group('setting_id'); ->group('setting_id');
$rs = $sql->select(); $record = $sql->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($record) || $record->isEmpty()) {
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($record->fetch()) {
$res[] = new ValueDescriptor( if (is_string($record->f('setting_id')) && is_numeric($record->f('counter'))) {
id: (string) $rs->f('setting_id'), $stack[] = new ValueDescriptor(
count: (int) $rs->f('counter') id: $record->f('setting_id'),
count: (int) $record->f('counter')
); );
} }
}
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -92,10 +92,10 @@ class Tables extends CleanerParent
public function values(): array public function values(): array
{ {
$object = AbstractSchema::init(dcCore::app()->con); $schema = AbstractSchema::init(dcCore::app()->con);
$tables = $object->getTables(); $tables = $schema->getTables();
$res = []; $stack = [];
foreach ($tables as $k => $v) { foreach ($tables as $k => $v) {
// get only tables with dotclear prefix // get only tables with dotclear prefix
if ('' != dcCore::app()->prefix) { if ('' != dcCore::app()->prefix) {
@ -106,14 +106,15 @@ class Tables extends CleanerParent
} }
$sql = new SelectStatement(); $sql = new SelectStatement();
$count = $sql->from($tables[$k])->fields([$sql->count('*')])->select()?->f(0);
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: (string) $v, ns: (string) $v,
count: (int) $sql->from($tables[$k])->fields([$sql->count('*')])->select()?->f(0) count: is_numeric($count) ? (int) $count : 0
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -66,15 +66,15 @@ class Themes extends CleanerParent
$dirs = self::getDirs($path); $dirs = self::getDirs($path);
sort($dirs); sort($dirs);
$res = []; $stack = [];
foreach ($dirs as $path => $count) { foreach ($dirs as $path => $count) {
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: $path, ns: $path,
count: $count count: $count
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -59,15 +59,15 @@ class Vars extends CleanerParent
public function values(): array public function values(): array
{ {
$res = []; $stack = [];
foreach (self::getDirs(DC_VAR) as $path => $count) { foreach (self::getDirs(DC_VAR) as $path => $count) {
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: $path, ns: $path,
count: $count count: $count
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool

View File

@ -80,16 +80,16 @@ class Versions extends CleanerParent
return []; return [];
} }
$res = []; $stack = [];
while ($rs->fetch()) { while ($rs->fetch()) {
$res[] = new ValueDescriptor( $stack[] = new ValueDescriptor(
ns: (string) $rs->f('module'), ns: (string) $rs->f('module'),
id: (string) $rs->f('version'), id: (string) $rs->f('version'),
count: 1 count: 1
); );
} }
return $res; return $stack;
} }
public function execute(string $action, string $ns): bool public function execute(string $action, string $ns): bool