add urldecode on read a private file and try/catch on `pre_delete_attachment` logs

This commit is contained in:
vnmedeiros 2020-06-30 14:45:05 -03:00
parent 914ea388ef
commit c3148daa91
3 changed files with 44 additions and 40 deletions

View File

@ -256,7 +256,7 @@ class REST_Collections_Controller extends REST_Controller {
} }
// Clear private metadata from metadata_order // Clear private metadata from metadata_order
if ( is_array( $item_arr['metadata_order'] ) && ! current_user_can( 'tnc_col_' . $item->get_id() . '_read_private_metadata' ) ) { if ( isset($item_arr['metadata_order']) && is_array( $item_arr['metadata_order'] ) && ! current_user_can( 'tnc_col_' . $item->get_id() . '_read_private_metadata' ) ) {
$metadata = $item->get_metadata(); $metadata = $item->get_metadata();
$meta_ids = array_map( $meta_ids = array_map(
@ -275,7 +275,7 @@ class REST_Collections_Controller extends REST_Controller {
} }
// Clear private filters from filters_order // Clear private filters from filters_order
if ( is_array( $item_arr['filters_order'] ) && ! current_user_can( 'tnc_col_' . $item->get_id() . '_read_private_filters' ) ) { if ( isset($item_arr['filters_order']) && is_array( $item_arr['filters_order'] ) && ! current_user_can( 'tnc_col_' . $item->get_id() . '_read_private_filters' ) ) {
$filters = $item->get_filters(); $filters = $item->get_filters();
$filters_ids = array_map( $filters_ids = array_map(

View File

@ -202,7 +202,7 @@ class Private_Files {
$file_path = \str_replace( '/', $this->dir_separator, str_replace($base_upload_url, '', $requested_uri) ); $file_path = \str_replace( '/', $this->dir_separator, str_replace($base_upload_url, '', $requested_uri) );
$file = $upload_dir['basedir'] . $file_path; $file = urldecode($upload_dir['basedir'] . $file_path);
$existing_file = false; $existing_file = false;
@ -262,8 +262,9 @@ class Private_Files {
* private uploads folder prefix from the attachments URLs * private uploads folder prefix from the attachments URLs
*/ */
function image_get_intermediate_size($data, $post_id, $size) { function image_get_intermediate_size($data, $post_id, $size) {
if(isset($data['path']))
$data['path'] = str_replace($this->dir_separator . $this->get_private_folder_prefix(), $this->dir_separator, $data['path']); $data['path'] = str_replace($this->dir_separator . $this->get_private_folder_prefix(), $this->dir_separator, $data['path']);
if(isset($data['url']))
$data['url'] = str_replace('/' . $this->get_private_folder_prefix(), '/', $data['url']); $data['url'] = str_replace('/' . $this->get_private_folder_prefix(), '/', $data['url']);
return $data; return $data;

View File

@ -309,7 +309,7 @@ class Logs extends Repository {
$entity_post = get_post($attachment_post->post_parent); $entity_post = get_post($attachment_post->post_parent);
if ( $entity_post ) { if ( $entity_post ) {
try {
$entity = Repository::get_entity_by_post( $entity_post ); $entity = Repository::get_entity_by_post( $entity_post );
if ( $entity ) { if ( $entity ) {
@ -345,6 +345,9 @@ class Logs extends Repository {
$this->current_attachment_delete_log = $log; $this->current_attachment_delete_log = $log;
} }
} catch (\Exception $e) {
error_log("[pre_delete_attachment]:" . $e->getMessage());
}
} }
} }