We have moved to Github. Please open tickets there.

Opened 3 years ago

Last modified 2 years ago

#2549 new Enhancement

Use negative priority in elgg_extend_view() for prepending

Reported by: brettp Owned by:
Priority: low Milestone: Near Term Future Release
Component: Core Version: Github Master
Severity: annoying Keywords:
Cc: brettp Difficulty: trivial

Description

Setting the epoch at 500 is a bit weird. Can be easily backward compatible by subtracting 500 from the view priority, then emitting a deprecation notice if the number is negative.

Change History (8)

comment:1 Changed 3 years ago by ewinslow

  • Owner set to ewinslow
  • Status changed from new to assigned

comment:2 Changed 3 years ago by ewinslow

in javascript I created an ElggPriorityList data structure that takes care of these issues. Might it be useful to do the same for PHP? The prioritized list comes up several times throughout core and I think it would be convenient to have an abstraction for it.

comment:3 Changed 3 years ago by ewinslow

  • Summary changed from Use negative priority in elgg_extend_view() for prepending to Set priority epoch at 0 instead of 500

comment:4 Changed 3 years ago by brettp

Cases for priority lists that can benefit from abstraction:

  • Views
  • Plugin order

Others?

When I originally wrote this ticket, I wasn't thinking to change all the priority lists to epoch = 0 because other lists don't have a concept of prepending. For elgg_extend_view() passing a negative number would do something markedly different than a positive number. With other lists, this isn't true; numbers are just flat priorities. I don't think there'd be a problem with changing this on other functions as long as we deprecated the same way as elgg_extend_view().

comment:5 Changed 3 years ago by ewinslow

Yea, I realized this when I started implementing it -- that there's no "prepend" concept for plugin hooks or events, so the only concern I'd have is whether it would be confusing to have one priority default to 0 and another default to 500.

comment:6 Changed 2 years ago by ewinslow

  • Summary changed from Set priority epoch at 0 instead of 500 to Use negative priority in elgg_extend_view() for prepending

comment:7 Changed 2 years ago by ewinslow

  • Owner ewinslow deleted
  • Status changed from assigned to new

comment:8 Changed 2 years ago by cash

  • Milestone changed from Elgg 1.8 to Elgg 1.9
Note: See TracTickets for help on using tickets.