Skip to content

Commit

Permalink
fix: handles the case when array access null
Browse files Browse the repository at this point in the history
  • Loading branch information
the-hercules committed Sep 18, 2024
1 parent 2b72ee0 commit a891170
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions app/main/controllers/template/RTMediaTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,11 @@ public function save_single_edit() {
wp_update_attachment_metadata( $rtmedia_query->media[0]->media_id, $image_meta_data );
}

$state = $media->update( $rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id );

if ( isset( $rtmedia_query->action_query->id ) && isset( $rtmedia_query->media[0]->media_id ) ) {
$state = $media->update( $rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id );
} else {
$state = false; // or handle the error as needed
}
$rtmedia_filepath_old = sanitize_text_field( filter_input( INPUT_POST, 'rtmedia-filepath-old', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) );
if ( isset( $rtmedia_filepath_old ) ) {
$is_valid_url = preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $rtmedia_filepath_old );
Expand Down
2 changes: 1 addition & 1 deletion app/main/controllers/template/rtmedia-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function rtmedia_add_album_selection_field( $media_type ) {
}
?>
<div class="rtmedia-edit-change-album rtm-field-wrap">
<label for=""><?php esc_html_e( 'Album', 'buddypress-media' ); ?> : </label>
<label ><?php esc_html_e( 'Album', 'buddypress-media' ); ?> : </label>
<?php
if ( isset( $rtmedia_query->query['context'] ) && 'group' === $rtmedia_query->query['context'] ) {
// show group album list.
Expand Down
12 changes: 8 additions & 4 deletions app/main/controllers/template/rtmedia-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,10 @@ function rtmedia_delete_allowed() {

global $rtmedia_media;

$flag = intval( $rtmedia_media->media_author ) === get_current_user_id();

$flag = false;
if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
$flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
}
if ( ! $flag && isset( $rtmedia_media->context ) && 'group' === $rtmedia_media->context && function_exists( 'bp_group_is_admin' ) ) {
$flag = ( bp_group_is_admin() || bp_group_is_mod() );
}
Expand All @@ -1020,8 +1022,10 @@ function rtmedia_edit_allowed() {

global $rtmedia_media;

$flag = intval( $rtmedia_media->media_author ) === get_current_user_id();

$flag = false;
if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
$flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
}
if ( ! $flag ) {
$flag = is_super_admin() || rtm_is_bp_group_admin() || rtm_is_bp_group_mod();
}
Expand Down

0 comments on commit a891170

Please sign in to comment.