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
{
$res = [];
$stack = [];
foreach (self::getDirs(DC_TPL_CACHE) as $path => $count) {
$res[] = new ValueDescriptor(
$stack[] = new ValueDescriptor(
ns: $path,
count: $count
);
}
return $res;
return $stack;
}
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']))
->group('log_table');
$rs = $sql->select();
if (is_null($rs) || $rs->isEmpty()) {
$record = $sql->select();
if (is_null($record) || $record->isEmpty()) {
return [];
}
$res = [];
while ($rs->fetch()) {
$res[] = new ValueDescriptor(
ns: (string) $rs->f('log_table'),
count: (int) $rs->f('counter')
$stack = [];
while ($record->fetch()) {
if (is_string($record->f('log_table')) && is_numeric($record->f('counter'))) {
$stack[] = new ValueDescriptor(
ns: $record->f('log_table'),
count: (int) $record->f('counter')
);
}
}
return $res;
return $stack;
}
public function execute(string $action, string $ns): bool

View File

@ -61,15 +61,15 @@ class Plugins extends CleanerParent
$dirs = self::getDirs(DC_PLUGINS_ROOT);
sort($dirs);
$res = [];
$stack = [];
foreach ($dirs as $path => $count) {
$res[] = new ValueDescriptor(
$stack[] = new ValueDescriptor(
ns: $path,
count: $count
);
}
return $res;
return $stack;
}
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']))
->group('pref_ws');
$rs = $sql->select();
if (is_null($rs) || $rs->isEmpty()) {
$record = $sql->select();
if (is_null($record) || $record->isEmpty()) {
return [];
}
$res = [];
while ($rs->fetch()) {
$res[] = new ValueDescriptor(
ns: (string) $rs->f('pref_ws'),
count: (int) $rs->f('counter')
$stack = [];
while ($record->fetch()) {
if (is_string($record->f('pref_ws')) && is_numeric($record->f('counter'))) {
$stack[] = new ValueDescriptor(
ns: $record->f('pref_ws'),
count: (int) $record->f('counter')
);
}
}
return $res;
return $stack;
}
public function related(string $ns): array
@ -133,20 +135,22 @@ class Preferences extends CleanerParent
->and('pref_ws = ' . $sql->quote($ns))
->group('pref_id');
$rs = $sql->select();
if (is_null($rs) || $rs->isEmpty()) {
$record = $sql->select();
if (is_null($record) || $record->isEmpty()) {
return [];
}
$res = [];
while ($rs->fetch()) {
$res[] = new ValueDescriptor(
id: (string) $rs->f('pref_id'),
count: (int) $rs->f('counter')
$stack = [];
while ($record->fetch()) {
if (is_string($record->f('pref_id')) && is_numeric($record->f('counter'))) {
$stack[] = new ValueDescriptor(
id: $record->f('pref_id'),
count: (int) $record->f('counter')
);
}
}
return $res;
return $stack;
}
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']))
->group('setting_ns');
$rs = $sql->select();
if (is_null($rs) || $rs->isEmpty()) {
$record = $sql->select();
if (is_null($record) || $record->isEmpty()) {
return [];
}
$res = [];
while ($rs->fetch()) {
$res[] = new ValueDescriptor(
ns: (string) $rs->f('setting_ns'),
count: (int) $rs->f('counter')
$stack = [];
while ($record->fetch()) {
if (is_string($record->f('setting_ns')) && is_numeric($record->f('counter'))) {
$stack[] = new ValueDescriptor(
ns: $record->f('setting_ns'),
count: (int) $record->f('counter')
);
}
}
return $res;
return $stack;
}
public function related(string $ns): array
@ -137,20 +139,22 @@ class Settings extends CleanerParent
->and('setting_ns = ' . $sql->quote($ns))
->group('setting_id');
$rs = $sql->select();
if (is_null($rs) || $rs->isEmpty()) {
$record = $sql->select();
if (is_null($record) || $record->isEmpty()) {
return [];
}
$res = [];
while ($rs->fetch()) {
$res[] = new ValueDescriptor(
id: (string) $rs->f('setting_id'),
count: (int) $rs->f('counter')
$stack = [];
while ($record->fetch()) {
if (is_string($record->f('setting_id')) && is_numeric($record->f('counter'))) {
$stack[] = new ValueDescriptor(
id: $record->f('setting_id'),
count: (int) $record->f('counter')
);
}
}
return $res;
return $stack;
}
public function execute(string $action, string $ns): bool

View File

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

View File

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

View File

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

View File

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