Return 400 instead of 500 when duplicate (#3355)

Fixes #3319
This commit is contained in:
྅༻ Ǭɀħ ༄༆ཉ 2022-05-29 14:48:08 +02:00 committed by GitHub
parent e79b33c706
commit 19eb4d5d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -84,6 +84,7 @@ function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
yourls_trim_long_string($url), preg_replace('!https?://!', '', yourls_get_yourls_site()) . '/'. $url_exists->keyword );
$return['title'] = $url_exists->title;
$return['shorturl'] = yourls_link($url_exists->keyword);
$return['errorCode'] = $return['statusCode'] = '400'; // 400 Bad Request
return yourls_apply_filter( 'add_new_link_already_stored_filter', $return, $url, $keyword, $title );
}

View File

@ -461,7 +461,7 @@ function yourls_get_HTTP_status( $code ) {
510 => 'Not Extended'
];
return isset( $headers_desc[ $code ] ) ? $headers_desc[ $code ] : '';
return $headers_desc[$code] ?? '';
}
/**