Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#8189 closed defect (bug) (wontfix)

buddypress-xprofile-rich-text-field (PHP 7+ warnings) - variable checking needs to be done

Reported by: thezman's profile theZman Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords:
Cc:

Description

File: buddypress-xprofile-rich-text-field.php

Problem: slows down sites with many profile fields and fill up logging with warnings. (For example, a site with 50+ custom profile fields of varying types is a big problem.)

PHP warning:
Trying to get property 'field_id' of non-object in wp-content/plugins/bp-xprofile-rich-text-field/buddypress-xprofile-rich-text-field.php on line 190

To fix line 190 better variable checking needs to be done since this function hooks into EVERY single xprofile_get_field_data() call and does not consider that sometimes an ID is passed instead of an object.

============ PATCH =============

<?php
//check if this is an object or a number to prevent PHP 7 warnings
if(is_object( $data_obj)) { $field_id =  $data_obj->field_id;}
if(!is_object( $data_obj) && is_numeric($data_obj)) { $field_id =  $data_obj;}

// THEN get field from data object
$field = new BP_XProfile_Field( $field_id);

// if this isn't our field, skip amending allowed tags
if ( $field->type != 'richtext' ) { return $allowedtags;  }


============ END PATCH =============

Change History (3)

#1 @imath
5 years ago

Thanks a lot for your feedback @theZman I'll look at it asap.

#2 @imath
4 years ago

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

Hi @theZman

After a closer look into it, we cannot do this fix: it has to be done by the author of this plugin https://wordpress.org/plugins/bp-xprofile-rich-text-field/

#3 @needle
4 years ago

Hi @theZman The announcement that the "Buddypress xProfile Rich Text Field" plugin was going to be retired was published over 5 years ago:

https://wordpress.org/support/topic/the-end-of-a-useful-life/

I strongly advise you to migrate your data to the built-in BuddyPress Rich Text Field since there won't be any updates to the plugin.

Note: See TracTickets for help on using tickets.