Skip to content

Commit

Permalink
- Solucionado bug al eliminar registros del log.
Browse files Browse the repository at this point in the history
- Pequeñas correcciones al código.
  • Loading branch information
NeoRazorX committed Mar 4, 2022
1 parent 899b31a commit de3518e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions Core/Base/ExtensionsTrait.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2019-2020 Carlos Garcia Gomez <[email protected]>
* Copyright (C) 2019-2022 Carlos Garcia Gomez <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand All @@ -16,6 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace FacturaScripts\Core\Base;

use BadMethodCallException;
Expand All @@ -35,9 +36,9 @@ trait ExtensionsTrait

/**
* Executes the first matched extension.
*
*
* @param string $name
* @param array $arguments
* @param array $arguments
*
* @return mixed
*
Expand All @@ -47,30 +48,28 @@ public function __call($name, $arguments = [])
{
foreach (static::$extensions as $ext) {
if ($ext['name'] === $name && $ext['function'] instanceof Closure) {
return \call_user_func_array($ext['function']->bindTo($this, static::class), $arguments);
return call_user_func_array($ext['function']->bindTo($this, static::class), $arguments);
}
}

throw new BadMethodCallException('Method ' . $name . ' does not exist on class ' . static::class . '.');
}

/**
*
* @param mixed $extension
*/
public static function addExtension($extension)
{
$methods = (new ReflectionClass($extension))->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED);
foreach ($methods as $method) {
$method->setAccessible(true);
\array_unshift(self::$extensions, ['name' => $method->name, 'function' => $method->invoke($extension)]);
array_unshift(self::$extensions, ['name' => $method->name, 'function' => $method->invoke($extension)]);
}
}

/**
*
* @param string $name
* @param array $arguments
* @param array $arguments
*
* @return mixed
*/
Expand All @@ -81,7 +80,7 @@ public function pipe($name, ...$arguments)
if ($ext['name'] !== $name) {
continue;
} elseif ($ext['function'] instanceof Closure) {
$return = \call_user_func_array($ext['function']->bindTo($this, static::class), $arguments);
$return = call_user_func_array($ext['function']->bindTo($this, static::class), $arguments);
}

if ($return !== null) {
Expand Down
2 changes: 1 addition & 1 deletion Core/Base/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static function clearLogs()
// cuando hay miles de registros en el canal master, eliminamos los antiguos para evitar problemas de rendimiento
$dataBase = new DataBase();
$date = date("Y-m-d H:i:s", strtotime("-1 month"));
$sql = "DELETE logs WHERE channel = 'master' AND time < '" . $date . "';";
$sql = "DELETE FROM logs WHERE channel = 'master' AND time < '" . $date . "';";
$dataBase->exec($sql);
}

Expand Down

0 comments on commit de3518e

Please sign in to comment.