From fce3a73c95cc405ac75e7494fc69460ff01f205e Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 11:14:56 -0300 Subject: [PATCH 1/6] FIX: descripcion for null --- app/resources/views/inmobiliarias/list.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resources/views/inmobiliarias/list.blade.php b/app/resources/views/inmobiliarias/list.blade.php index cf9478a..489ce31 100644 --- a/app/resources/views/inmobiliarias/list.blade.php +++ b/app/resources/views/inmobiliarias/list.blade.php @@ -19,7 +19,7 @@
{{$inmobiliaria->abreviacion}}
-
{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}
+
{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad?->descripcion ?? ''}}
{{$inmobiliaria->rut()}}
-- 2.49.0 From d6e146dc31ef28aadf1634c9294d17e6bc7d3311 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 11:15:09 -0300 Subject: [PATCH 2/6] FIX: cast id to int --- app/src/Service/Venta/Propietario.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/Service/Venta/Propietario.php b/app/src/Service/Venta/Propietario.php index cd1a809..c2a8c03 100644 --- a/app/src/Service/Venta/Propietario.php +++ b/app/src/Service/Venta/Propietario.php @@ -181,7 +181,8 @@ class Propietario extends Service ]); $filtered_data = array_intersect_key($data, $fields); try { - $direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtraAndComuna($filtered_data['calle'], $filtered_data['numero'], $filtered_data['extra'], $filtered_data['comuna']); + $direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtraAndComuna($filtered_data['calle'], + $filtered_data['numero'], $filtered_data['extra'], (int) $filtered_data['comuna']); } catch (EmptyResult) { try { $direccion = $this->direccionRepository->create($filtered_data); -- 2.49.0 From fa2b9d130bcbdaea9fb91d43ef186899d15739aa Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 11:47:13 -0300 Subject: [PATCH 3/6] Log exception processor --- .../Implement/Log/Processor/Exception.php | 66 +++++++++++++++++++ app/setup/setups/logs.php | 1 + 2 files changed, 67 insertions(+) create mode 100644 app/common/Implement/Log/Processor/Exception.php diff --git a/app/common/Implement/Log/Processor/Exception.php b/app/common/Implement/Log/Processor/Exception.php new file mode 100644 index 0000000..65211b1 --- /dev/null +++ b/app/common/Implement/Log/Processor/Exception.php @@ -0,0 +1,66 @@ +context; + foreach ($context as $key => $value) { + if (is_a($value, Throwable::class)) { + $exception = $value; + $output = $this->processException($exception); + $context[$key] = $output; + $new_record = new LogRecord( + $record->datetime, + $record->channel, + $record->level, + $record->message, + $context, + $record->extra + ); + $record = $new_record; + } + } + if (is_a($record->message, Throwable::class)) { + $exception = $record->message; + $output = $this->processException($exception); + $message = $output['message']; + if (array_key_exists('exception', $context)) { + $context['other_exception'] = $context['exception']; + } + $context['exception'] = $output; + $new_record = new LogRecord( + $record->datetime, + $record->channel, + $record->level, + $message, + $context, + $record->extra + ); + $record = $new_record; + } + + return $record; + } + + protected function processException(Throwable $exception): array + { + $output = [ + 'class' => get_class($exception), + 'code' => $exception->getCode(), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'trace' => $exception->getTraceAsString(), + ]; + if ($exception->getPrevious() !== null) { + $output['previous'] = $this->processException($exception); + } + return $output; + } +} diff --git a/app/setup/setups/logs.php b/app/setup/setups/logs.php index c96cd40..46e5a7e 100644 --- a/app/setup/setups/logs.php +++ b/app/setup/setups/logs.php @@ -25,6 +25,7 @@ return [ $container->get(Monolog\Processor\MemoryPeakUsageProcessor::class), $container->get(Monolog\Processor\PsrLogMessageProcessor::class), $container->get(Monolog\Processor\UidProcessor::class), + $container->get(Incoviba\Common\Implement\Log\Processor\Exception::class), ]; }, 'baseDefaultHandlers' => function(ContainerInterface $container) { -- 2.49.0 From 032d00fbb6cf18635602cbef4dee353ceded6f9d Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 11:48:11 -0300 Subject: [PATCH 4/6] Exception history --- app/src/Service/Money/Ine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/Service/Money/Ine.php b/app/src/Service/Money/Ine.php index 24c693c..a4d78cf 100644 --- a/app/src/Service/Money/Ine.php +++ b/app/src/Service/Money/Ine.php @@ -48,8 +48,8 @@ class Ine implements Provider ]); try { $response = $this->client->get($request_uri); - } catch (GuzzleException) { - throw new EmptyResponse($request_uri); + } catch (GuzzleException $exception) { + throw new EmptyResponse($request_uri, $exception); } $body = $response->getBody(); $json = json_decode($body->getContents()); -- 2.49.0 From fe8bbb57676d2f2e7cac5a52ecabcbd390eec537 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 11:56:05 -0300 Subject: [PATCH 5/6] Use exception processor --- .../Implement/Log/Processor/Exception.php | 30 ++++++++++--------- app/src/Service/Queue.php | 8 +---- app/src/Service/Venta/Reservation.php | 2 +- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/app/common/Implement/Log/Processor/Exception.php b/app/common/Implement/Log/Processor/Exception.php index 65211b1..d02431d 100644 --- a/app/common/Implement/Log/Processor/Exception.php +++ b/app/common/Implement/Log/Processor/Exception.php @@ -10,21 +10,23 @@ class Exception implements ProcessorInterface public function __invoke(LogRecord $record): LogRecord { $context = $record->context; - foreach ($context as $key => $value) { - if (is_a($value, Throwable::class)) { - $exception = $value; - $output = $this->processException($exception); - $context[$key] = $output; - $new_record = new LogRecord( - $record->datetime, - $record->channel, - $record->level, - $record->message, - $context, - $record->extra - ); - $record = $new_record; + $changed = false; + array_walk_recursive($context, function (&$item) use (&$changed) { + if (is_a($item, Throwable::class)) { + $item = $this->processException($item); + $changed = true; } + }); + if ($changed) { + $new_record = new LogRecord( + $record->datetime, + $record->channel, + $record->level, + $record->message, + $context, + $record->extra + ); + $record = $new_record; } if (is_a($record->message, Throwable::class)) { $exception = $record->message; diff --git a/app/src/Service/Queue.php b/app/src/Service/Queue.php index 0513554..754c44b 100644 --- a/app/src/Service/Queue.php +++ b/app/src/Service/Queue.php @@ -79,13 +79,7 @@ class Queue extends Ideal\Service try { $this->jobService->update($job); } catch (Update $exception) { - $this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]]); + $this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]); } return false; } diff --git a/app/src/Service/Venta/Reservation.php b/app/src/Service/Venta/Reservation.php index f6d3141..3be8c93 100644 --- a/app/src/Service/Venta/Reservation.php +++ b/app/src/Service/Venta/Reservation.php @@ -174,7 +174,7 @@ class Reservation extends Ideal\Service\API $this->reservationRepository->getConnection()->getPDO()->commit(); } } catch (PDOException $exception) { - $this->logger->warning($exception->getMessage(), ['exception' => $exception->getTraceAsString()]); + $this->logger->warning($exception->getMessage(), ['exception' => $exception]); if ($this->reservationRepository->getConnection()->getPDO()->inTransaction()) { $this->reservationRepository->getConnection()->getPDO()->rollBack(); } -- 2.49.0 From ecae3147d484015990c6838cc17702b9f439e509 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 12:09:54 -0300 Subject: [PATCH 6/6] Get values when 0 --- app/src/Controller/API/Money.php | 2 +- app/src/Service/IPC.php | 2 +- app/src/Service/UF.php | 8 ++++++-- app/src/Service/USD.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/Controller/API/Money.php b/app/src/Controller/API/Money.php index a13d14a..ea74f10 100644 --- a/app/src/Controller/API/Money.php +++ b/app/src/Controller/API/Money.php @@ -53,7 +53,7 @@ class Money } try { $this->data[$provider] = (array) $this->fetchRedis($redisService, $redisKey); - if (!isset($this->data[$provider][$date->format('Y-m-d')])) { + if (!isset($this->data[$provider][$date->format('Y-m-d')]) or $this->data[$provider][$date->format('Y-m-d')] === 0) { throw new EmptyRedis($redisKey); } } catch (EmptyRedis) { diff --git a/app/src/Service/IPC.php b/app/src/Service/IPC.php index b75398d..b8a51b2 100644 --- a/app/src/Service/IPC.php +++ b/app/src/Service/IPC.php @@ -21,7 +21,7 @@ class IPC $ipcs = []; try { $ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); - if (!isset($ipcs[$dateKey])) { + if (!isset($ipcs[$dateKey]) or $ipcs[$dateKey] === 0) { throw new EmptyRedis($this->redisKey); } } catch (EmptyRedis) { diff --git a/app/src/Service/UF.php b/app/src/Service/UF.php index 58d80b0..c99771f 100644 --- a/app/src/Service/UF.php +++ b/app/src/Service/UF.php @@ -22,7 +22,7 @@ class UF if ($date === null) { $date = new DateTimeImmutable(); } - if ($date->diff($today)->days < 0) { + if ($date->diff($today)->invert === 1) { return 0.0; } /** @@ -32,7 +32,7 @@ class UF */ try { $ufs = $this->getRedisUFs(); - if (!isset($ufs[$date->format('Y-m-d')])) { + if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) { throw new EmptyRedis($this->redisKey); } return $ufs[$date->format('Y-m-d')]; @@ -54,12 +54,16 @@ class UF } public function updateMany(array $dates): array { + $today = new DateTimeImmutable(); $ufs = []; try { $ufs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); } catch (EmptyRedis) {} $updated = []; foreach ($dates as $date) { + if ($date->diff($today)->invert === 1) { + continue; + } if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) { $uf = $this->moneyService->getUF($date); if ($uf === 0.0) { diff --git a/app/src/Service/USD.php b/app/src/Service/USD.php index edfeed5..21f343c 100644 --- a/app/src/Service/USD.php +++ b/app/src/Service/USD.php @@ -19,7 +19,7 @@ class USD $usds = []; try { $usds = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); - if (!isset($usds[$date->format('Y-m-d')])) { + if (!isset($usds[$date->format('Y-m-d')]) or $usds[$date->format('Y-m-d')] === 0) { throw new EmptyRedis($this->redisKey); } $usd = $usds[$date->format('Y-m-d')]; -- 2.49.0