refactor: avoid recursive loop in some condition

This commit is contained in:
Hugo Poissonnet 2022-10-19 19:47:06 +02:00
parent 5ff62ba34a
commit 2a154a6eea

View File

@ -292,7 +292,7 @@ function getFileMetadata( $dsn, $url )
return $metadata; return $metadata;
} }
function getOtherVersionUrls( $url ) function getOtherWordpressVersionUrls( $url )
{ {
global $dsn; global $dsn;
$path = parse_url($url, PHP_URL_PATH); $path = parse_url($url, PHP_URL_PATH);
@ -450,12 +450,6 @@ function handle404( $sourcePath, $url )
http_response_code( 301 ); http_response_code( 301 );
exit( 0 ); exit( 0 );
break; break;
case ( $LOADER['WORDPRESS_FIX_MISSING_VERSION'] ) :
$otherVersionFound = getOtherVersionUrls($url);
if ( $otherVersionFound ) {
render( $otherVersionFound, $sourcePath, $url );
break;
}
default: default:
http_response_code( 404 ); http_response_code( 404 );
} }
@ -612,7 +606,12 @@ try {
exit( 0 ); exit( 0 );
} }
if ( $LOADER['ARCHIVARIX_LOADER_MODE'] == 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 ) { if ( $LOADER['ARCHIVARIX_LOADER_MODE'] > 0 ) {
include __DIR__ . DIRECTORY_SEPARATOR . 'index.php'; include __DIR__ . DIRECTORY_SEPARATOR . 'index.php';