Extension's Path and Controllers's issue

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Extension's Path and Controllers's issue

Post by 3Di » Tue Oct 03, 2017 5:08 am

Hi all,
there is an Ext I am developing DAE which aims to set a default Avatar board-wide, which it does.. basically.

The issue is with controllers, with some extension
º - AjaxChat = it works perfectly (both options I wrote)
º - mChat = doesn't (I don't know why since sets a default avatar like AjaxChat does).. no way.
º
º - my TPOTM at 90% (places a placeholder and the HTML response is 200 - just in the Hall of fame), see below the source from app.php/tpotm/hall_of_fame's page
src="./ext/threedi/dae/styles/prosilver/theme/images/dae_noavatar_full.png"
DAE_glitch.png
.
we are speaking JUST about controllers.
I managed to do my best to fix an absolute path here:
https://github.com/3D-I/Default-Avatar- ... es.yml#L20
and here
https://github.com/3D-I/Default-Avatar- ... ae.php#L37

What else should I do since I searched up and down to no success, hence I am asking.

Thanks IA.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1151
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Extension's Path and Controllers's issue

Post by Ger » Wed Oct 04, 2017 8:56 am

I'm trying to understand the issue here. Am I correct about:
  1. The DAE extension hooks into core.get_avatar_after to check if the avatar is empty (or always overridden)
  2. If so, it returns the full HTML string for the avatar image
  3. In theory, every extension that calls for an avatar should call phpbb_get_avatar() so it would call your event
Now, 1 thing I know for sure is that one extension of mine (cmBB), I use my own avatar fetching, hence the DAE function won't be executed. That might not be the issue for you but I thought it might be worth noting.

Next, the phpbb_get_avatar() has 3 different return points, 2 of them before your event. That may also be the issue here. You can try all you want with paths and stuff, but you won't succeed since the event isn't called.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Extension's Path and Controllers's issue

Post by 3Di » Thu Oct 05, 2017 3:23 am

Ger wrote:
Wed Oct 04, 2017 8:56 am
I'm trying to understand the issue here. Am I correct about:
  1. The DAE extension hooks into core.get_avatar_after to check if the avatar is empty (or always overridden)
  2. If so, it returns the full HTML string for the avatar image
  3. In theory, every extension that calls for an avatar should call phpbb_get_avatar() so it would call your event
Correct, plus has the feature to be able to override also gravatars (phpBB bug), see ext.php and /config if interested.
Ger wrote:
Wed Oct 04, 2017 8:56 am
Now, 1 thing I know for sure is that one extension of mine (cmBB), I use my own avatar fetching, hence the DAE function won't be executed. That might not be the issue for you but I thought it might be worth noting.
Me too in TPOTM I use a my own TPOTM default avatar fetch..but for compatibility with DAE I coded such a condition (here I am making a short case with no bell and whistles)

Code: Select all

public function style_mini_badge()
{
	return '<img src="' . $this->ext_path_web() . 'styles/' . rawurlencode($this->user->style['style_path']) . '/theme/images/tpotm_badge.png" />';
}

/* DAE (Default Avatar Extended) extension compatibility */
if ($this->config['threedi_default_avatar_extended'] && $this->config['threedi_default_avatar_exists'])
{
	$user_avatar = phpbb_get_avatar($row_avatar, '');
}
else
{
	$user_avatar = (!empty($row['user_avatar'])) ? phpbb_get_avatar($row_avatar, '') : $this->style_mini_badge();
}
And DAE it works well on index, both functions work ("use only if no avatar" (and overrides also my default TPOTM) and "replace always" - or if disabled then returns my TPOTM settings) ..

