[ABD] Template Events Locations (for extension developers)

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
User avatar
3Di
Registered User
Posts: 12685
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by 3Di » Mon Mar 26, 2018 9:47 pm

Try to disable your extension and delete its data, then activate Zend x-debug and install it again, you will see this one: http://prntscr.com/iwrk3u

Using the above temporary fix will allow you to go ahead, then you can roll back that change and it works.
Didn't investigate further since I am busy elsewhere, sorry.

And no, phpBB 3.2.2 (patched) - Environment PHP 7.1.15 / Apache 2.4.29 / MySql 5.7.21

Edit: moreover, once we are facing that screen on enable extension's action, if going back and submit again that error screen goes away and it works.
I guess that's something a do with the cache somehow.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Template Events Locations (for extension developers)

Post by martti » Tue Mar 27, 2018 5:01 am

Probably it's cache related. I will see if something can be done in the ext.php file.

User avatar
Froddelaar
Registered User
Posts: 851
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by Froddelaar » Wed Mar 28, 2018 7:42 pm

martti wrote:
Tue Mar 27, 2018 5:01 am
Probably it's cache related. I will see if something can be done in the ext.php file.
Thank you! :)
Also noticed that the "show" is also viewable and working by guests and members.
Is it possible to show this only for admins or founder ?

{% if U_ACP %}
code
{% endif %}

This is not working.. this shows "show" without css
Wij promoten UW muziek in ons forum & delen alles via Sociale media!
Muziek wordt ook toegevoegd in de playlist van
textradio.be!
Mail uw single + hoesje + info naar: info@muziekpromo.net of Solidjeuh@textradio.be
===============
Onze Website: https://www.muziekpromo.net

User avatar
3Di
Registered User
Posts: 12685
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by 3Di » Wed Mar 28, 2018 7:46 pm

You shouldn't use this on a live board Man ;)
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
canonknipser
Registered User
Posts: 1539
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by canonknipser » Wed Mar 28, 2018 7:52 pm

Froddelaar wrote:
Wed Mar 28, 2018 7:42 pm
Is it possible to show this only for admins or founder ?
as per title
for extension developers
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
Froddelaar
Registered User
Posts: 851
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by Froddelaar » Wed Mar 28, 2018 7:53 pm

3Di wrote:
Wed Mar 28, 2018 7:46 pm
You shouldn't use this on a live board Man ;)
Yeah I know... but it's a fast way to locate events :lol: I only enable it when I need it
Wij promoten UW muziek in ons forum & delen alles via Sociale media!
Muziek wordt ook toegevoegd in de playlist van
textradio.be!
Mail uw single + hoesje + info naar: info@muziekpromo.net of Solidjeuh@textradio.be
===============
Onze Website: https://www.muziekpromo.net

User avatar
canonknipser
Registered User
Posts: 1539
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by canonknipser » Wed Mar 28, 2018 7:56 pm

Froddelaar wrote:
Wed Mar 28, 2018 7:53 pm
but it's a fast way to locate events
It works even faster when you have it permanently enabled on a test board - no on/off-switching needed :D
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
Froddelaar
Registered User
Posts: 851
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by Froddelaar » Wed Mar 28, 2018 7:57 pm

canonknipser wrote:
Wed Mar 28, 2018 7:56 pm
Froddelaar wrote:
Wed Mar 28, 2018 7:53 pm
but it's a fast way to locate events
It works even faster when you have it permanently enabled on a test board - no on/off-switching needed :D
Oke you have a point there :D
Wij promoten UW muziek in ons forum & delen alles via Sociale media!
Muziek wordt ook toegevoegd in de playlist van
textradio.be!
Mail uw single + hoesje + info naar: info@muziekpromo.net of Solidjeuh@textradio.be
===============
Onze Website: https://www.muziekpromo.net

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Template Events Locations (for extension developers)

Post by martti » Thu Mar 29, 2018 10:25 am

@Froddelaar and others who get a blank page upon enabling the extension: Do you have the "Recompile stale style components" option enabled?

ACP > General > Server Configuration > Load Settings > Recompile stale style components

