From 2a154a6eea510e08b2608fd55f6729056c363b25 Mon Sep 17 00:00:00 2001 From: HugoPoi Date: Wed, 19 Oct 2022 19:47:06 +0200 Subject: [PATCH] refactor: avoid recursive loop in some condition --- www/index.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/www/index.php b/www/index.php index 3b7e777..9ab9293 100644 --- a/www/index.php +++ b/www/index.php @@ -292,7 +292,7 @@ function getFileMetadata( $dsn, $url ) return $metadata; } -function getOtherVersionUrls( $url ) +function getOtherWordpressVersionUrls( $url ) { global $dsn; $path = parse_url($url, PHP_URL_PATH); @@ -450,12 +450,6 @@ function handle404( $sourcePath, $url ) http_response_code( 301 ); exit( 0 ); break; - case ( $LOADER['WORDPRESS_FIX_MISSING_VERSION'] ) : - $otherVersionFound = getOtherVersionUrls($url); - if ( $otherVersionFound ) { - render( $otherVersionFound, $sourcePath, $url ); - break; - } default: http_response_code( 404 ); } @@ -612,7 +606,12 @@ try { exit( 0 ); } if ( $LOADER['ARCHIVARIX_LOADER_MODE'] == 0 ) { - handle404( $sourcePath, $url ); + if ( $LOADER['WORDPRESS_FIX_MISSING_VERSION'] && ($otherVersionFound = getOtherWordpressVersionUrls($url)) ) { + render( $otherVersionFound, $sourcePath, $url ); + } else { + handle404( $sourcePath, $url ); + exit( 0 ); + } } if ( $LOADER['ARCHIVARIX_LOADER_MODE'] > 0 ) { include __DIR__ . DIRECTORY_SEPARATOR . 'index.php';