Skip to:
Content

BuddyPress.org

Opened 3 years ago

Last modified 2 years ago

#8702 assigned defect (bug)

php 8.0 warnings

Reported by: webmasterfreya's profile webmasterfreya Owned by: dcavins's profile dcavins
Milestone: Awaiting Contributions Priority: low
Severity: minor Version: 10.2.0
Component: Emails Keywords: needs-patch
Cc: webmaster@…, webmasterfreya

Description

BuddyPress Versie 10.2.0, WordPress 5.9.3, bbPress 2.6.9, BP Theme Legacy, PHP 8.0.18

[Tue May 10 10:15:07.638905 2022] [proxy_fcgi:error] [pid 30152]
[client 62.195.71.141:52876]
AH01071: Got error 'PHP message: PHP Warning: Undefined array key "membership.id" in
/var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/deprecated/2.5.php on line 873
PHP message: PHP Warning: Undefined array key "membership.id" in
/var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/deprecated/2.5.php on line 873',
referer: https://www.freya.nl/groepen/ivf/request-membership/?_wpnonce=3b82686070

[Tue May 10 10:22:12.649239 2022] [proxy_fcgi:error] [pid 30152] [client 62.195.71.141:54286]
AH01071: Got error 'PHP message: PHP Warning: Attempt to read property "ID" on null in
/var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-query.php on line 4121
PHP message: PHP Warning: Attempt to read property "post_title" on null in
/var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-query.php on line 4123
PHP message: PHP Warning: Attempt to read property "post_name" on null in
/var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-query.php on line 4125
PHP message: PHP Warning: Attempt to read property "post_type" on null in
/var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-query.php on line 4273',
referer: https://www.freya.nl/groepen/ivf/

Change History (11)

#1 @imath
3 years ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hi @webmasterfreya

Thanks a lot for your report. You have some code into your WordPress config using this deprecated hook bp_groups_sent_membership_request_email This hook is deprecated since version 2.5.

I advise you to perform a global text search into your /wp-content site's folder looking for this text 'bp_groups_sent_membership_request_email' to find the plugin, the theme or some other custom code which is using this hook then contact the code's author to update it so that it now uses the bp_send_email hook checking the 2nd argument it returns equals groups-membership-request.

I don't think we need to work on this, that's why I'm going to close this ticket. But if you think I'm wrong, don't hesitate to reopen it with your reasons why we should fix this.

#2 @webmasterfreya
3 years ago

Did a search, but the only place that the string is found is in 2.5.php . So i'm lost.

find /var/www/vhosts/freya.nl -type f -name \*.php -exec grep -nwH 'bp_groups_sent_membership_request_email' {} \;
/var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/deprecated/2.5.php:873: do_action( 'bp_groups_sent_membership_request_email', $tokensadmin.id?, $email_subject, $email_content, $tokensrequesting-user.id?, $tokensgroup.id?, $tokensmembership.id? );
root@s01:/var/www/vhosts/freya.nl#

However:

\wp-content\plugins\buddypress\bp-groups\bp-groups-notifications.php line 166 admin.id is set
\wp-content\plugins\buddypress\bp-members\bp-members-membership-requests.php line 200 admin.id is set
\wp-content\plugins\buddypress\bp-groups\bp-groups-notifications.php line 172 and 219 requesting-user.id is set
\wp-content\plugins\buddypress\bp-groups\bp-groups-notifications.php line 91,169,216 and 292 group.id is set

membership.id is nowhere set, so that explaines the warning.

Last edited 3 years ago by webmasterfreya (previous) (diff)

#3 @webmasterfreya
3 years ago

  • Cc webmasterfreya added
  • Keywords needs-patch added
  • Milestone set to Awaiting Review
  • Resolution worksforme deleted
  • Status changed from closed to reopened

