4

I want to override JFilterInput class on Joomla. The file is on below path:

[Joomla_Path]/libraries/joomla/filter/input.php

Because this file developed just for non-Unicode characters.So it shows

Notice: Array to string conversion

on line 233 in many components like com_finder that uses this class for Unicode characters. That line is:

$result = (string) preg_replace('/[^A-Z0-9_\.-]/i', '', $source);

for this reason I wanted to override this line and same others. firstly I developed a Joomla system plugin to override this file with onAfterRoute() method but by following this post in stackexchange I changed onAfterRoute() method to onAfterInitialise() method. But again it shows below fatal error:

Fatal error: Cannot redeclare class JFilterInput

Now I'm looking forward to get helps from everybody which solve this problem. in addition, I use last version of Joomla

  • onAfterInitialise is the event used once the framework has dispatched the application. Meaning JFilterInput already exists, which is why you're getting the error Cannot redeclare class JFilterInput. Rather than trying to redefine the class, try extending it – Lodder Jul 16 '15 at 11:12
  • I understood very helpful tip from your comment. Just could you help a little more; how can I extend this class plz. A link or any sample code with regards – Sami Jul 16 '15 at 12:49
  • 1
    A demo plugin written by @Don Gilbert can be found here: gist.github.com/dongilbert/3237387 – Lodder Jul 16 '15 at 13:25
1

It is strange that it return "Notice: Array to string conversion". It usually means that you try to get array variable using string functions. Check what data do you push directly in $_REQUEST.

Back to question. You can always use RAW type of filter if filtering is to strict.

If you still need to override this class please check this plugin sample: https://gist.github.com/dongilbert/3237387.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.