When I turn off this option, I also get a blank page. But when developing extensions this option should be turned on.


edited: "Server Settings" became "Server Configuration"
Last edited by martti on Thu Mar 29, 2018 11:06 am, edited 2 times in total.

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Template Events Locations (for extension developers)

Post by martti » Thu Mar 29, 2018 10:39 am

Froddelaar wrote:
Wed Mar 28, 2018 7:42 pm
Also noticed that the "show" is also viewable and working by guests and members.
Is it possible to show this only for admins or founder ?
This was until shortly the behaviour of the extension, but as @canonknipser remarked, this extension is to be used in development only, so I removed this behaviour because then you can also see the events when logged out or from users with other permissions.

As nowadays PHP has a built-in development server it's very easy to set up a development environment on your local machine. You can also use a Sqlite3 database instead of a MySQL or PostgreSQL. That's what I use for development. No user or password configuration needed.

User avatar
3Di
Registered User
Posts: 12685
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [RC] Template Events Locations (for extension developers)

Post by 3Di » Thu Mar 29, 2018 8:52 pm

martti wrote:
Thu Mar 29, 2018 10:25 am
@Froddelaar and others who get a blank page upon enabling the extension: Do you have the "Recompile stale style components" option enabled?

ACP > General > Server Configuration > Load Settings > Recompile stale style components

When I turn off this option, I also get a blank page. But when developing extensions this option should be turned on.


edited: "Server Settings" became "Server Configuration"
Are you referring to the bug-screen I have earlier posted?
FYI my environments are always set to have "recompile stale style components" --> ON. :geek:
Moreover that setting helps just for template files, say you are working on a template and do not want to use the "purge cache" ACP tool.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Template Events Locations (for extension developers)

Post by martti » Fri Mar 30, 2018 5:41 pm

So not enabling 'Recompile Stale Style Elements' doesn't seem to be the problem.

However, I've launched a new version (1.3.1) in which I've probably solved the problem now.

phpBB does not use a Post-Redirect-Get pattern when enabling the extensions. If it did, the problem would not exist I think. Then the extension would always be fully loaded upon first response to the user. And now it gets partially loaded which causes problems. It seems that the template events are always listened to but that the new services of the enabled extension not always exist (maybe depending on cache) in the response right after you hit "Enable".
To circumvent this, I load the Twig Extension now manually in the ext.php file. It seems to be working.

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Template Events Locations (for extension developers)

Post by martti » Sun Apr 01, 2018 2:42 pm

Version 1.4.0 that's released today introduces yet another feature that will be useful when building extensions. All events (template and PHP) are now linked to their location in the phpBB repository on Github, so their context can be reviewed by clicking on them.

Note: there are 3 template events that appear 3 times in 3 different locations. Namely topiclist_row_topic_title_after, topiclist_row_append and topiclist_row_prepend all appear in search_results.html, viewforum_body.html and mcp_forum.html. The link will carry you to the event that was actually triggered. I.e on the viewforum page, the link will point to the event in viewforum_body.html, on the search page, the link of the same event will point to the line where the event appears in search_results.html

If you hold the mouse pointer on a template event label, you see the phpBB version it was introduced and the file where it resides:
Image

Clicking on the template event label brings you to the line in the phpBB code:
Image

Also the PHP events are linked:
Image

User avatar
martti
Registered User
Posts: 572
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Template Events Locations (for extension developers)

Post by martti » Sun Apr 01, 2018 9:27 pm

Hmm, when I enable another extension suddenly the Twig Function which was defined in this extension is not recognised anymore. I don't understand why, but it starts to look like that phpBB extensions cannot define Twig Extensions in a stable way.

Code: Select all

