Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
subclassing bug?
I came across what seems to be a bug in Vanilla so I thought I'd mention it here to see what others think. I have a couple of fixes which may be useful to anyone with the same problem.
My extension wants to use a class which extends
The way I fix this is to change the method
with
Then it works.
It might be easier to change the
My extension wants to use a class which extends
ApplyForm
(from controls/apply.php
). This won't work because extensions are loaded before the page controls file, so the superclass is not available, and we can't inherit from an undefined class. If I include()
the controls file in my file, it is available for the subclass but then, when the page controls file is loaded, there is a "can't redefine class error". Catch 22.The way I fix this is to change the method
Page->Import
so that it has include_once()
once instead of include()
. On its own this doesn't suffice because include_once()
treats the file as different if it is included using absolute and relative paths (PHP bug?), so I need to change Page
's constructor to replace
$this->ControlFile = "controls/".$this->Context->SelfUrl;
with
$this->ControlFile = agAPPLICATION_PATH . "controls/".$this->Context->SelfUrl;
Then it works.
It might be easier to change the
init_*
files to load the page controls before the extensions and avoid this whole palava, but I didn't try that. 0
This discussion has been closed.
Comments
ObjectFactory
to load a "trampoline" instead of the real class I want to use. The trampoline looks like this:class MyApplyForm_TRAMP { var $file = "MyApplyForm.class.php"; function MyApplyForm_TRAMP(&$Context, $Param1 = "", ... , $Param10 = "") { include(sgOGI_PATH.$this->file); $this = $Context->ObjectFactory->NewContextObject($Context, "MyApplyForm",$Param1, ...., $Param10); } }
The trampoline's constructor replaces itself with the class you really wanted. Because the text of
MyApplyForm
is read only when we try to instantiate the trampoline we avoid the problem ofApplyForm
being undefined.Sadly this behaviour is a parse error in php5, even with the compatibility mode turned on.