but not in my controller which uses the same conditions.. that leads me to think there is something wrong in my TPOTM controller, also because gives me false negatives.. I will open a new topic for that.
I think the issue isn't of DAE but my TPOTM's controller somehow, I am not able to catch the issue, I recoded a lot of stuffs but the result is the same.
Ger wrote:
Wed Oct 04, 2017 8:56 am
Next, the phpbb_get_avatar() has 3 different return points, 2 of them before your event. That may also be the issue here. You can try all you want with paths and stuff, but you won't succeed since the event isn't called.
Could you pls expand, I read the code but I am missing your point sorry.

Thx. :)
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Extension's Path and Controllers's issue

Post by 3Di » Thu Oct 05, 2017 4:48 am

Moved content into a new topic
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1151
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Extension's Path and Controllers's issue

Post by Ger » Thu Oct 05, 2017 6:58 am

3Di wrote:
Thu Oct 05, 2017 3:23 am
Ger wrote:
Wed Oct 04, 2017 8:56 am
Next, the phpbb_get_avatar() has 3 different return points, 2 of them before your event. That may also be the issue here. You can try all you want with paths and stuff, but you won't succeed since the event isn't called.
Could you pls expand, I read the code but I am missing your point sorry.

Thx. :)
The function has 3 points at which it returns:
https://github.com/phpbb/phpbb/blob/mas ... .php#L4035
https://github.com/phpbb/phpbb/blob/mas ... .php#L4054
https://github.com/phpbb/phpbb/blob/mas ... .php#L4107

As you know, when return is called, the function returns control to the calling module, hence anything below isn't executed. The first 2 return calls are above the event point. That means: if for some reason your routine gets to the first or second return (e.g. when avatars aren't allowed or when a custom avatar driver returns HTML) the event point is not reached. And that means your extension code won't be executed.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Extension's Path and Controllers's issue

Post by 3Di » Thu Oct 05, 2017 9:39 am

Ah ok, I see. Time to make some test and get back then.
Thanks. :)
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Extension's Path and Controllers's issue

Post by 3Di » Thu Oct 05, 2017 10:04 am

Ger wrote:
Thu Oct 05, 2017 6:58 am
That means: if for some reason your routine gets to the first or second return (e.g. when avatars aren't allowed or when a custom avatar driver returns HTML) the event point is not reached. And that means your extension code won't be executed.
The event config is already returned by my code here:
https://github.com/3D-I/Default-Avatar- ... #L118-L125

About the custom driver, I am not using a custom one.

As I said I use custom HTML which is perfectly overriden in index etc.. but app.php.
Here's my custom HTML in TPOTM

Code: Select all

	public function style_mini_badge()
	{
		return '<img src="' . $this->ext_path_web() . 'styles/' . rawurlencode($this->user->style['style_path']) . '/theme/images/tpotm_badge.png" />';
	}
And it is the same for index/viewforum or app.php, just in the latter doesn't return the correct URL, question of ./../ or ./ or similars. I modified that bit in firefox's developer tools and I saw changing it with a dot the IMG is shown.

Hence the issue lies there, the path.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1151
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Extension's Path and Controllers's issue

Post by Ger » Thu Oct 05, 2017 11:33 am

I've installed both extension on my development board, I seem to be able to reproduce the issue.

When I var_dump the $src in the event, I see

Code: Select all

string 'src="./ext/threedi/dae/styles/prosilver/theme/images/dae_noavatar_full.png"'
When you're in a subfolder (e.g.: ./tpotm/hall_of_fame) that's wrong.

If I were you, I'd simply use generate_board_url(); in the dae class:

Code: Select all

return (generate_board_url() . '/ext/threedi/dae/styles/' . rawurlencode($this->user->style['style_path']) . '/theme/images/dae_noavatar.png');
Of course you can move '/ext/threedi/dae/styles/' to the service.yml file, but you get the idea.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Extension's Path and Controllers's issue

Post by 3Di » Thu Oct 05, 2017 11:53 am

Wonderful. :) Thanks a lot.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1151
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Extension's Path and Controllers's issue

Post by Ger » Thu Oct 05, 2017 12:01 pm

YW :)
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests

cron