PHP message: called deprecated buddypress function
PHP message:
#0 /var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-hook.php(307): bp_core_deprecated_email_actions()
#1 /var/www/vhosts/freya.nl/httpdocs/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#2 /var/www/vhosts/freya.nl/httpdocs/wp-includes/plugin.php(474): WP_Hook->do_action()
#3 /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/bp-core-functions.php(3681): do_action()
#4 /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-groups/bp-groups-notifications.php(178): bp_send_email()
#5 /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-invitation-manager.php(48): groups_notification_new_membership_request()
#6 /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/classes/class-bp-invitation-manager.php(360): BP_Groups_Invitation_Manager->run_send_action()
#7 /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-groups/bp-groups-functions.php(2196): BP_Invitation_Manage...

PHP message: PHP Warning: Undefined array key "membership.id" in /var/www/vhosts/freya.nl/httpdocs/wp-content/plugins/buddypress/bp-core/deprecated/2.5.php on line 877', referer: https://www.freya.nl/groepen/ivf/request-membership/?_wpnonce=c86d8699d5

#4 follow-up: @imath
3 years ago

  • Keywords 2nd-opinion added

@dcavins could you have a look at this? Ticket was reopened after I’ve closed it (I thought a plug-in was using a deprecated hook). I’m wondering if we need to change something to make the notice disappear ?

#5 in reply to: ↑ 4 @dcavins
3 years ago

Replying to imath:

@dcavins could you have a look at this? Ticket was reopened after I’ve closed it (I thought a plug-in was using a deprecated hook). I’m wondering if we need to change something to make the notice disappear ?

I'll happily take a look tomorrow!

#6 @dcavins
3 years ago

I see what @webmasterfreya is saying, but unless the deprecated code file 2.5.php is being loaded, I can't see how the action
do_action( 'bp_groups_sent_membership_request_email', $tokens['admin.id'], $email_subject, $email_content, $tokens['requesting-user.id'], $tokens['group.id'], $tokens['membership.id'] );
is being triggered. (I also cannot get this notice to be logged when sending membership requests with php8, BP legacy theme and BP 10.3.)

My doubt is that
* @param int $membership_id ID of the group membership object.
doesn't exist as it used to (it used to be the ID of the unconfirmed group membership row in wp_bp_groups_members, but unconfirmed requests are now stored in wp_bp_invitations).

We could set the token membership.id in bp_send_email( 'groups-membership-request', (int) $admin_id, $args ); to the ID from the wp_bp_invitations table, but code built for BP2.5 would misinterpret that number, so... I'm not sure what the best answer is. I'll attach a patch that restores the token, and updates the documentation in a couple of places.

Here's the commit where I removed the membership.id token: https://github.com/buddypress/buddypress/commit/0604b687e97149af609d239186f2421d9501f302

Thanks for opening this odd ticket!

Last edited 3 years ago by dcavins (previous) (diff)

#7 @webmasterfreya
3 years ago

I took a peek into the table wp_bp_invitations.
There are 53 rows from wich 46 are of non existent users and 7 existent users. Looks like removing users does not clean up this table.

class-buddypress.php 538 is intriging :

Maybe load deprecated functionality (this double negative is proof positive!).
if ( ! bp_get_option( '_bp_ignore_deprecated_code', ! $this->load_deprecated ) ) {

bp-core-options.php 98

Ignore deprecated code.
'_bp_ignore_deprecated_code' => true,

bp-core-update.php 575 [function bp_update_to_2_7() {}]

Do not ignore deprecated code for existing installs.
bp_add_option( '_bp_ignore_deprecated_code', false );

Maybe this helps ?

#8 @imath
3 years ago

  • Component changed from Core to Emails
  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 11.0.0

This ticket should be fixed in #8687 where we've decided to only load deprecated code by the last 2 previous versions of BuddyPress by default.

That being said, I believe we should probably include a new constant to carry on loading all deprecated code. If my belief is ok with the team, then we'll need to fix this warning. So let's include this ticket to 11.0 milestone.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


2 years ago

#10 @dcavins
2 years ago

  • Owner set to dcavins
  • Status changed from reopened to assigned

#11 @imath
2 years ago

  • Milestone changed from 11.0.0 to Awaiting Contributions
Note: See TracTickets for help on using tickets.