Skip to:
Content

BuddyPress.org

Opened 15 years ago

Closed 13 years ago

#3886 closed defect (bug) (fixed)

Audit class methods and mark appropriately as static

Reported by: kayue Owned by:
Priority: normal Milestone: 1.9
Component: Core Version:
Severity: normal Keywords: needs-patch
Cc:

Description (last modified by DJPaul)

Non-static method BP_Core_Notification::get_all_for_user() should not be called statically in /buddypress/bp-members/bp-members-notifications.php line 51

Change History (11)

#1 @kayue
15 years ago

To fix this, in bp-core-classes.php, should add a static keyword before declare the function.

/

  • Fetches all the notifications in the database for a specific user. *
  • @global object $bp Global BuddyPress settings object
  • @global wpdb $wpdb WordPress database object
  • @param integer $user_id User ID
  • @return array Associative array
  • @static */

static function get_all_for_user( $user_id ) {

global $bp, $wpdb;

return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );

}

#2 @DJPaul
15 years ago

  • Description modified (diff)
  • Keywords 1.7-early added
  • Milestone Awaiting Review → Future Release
  • Summary Non-static method BP_Core_Notification::get_all_for_user() should not be called statically → Audit class methods and mark appropriately as static

We need to look at all of BuddyPress, and mark class methods as static where appropriate. There was a conversation on IRC (​https://irclogs.wordpress.org/chanlog.php?channel=buddypress-dev&day=2011-12-21#m155663) between Spadeski and boonebgorges recently about the same thing.

#3 @DJPaul
15 years ago

  • Description modified (diff)

Marking this ticket for 1.7 so we can do all of these at the same time, and make sure we have plenty of time to check for any breakages.

#4 @boonebgorges
14 years ago

  • Keywords 1.7-early removed
  • Milestone Future Release → 1.7
  • Priority normal → low

Moving to 1.7 for further review. Note that we have to make sure that marking items static doesn't break plugins that are extending our core classes, as PHP will throw a fit if you override a method without declaring access levels, etc properly.

#5 @johnjamesjacoby
14 years ago

  • Milestone 1.7 → 1.8

Going to move this to 1.8. There's no complaints or traction in 12 months, so we can iterate on this more in the future.

#6 @boonebgorges
13 years ago

  • Component Notifications → Core
  • Milestone 1.8 → Future Release
  • Priority low → lowest
  • Severity minor → trivial

#7 @boonebgorges
13 years ago

  • Milestone Future Release → 1.9
  • Priority lowest → normal
  • Severity trivial → normal

Because of issues described in #5108, this has become much more of an annoying and pressing issue. Let's look at it in greater depth for 1.9.

#8 @boonebgorges
13 years ago

In 7316:

Explicit PHP5 visibility and static declarations for bp-groups-classes.php

See #5108, #3886

#9 @boonebgorges
13 years ago

In 7317:

Explicit visibility and static declarations in bp-blogs-classes.php

See #3886, #5108

#10 @r-a-y
13 years ago

See #5108. Marking as resolved to clear the milestone.

#11 @r-a-y
13 years ago

  • Resolution → fixed
  • Status new → closed
Note: See TracTickets for help on using tickets.