XF 1.5 Xenforo Class Proxy System Query

sajal

Active member
I've two plugins that extend the core "XenForo_DataWriter_Forum" class.

Both plugins override couple of "maxLength" values from core. However, I noticed that only one plugin is called by the XFCP system, since I'm using "return" statement. It seems that it's causing issues since there's a return statement in the plugin thus not further calling other plugins.

Any solution for this?
 
It sounds like one of the extensions is overriding the existing method, rather than extending it.

In both cases you need to call the parent, modify that, and then return it. If you can share the code, that will help.
 
@Chris D Yes both plugins override _getFields() method, but I also call parent in both methods as well, still not working.

Plugin one ExtendThreadTitleLength:

<?php
class ExtendThreadTitleLength_Extend_XenForo_DataWriter_Forum extends XFCP_ExtendThreadTitleLength_Extend_XenForo_DataWriter_Forum
{
protected function _getFields() {
$fields = parent::_getFields();
$fields['xf_forum']['last_thread_title']['maxLength'] = 255;

return $fields;
}
}

Listener of plugin one:

<?php
class ExtendThreadTitleLength_Listener {
public static function load_class_datawriter($class, array &$extend)
{
if ($class == 'XenForo_DataWriter_Forum')
{
$extend[] = 'ExtendThreadTitleLength_Extend_XenForo_DataWriter_Forum';
}
}
}


Plugin two ExtendNodeTitleLength:

<?php
class ExtendNodeTitleLength_Extend_XenForo_DataWriter_Forum extends XFCP_ExtendNodeTitleLength_Extend_XenForo_DataWriter_Forum
{
protected function _getFields() {
$fields = parent::_getFields();
$fields['xf_node']['title']['maxLength'] = 255;

return $fields;
}
}

Listener of plugin two:

<?php
class ExtendNodeTitleLength_Listener {
public static function load_class_datawriter($class, array &$extend)
{
if ($class == 'XenForo_DataWriter_Forum')
{
$extend[] = 'ExtendNodeTitleLength_Extend_XenForo_DataWriter_Forum';
}
}
}
 
@Chris D So, as you could see I want to have both title and last_thread_title maxLength affected. Of course, I can do this in one plugin, but just wondering why it doesn't work with two plugins.
 
Please try to use code tags when posting code for legibility :)

I don't see a reason why it wouldn't work.

That said, it probably makes more sense to extend XenForo_DataWriter_Node directly to modify the xf_node.title field.
 
@Chris D Sorry to bother you, my bad.

It works now, I was using "Event Hint" as I was using multiple overrides in my listener class, for simplicity I didn't paste all overrides in the above code. So, it was calling that second plugin only when the event hint was matched. Removing event hint works e'thing now.

Thanks again!
 
Top Bottom