mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #32820
[Bug 1544381] Re: Problem with cleanurls and group_homepage_url() in .tpl
After a lot of investigation with Robert, here's what we found you have
to do to replicate this:
1. Install Mahara 16.04dev
2. Disable/hide the multirecipientnotifications module
3. Make sure no pages owned by a group are showing up in your "Latest changes I can view" block
4. Clear your "dwoo" cache folder in your dataroot directory (i.e. rm -Rf /path/to/dataroot/dwoo)
When these conditions are in place (which is most likely to happen after
an upgrade, if the upgrading site somehow failed to install the
multirecipientnotification module), what happens is that the newview
block tries to load "newviews.tpl". Dwoo finds no compiled copy of this
template in its cache, so it attempts to recompile it. Line 12 of
newviews.tpl contains this code:
"{group_homepage_url($view.groupdata)}".
In trying to parse that, Dwoo checks to see if "group_homepage_url" is a
PHP function in the scope where smarty() was called. It *is* in fact a
PHP function, in htdocs/lib/group.php, but in these conditions no code
will have yet been loaded that will have included that
htdocs/lib/group.php file, and so Dwoo will not find the function.
Lacking that, Dwoo will assume that "group_homepage_url" is a Dwoo
plugin. But it won't find a plugin by that name either. So, lacking
either, it will error out.
The reloading and blinking is caused by a separate bug (Bug 1544424) in
the ajax block code. If you disable ajax blocks, you'll see the standard
Dwoo exception error page.
This one is tricky because it is caused by one of the differences in
behavior between Dwoo and PHP. The Dwoo template code that invokes
"group_homepage_url()" is surrounded by an "if" block that is only
entered if one of the views is owned by a group. In a PHP script, this
would mean that "group_homepage_url()" doesn't get evaluated, and it
wouldn't matter whether it's in scope or not. But Dwoo is actually a
compiled language (it is compiled into PHP scripts). So, if there is no
cached compiled version of the template, it will attempt to evaluate
"group_homepage_url()" during the compilation, whether or not it will
actually get invoked while rendering the template.
I guess the lesson here is to make sure that *every* method you call in
a Dwoo template is in scope when you call smarty(). Or even better,
avoid calling methods from within Dwoo templates. Instead, call the
method from the surrounding PHP code, and assign its return value to a
Dwoo variable.
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1544381
Title:
Problem with cleanurls and group_homepage_url() in .tpl
Status in Mahara:
In Progress
Bug description:
Sometimes when I'm testing things on my cleanurl https:// site I get
this strange error where if I go to the homepage it tries to reload
the page over and over.
In the error logs I see:
[WAR] b6 (lib/dwoo/dwoo/Dwoo/Loader.php:119) Plugin <em>group_homepage_url</em> can not be found, maybe you forgot to bind it if it's a custom plugin ?, referer: https://mahara-testing/
Call stack (most recent first):, referer: https://mahara-testing/
* Dwoo_Loader->loadPlugin("group_homepage_url", true) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Compiler.php:2968, referer: https://mahara-testing/
* Dwoo_Compiler->getPluginType("group_homepage_url") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Compiler.php:1715, referer: https://mahara-testing/
* Dwoo_Compiler->parseFunction("{if $views}, referer: https://mahara-testing/
<div class="list-group">, referer: https://mahara-testing/
{foreach ...", 500, 1902, false, "root", 535) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Compiler.php:1365, referer: https://mahara-testing/
* Dwoo_Compiler->parse("{if $views}, referer: https://mahara-testing/
<div class="list-group">, referer: https://mahara-testing/
{foreach ...", 500, null, false, "root", 535) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Compiler.php:805, referer: https://mahara-testing/
* Dwoo_Compiler->compile(object(Dwoo_Mahara), object(Dwoo_Template_Mahara)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Template/String.php:370, referer: https://mahara-testing/
* Dwoo_Template_String->getCompiledTemplate(object(Dwoo_Mahara), null) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/dwoo/Dwoo/Core.php:373, referer: https://mahara-testing/
* Dwoo_Core->get(object(Dwoo_Template_Mahara), array(size 5)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/dwoo/mahara/Dwoo_Mahara.php:123, referer: https://mahara-testing/
* Dwoo_Mahara->fetch("blocktype:newviews:newviews.tpl") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/blocktype/newviews/lib.php:59, referer: https://mahara-testing/
* PluginBlocktypeNewViews::render_instance(object(BlockInstance)) at Unknown:0, referer: https://mahara-testing/
If I make a dwoo plugin for group_homepage_url() the issue goes away
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1544381/+subscriptions
References