ver. 0.294: Code review complete — 96/96 classes, 27 fixes across all layers
Full codebase review of autoload/ directory (96 classes, ~1144 methods). Fixes: null safety (query/find guards), redundant DI bypass, undefined variables, missing globals, and Imagick WebP mime type bug in Helpers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,11 @@ class App
|
||||
if ( $result == 1 )
|
||||
{
|
||||
$user = $users->details( $login );
|
||||
if ( !$user ) {
|
||||
\Shared\Helpers\Helpers::alert( 'Błąd logowania.' );
|
||||
header( 'Location: /admin/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $user['twofa_enabled'] == 1 )
|
||||
{
|
||||
@@ -116,6 +121,12 @@ class App
|
||||
}
|
||||
|
||||
$user = $users->details( $pending['login'] );
|
||||
if ( !$user ) {
|
||||
\Shared\Helpers\Helpers::delete_session( 'twofa_pending' );
|
||||
\Shared\Helpers\Helpers::alert( 'Sesja wygasła. Zaloguj się ponownie.' );
|
||||
header( 'Location: /admin/' );
|
||||
exit;
|
||||
}
|
||||
self::finalize_admin_login( $user, $domain, $cookie_name, !empty( $pending['remember'] ) );
|
||||
header( 'Location: /admin/articles/list/' );
|
||||
exit;
|
||||
|
||||
@@ -165,7 +165,7 @@ class BannerController
|
||||
public function edit(): string
|
||||
{
|
||||
$bannerId = (int)\Shared\Helpers\Helpers::get('id');
|
||||
$banner = $this->repository->find($bannerId);
|
||||
$banner = $this->repository->find($bannerId) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
|
||||
// Sprawdź czy są błędy walidacji z poprzedniego requestu
|
||||
@@ -187,9 +187,9 @@ class BannerController
|
||||
$response = ['success' => false, 'errors' => []];
|
||||
|
||||
$bannerId = (int)\Shared\Helpers\Helpers::get('id');
|
||||
$banner = $this->repository->find($bannerId);
|
||||
$banner = $this->repository->find($bannerId) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
|
||||
|
||||
$viewModel = $this->buildFormViewModel($banner, $languages);
|
||||
|
||||
// Przetwórz dane z POST
|
||||
|
||||
@@ -58,7 +58,7 @@ class PagesController
|
||||
|
||||
public function menuEdit(): string
|
||||
{
|
||||
$menu = $this->repository->menuDetails((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$menu = $this->repository->menuDetails((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
|
||||
return \Shared\Tpl\Tpl::view('pages/menu-edit', [
|
||||
'form' => $this->buildMenuFormViewModel($menu),
|
||||
@@ -167,7 +167,7 @@ class PagesController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$page = $this->repository->pageDetails((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$page = $this->repository->pageDetails((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$parentId = (int)\Shared\Helpers\Helpers::get('pid');
|
||||
$menuId = (int)\Shared\Helpers\Helpers::get('menu_id');
|
||||
$menus = $this->repository->menusList();
|
||||
|
||||
@@ -60,7 +60,7 @@ class ProductArchiveController
|
||||
$imageSrc = '/' . ltrim($imageSrc, '/');
|
||||
}
|
||||
|
||||
$categories = trim((string)$this->repository->productCategoriesText($id));
|
||||
$categories = trim((string)$this->productRepository->productCategoriesText($id));
|
||||
$categoriesHtml = '';
|
||||
if ($categories !== '') {
|
||||
$categoriesHtml = '<small class="text-muted product-categories">'
|
||||
|
||||
@@ -137,7 +137,7 @@ class ScontainersController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$container = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$container = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
$validationErrors = $_SESSION['form_errors'][$this->formId()] ?? null;
|
||||
if ($validationErrors) {
|
||||
@@ -172,7 +172,7 @@ class ScontainersController
|
||||
exit;
|
||||
}
|
||||
|
||||
$container = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$container = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
$form = $this->buildFormViewModel($container, $languages);
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class ShopAttributeController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$attribute = $this->repository->findAttribute((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$attribute = $this->repository->findAttribute((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
|
||||
return \Shared\Tpl\Tpl::view('shop-attribute/attribute-edit', [
|
||||
|
||||
@@ -172,7 +172,7 @@ class ShopCouponController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$coupon = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$coupon = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$categories = $this->repository->categoriesTree(null);
|
||||
|
||||
return \Shared\Tpl\Tpl::view('shop-coupon/coupon-edit-new', [
|
||||
|
||||
@@ -146,7 +146,7 @@ class ShopProducerController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$producer = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$producer = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
$validationErrors = $_SESSION['form_errors'][$this->formId()] ?? null;
|
||||
if ($validationErrors) {
|
||||
@@ -204,7 +204,7 @@ class ShopProducerController
|
||||
}
|
||||
|
||||
// Nowy flow (form-edit)
|
||||
$producer = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$producer = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
$form = $this->buildFormViewModel($producer, $languages);
|
||||
|
||||
|
||||
@@ -216,8 +216,8 @@ class ShopProductController
|
||||
|
||||
$db = $GLOBALS['mdb'];
|
||||
|
||||
$product = $this->repository->findForAdmin( (int) \Shared\Helpers\Helpers::get( 'id' ) );
|
||||
$languages = ( new \Domain\Languages\LanguagesRepository( $db ) )->languagesList();
|
||||
$product = $this->repository->findForAdmin( (int) \Shared\Helpers\Helpers::get( 'id' ) ) ?: [];
|
||||
$languages = $this->languagesRepository->languagesList();
|
||||
$categories = ( new CategoryRepository( $db ) )->subcategories( null );
|
||||
$layouts = $this->layoutsForProductEdit( $db );
|
||||
$products = $this->repository->allProductsList();
|
||||
@@ -920,7 +920,7 @@ class ShopProductController
|
||||
*/
|
||||
public function ajax_product_url(): void
|
||||
{
|
||||
echo json_encode( [ 'url' => ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->getProductUrl( (int) \Shared\Helpers\Helpers::get( 'product_id' ) ) ] );
|
||||
echo json_encode( [ 'url' => $this->repository->getProductUrl( (int) \Shared\Helpers\Helpers::get( 'product_id' ) ) ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ class ShopProductController
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas generowania kodu sku wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
$sku = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->generateSkuCode();
|
||||
$sku = $this->repository->generateSkuCode();
|
||||
if ( $sku ) {
|
||||
$response = [ 'status' => 'ok', 'sku' => $sku ];
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class ShopProductSetsController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$set = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$set = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$products = $this->repository->allProductsMap();
|
||||
|
||||
return \Shared\Tpl\Tpl::view('shop-product-sets/product-set-edit', [
|
||||
|
||||
@@ -136,7 +136,7 @@ class ShopPromotionController
|
||||
|
||||
public function edit(): string
|
||||
{
|
||||
$promotion = $this->repository->find((int)\Shared\Helpers\Helpers::get('id'));
|
||||
$promotion = $this->repository->find((int)\Shared\Helpers\Helpers::get('id')) ?: [];
|
||||
$categories = $this->repository->categoriesTree(null);
|
||||
|
||||
return \Shared\Tpl\Tpl::view('shop-promotion/promotion-edit', [
|
||||
|
||||
Reference in New Issue
Block a user