Opened 4 years ago
Closed 4 years ago
#8619 closed defect (bug) (fixed)
Undefined variable when handle avatar crop
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 10.1.0 | Priority: | normal |
| Severity: | normal | Version: | 10.0.0 |
| Component: | Core | Keywords: | has-patch |
| Cc: |
Description
I noticed this problem when I was doing a detailed review after BuddyPress 10 release.
There is no variable called $r in bp_members_screen_change_avatar() function. It should be $args. Commit https://buddypress.trac.wordpress.org/changeset/13177/trunk/src/bp-members/screens/change-avatar.php
I don't see any problem with in Legacy and Nouveau template pack. We can fix this in 10.1 if I don't missing something important.
Change History (7)
#2
@
4 years ago
- Keywords has-patch added
- Version set to 10.0.0
Good catch and thanks for finding this early!
No problemo, we'll fix this asap.
#3
@
4 years ago
I've found an another undefined variable usage in bp_nouveau_ajax_post_update() function. I think $group_id should be $item_id.
diff --git a/src/bp-templates/bp-nouveau/includes/activity/ajax.php b/src/bp-templates/bp-nouveau/includes/activity/ajax.php
index 0043e9d4c..6e81f3a88 100644
--- a/src/bp-templates/bp-nouveau/includes/activity/ajax.php
+++ b/src/bp-templates/bp-nouveau/includes/activity/ajax.php
@@ -552,7 +552,7 @@ function bp_nouveau_ajax_post_update() {
if ( ! empty( $bp->groups->current_group->status ) ) {
$status = $bp->groups->current_group->status;
} else {
- $group = groups_get_group( array( 'group_id' => $group_id ) );
+ $group = groups_get_group( array( 'group_id' => $item_id ) );
$status = $group->status;
}
BTW I wish I had seen this problem sooner but I was testing new release as an end user. I noticed the problem when I was doing full code review for production release.
Patch:
diff --git a/src/bp-members/screens/change-avatar.php b/src/bp-members/screens/change-avatar.php index 6a421ec77..8a64dd95e 100644 --- a/src/bp-members/screens/change-avatar.php +++ b/src/bp-members/screens/change-avatar.php @@ -62,7 +62,7 @@ function bp_members_screen_change_avatar() { ); // Handle crop. - $cropped_avatar = bp_core_avatar_handle_crop( $r, 'array' ); + $cropped_avatar = bp_core_avatar_handle_crop( $args, 'array' ); if ( ! $cropped_avatar ) { bp_core_add_message( __( 'There was a problem cropping your profile photo.', 'buddypress' ), 'error' );