Feature freeze events in templates

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Feature freeze events in templates

Post by Arty »

I suggest to include template events to feature freeze for 3.2, so minor updates, like 3.2.1, wouldn't add new template events.

Currently in 3.1 styles require updates for every minor release because of array of events that are added to templates. That means authors have to release updates every few months to keep style usable.

In phpBB style authors have no incentive to maintain styles. Many years ago links in footer were good enough incentive, but since Google cracked down on those links, making them almost irrelevant, there are no incentives for designers to release styles and even fewer incentives to maintain released styles.

In phpBB 3.0 minor updates didn't add anything new. Even today styles for 3.0.8, which was released 5 years ago, are compatible with latest phpBB 3.0 version. That's not the case in phpBB 3.1 because events are added in each minor release, which are required by extensions, making outdated styles incompatible with those extensions.

You can already see effect of constantly requiring updates by looking at styles database - there are very few styles for 3.1, number of styles that are up to date is only around 10.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Feature freeze events in templates

Post by DavidIQ »

Are you then saying that if someone wants to create an extension in 3.2.1 that will require a new template event that they're not going to be able to submit said extension to our CDB because it requires modifications to core files?

To me it looks like freezing template events in an entire version slightly helps styles authors while adversely affecting extension authors. I also think that the amount of new template events has already peaked for the most part and should start reducing in occurrence so maybe this isn't that much of a concern in 3.2?
Image

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: Feature freeze events in templates

Post by Arty »

Good point. With current template events system someone will get screwed - ether style devs or extension devs.

Ideally whole system should be replaced with template modifications. It is way more powerful and flexible than template events and would make both style and extension developers happy. However that would require complete overhaul of template engine because it was written as standalone parser without accounting for possibility events.

Nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 299
Joined: Sun Apr 13, 2014 1:40 am
Location: Paris

Re: Feature freeze events in templates

Post by Nicofuma »

What do you mean by template modifications?
Member of the phpBB Development-Team
No Support via PM

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: Feature freeze events in templates

Post by Arty »

Nicofuma wrote: Sun Oct 04, 2015 8:38 am What do you mean by template modifications?
See https://area51.phpbb.com/phpBB/viewtopi ... 3&start=80 (second part of post and there is discussion on previous page of that thread)

Its an idea implemented in vBulletin many years ago as third party add-on that quickly became very popular among add-on developers because of how powerful it is. Also implemented in XenForo, which is where screenshots attached to post are from.

Short version: instead of inserting code into predefined places, like template events do, template modifications do simple (or not so simple - there are options for regex and callback replacements) search/replace in existing code. That makes it possible to not only insert code anywhere you want, but also modify existing code.

CHItA
Development Team
Development Team
Posts: 169
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: Feature freeze events in templates

Post by CHItA »

Arty wrote: Sun Oct 04, 2015 8:42 am Short version: instead of inserting code into predefined places, like template events do, template modifications do simple (or not so simple - there are options for regex and callback replacements) search/replace in existing code. That makes it possible to not only insert code anywhere you want, but also modify existing code.
I think the main drawback of this would be that extensions could become incompatible with each other.

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: Feature freeze events in templates

Post by Arty »

CHItA wrote: Sun Oct 04, 2015 9:55 amI think the main drawback of this would be that extensions could become incompatible with each other.
Why? Replacing code doesn't mean old code is removed. So, for example, if some extension wants to append code after <!-- end of header -->, it should include search in replacement, allowing other extensions to search for same code.

Current method of events limits extension authors to injecting code in specific places. Search/replace doesn't remove that ability. It adds more possibilities without removing old ones. If properly used, there won't be any conflicts with different extensions.

Template replacements have been tested on forums that run more add-ons than there are extensions for phpBB 3.1. It works fine, with rare exception of really badly coded add-on that does replacement wrong (such as searching for 10-20 lines only to replace 1 line).

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Feature freeze events in templates

Post by DavidIQ »

I'm in agreement with Arty there. Template system needs an overhaul in order to make this a non-issue, which I agree it is an issue but not sure there is a solution we can go with that will make everyone happy.

Maybe that is something that could be looked at into further for 3.3/4.0? I think we've missed the cut-off time for 3.2 to address this.

A much more detailed answer on this proposal of yours and how it would work with phpBB would be great as most of us are unfamiliar with the inner workings of XenForo, vB and the like.
Image

CHItA
Development Team
Development Team
Posts: 169
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: Feature freeze events in templates

Post by CHItA »

Arty wrote: Sun Oct 04, 2015 2:03 pm Why? Replacing code doesn't mean old code is removed. So, for example, if some extension wants to append code after <!-- end of header -->, it should include search in replacement, allowing other extensions to search for same code.

Current method of events limits extension authors to injecting code in specific places. Search/replace doesn't remove that ability. It adds more possibilities without removing old ones. If properly used, there won't be any conflicts with different extensions.
Oh, okay, i misunderstood what you proposed. However I'm still quite unsure how that would look like in practice (for example, what if the style uses different HTML then what the ext. author expects etc). Otherwise it sounds like a good idea to me, and probably could be implemented in 3.3/4.0 as DavidIQ wrote.

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: Feature freeze events in templates

Post by Arty »

CHItA wrote: Sun Oct 04, 2015 4:24 pmHowever I'm still quite unsure how that would look like in practice (for example, what if the style uses different HTML then what the ext. author expects etc).
In practice there are few issues I can think of:
  • In phpBB templates are quite large, so searching for code might be more complex than needed. That can be solved by splitting templates into smaller chunks.
  • Line endings and indentation. Its not a problem in other forum systems because templates are stored in database, so users don't mess up line endings with unpacking/transferring or any other way. That can be solved by doing something like preg_replace("/((?:\r)?\n\w*)/", "\n") - replacing possible \r + \n + all spacing after it with \n in both templates and search/replace code before compilation.
  • Different syntax in different styles. That can be solved by treating replacements same way as template events: store them in extension's styles directory, so replacements could be changed per style.
Format could be something simple, like json (/ext/foo/bar/styles/prosilver/replacements.json or /ext/foo/bar/styles/prosilver/replacements/forumlist_body.json)

Code: Select all

{
    "forumlist_body.html": [
        {
            "type": "string",
            "search": "HTML code here",
            "replace": "$0 new HTML code!"
        },
        {
            "type": "regex",
            "search": "#^.*$#s",
            "replace": "$0 new code at the end of template"
        },
        {
            "type": "callback",
            "search": "#^.*$#s",
            "replace" "\\foo\\bar\\listeners\\template::forumList"
        }
    ]
}
where $0 is matched string

Post Reply