PHP Fatal error:  Uncaught Twig_Error_Syntax: Unknown "marttiphpbb_templateevents_render" function. in /home/martti/pjt/phpbb/x/ext/marttiphpbb/templateevents/styles/all/template/event/overall_header_feeds.html:1
Stack trace:
#0 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(374): Twig_ExpressionParser->getFunctionNodeClass('marttiphpbb_tem...', 1)
#1 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(162): Twig_ExpressionParser->getFunctionNode('marttiphpbb_tem...', 1)
#2 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(102): Twig_ExpressionParser->parsePrimaryExpression()
#3 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(55): Twig_ExpressionParser->getPrimary()
#4 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Parser.php(147): Twig_ExpressionParser->parseExpression()
#5 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Parser.php(103): Twig_Parser->subparse(NULL, false)
#6 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Envi in /home/martti/pjt/phpbb/x/ext/marttiphpbb/templateevents/styles/all/template/event/overall_header_feeds.html on line 1
Last edited by martti on Mon Apr 02, 2018 7:01 am, edited 1 time in total.

User avatar
3Di
Registered User
Posts: 12685
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.2][BETA] Template Events Locations (for extension developers)

Post by 3Di » Sun Apr 01, 2018 11:05 pm

martti wrote:
Sun Apr 01, 2018 9:27 pm
Hmm, when I enable another extension suddenly the Twig Function which was defined in this extension is not recognised anymore. I don't understand why, but it start to look like that phpBB extensions cannot define Twig Extensions in a stable way.

Code: Select all

PHP Fatal error:  Uncaught Twig_Error_Syntax: Unknown "marttiphpbb_templateevents_render" function. in /home/martti/pjt/phpbb/x/ext/marttiphpbb/templateevents/styles/all/template/event/overall_header_feeds.html:1
Stack trace:
#0 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(374): Twig_ExpressionParser->getFunctionNodeClass('marttiphpbb_tem...', 1)
#1 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(162): Twig_ExpressionParser->getFunctionNode('marttiphpbb_tem...', 1)
#2 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(102): Twig_ExpressionParser->parsePrimaryExpression()
#3 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/ExpressionParser.php(55): Twig_ExpressionParser->getPrimary()
#4 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Parser.php(147): Twig_ExpressionParser->parseExpression()
#5 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Parser.php(103): Twig_Parser->subparse(NULL, false)
#6 /home/martti/pjt/phpbb/x/vendor/twig/twig/lib/Twig/Envi in /home/martti/pjt/phpbb/x/ext/marttiphpbb/templateevents/styles/all/template/event/overall_header_feeds.html on line 1
I am following the development's progresses here, congrats about the new features.

Back to the issue here, I did set a fresh 3.2.2/PHP 7.1.15 with just this extension v 1.4.0 freshly cloned

All of the other extensions there are disabled/never installed, so it doesn't matter.

At the enable action in ACP, right after I clicked on the Enable button I'm getting this debug error (Zend debug)

Image

The culprit seems to lie in the ext.php file, function enable_step() #38
$twig = $this->container->get('template.twig.environment'); that service doesn't exists there (see below)

I have found some topics about template.twig.environment's etc.
those seems to me they are related and helpful to try and solve this issue.
viewtopic.php?f=461&t=2466641
viewtopic.php?f=461&t=2454706

---------------

Edit: btw..
the usage of the "language" object isn't possible in ext.php, you need to use
$user->add_lang_ext('marttiphpbb/templateevents', 'common');

To implement Twig use $twig = new \Twig_Environment();

I did some work on this ext (modified 3 files) but I will finish tomorrow, and test.

the ext.php part modifed is here

Code: Select all

				$twig = new \Twig_Environment();
				$request = $this->container->get('request');
				$user = $this->container->get('user');
				$user->add_lang_ext('marttiphpbb/templateevents', 'common');
				$cache = $this->container->get('cache.driver');
				$php_event_listener = new php_event_listener();
				$events_cache = new events_cache($cache);
				$twig_extension = new extension($request, $user, $php_event_listener, $events_cache);
				$twig->addExtension($twig_extension);
				return 'add_twig_extension';
				break;
I modified also config/services.yml.. removed 'language'..
.. also from extension.php as you can see above, and used the user class like for 3.1.

About twig/extension.php, as I said, is wip
(It is mandatory now to inject the interface Twig_ExtensionInterface as the first element in the constructor, and create an abstract class for it, else can not be instantiated).

See if that helps.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “Abandoned Extensions”

Who is online

Users browsing this forum: Niko! and 7 guests