? ? Pending

User tests: Successful: Unsuccessful:

avatar ggppdk
ggppdk
3 Dec 2017

Pull Request for Issue #18962

Summary of Changes

If you try to add a module in error page of any joomla template

  • then this module may result in calling methods that only exist if JDocument is of type HtmlDocument

Then in all other document types you will get a new fatal error during error page creation
e.g. addHeadLink() method only exists in HtmlDocument

In J3.8.2 the adding of search module into the error was fixed (templates protostar and beez3)
by PR #18375
which was a good thing, but it results in issue describe in #18962

Testing Instructions

See #18962

Expected result

See #18962

Actual result

See #18962

Documentation Changes Required

None

avatar ggppdk ggppdk - open - 3 Dec 2017
avatar ggppdk ggppdk - change - 3 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 3 Dec 2017
Category Front End Templates (site)
avatar mbabker
mbabker - comment - 3 Dec 2017

Not a good fix. The Document instance in the factory is going to be a different document instance than the one being rendered at that point.

The template files (index.php, error.php, etc.) should NEVER be operating with JFactory::getDocument(), they should ONLY be operating with $this because they are in scope of the Document instance.

These types of conditionals would have to go into the module, not the template.

avatar ggppdk
ggppdk - comment - 4 Dec 2017

i think it is the same document, it must be the same,
unless someone outside the class code is setting the property ???

	public static function getDocument()
	{
		if (!self::$document)
		{
			self::$document = self::createDocument();
		}

		return self::$document;
	}

but even if it is a different document instance,
the check is still valid, because it is the document instance that will cause the error of
right ??

Call to undefined method Joomla\CMS\Document\RawDocument::addHeadLink(): View not found [name,type,prefix]: article, txt, contentView

The template files (index.php, error.php, etc.) should NEVER be operating with JFactory::getDocument(), they should ONLY be operating with $this because they are in scope of the Document instance.

i agree with you

but when we are calling code to create modules, then we are doing exactly it because the modules are not forbidden from calling it or using code that results in calling it, an example of the fact that it is used is the error that we patch now

avatar ggppdk
ggppdk - comment - 4 Dec 2017

About

These types of conditionals would have to go into the module, not the template.

this is understandable, i am already doing similar checks myself in plugins,
(just it is annoying to patch all modules that can be called, at least in this case it is only 1)

i will close this as soon as someone makes the new PR,
or should i close it now ?

avatar mbabker
mbabker - comment - 4 Dec 2017

i think it is the same document, it must be the same,
unless someone outside the class code is setting the property ???

When the error handler gets triggered it never overloads what's in the factory. So you will have an ErrorDocument instance being rendered while the factory will either not yet be initialized (depending on where in the request things fail) or it'll be a document for the request format (generally the HTMLDocument).

avatar ggppdk
ggppdk - comment - 4 Dec 2017

this is not understandable, i am already doing similar checks myself in plugins,

I meant to say that your argument is 'understanable',
but i see that i wrote a 'not understandable' in my answer, i corrected and removed the not

avatar ggppdk ggppdk - change - 24 Mar 2018
Labels Added: ?
avatar ggppdk
ggppdk - comment - 24 Mar 2018

@mbabker

I have replaced check on JFactory::getDocument() with a check on format request variable
added check to also protostar's error.php

avatar ggppdk
ggppdk - comment - 30 Mar 2018

I have modified this PR
I have replaced check on JFactory::getDocument() with a check on format request variable

 $layout   = $app->input->getCmd('layout', '');
 $task     = $app->input->getCmd('task', '');
 $itemid   = $app->input->getCmd('Itemid', '');
+$format   = $app->input->getCmd('format', 'html');
 $sitename = $app->get('sitename');

because the error.php is already using other request variables like layout and task, i assume there is no issue with using format request variable

avatar zyzak
zyzak - comment - 30 Mar 2018

Hei I want use your solution

as I understand I must modify the file, but witch one file ?

avatar ggppdk
ggppdk - comment - 30 Mar 2018

@zyzak

Yes, you can apply same check in your template (as the check of this PR)

but since in your case you have have attempt to call a different method

JDocumentNNN::addFavicon() 

your issue for addFavicon() is here
#20004

someone will need to find where this is done by your template (probably the execution path that calls the above starts somewhere inside error.php of your Joomla template)

and after finding then put similar check

Please post in Joomla forums and link to this PR and to this comment andf mention your template author
or ask for support a Joomla expert and link to this PR and to this comment, and they will know what to patch

Please dont ask for support in this PR

  • the best choice is to report to the template author and link here, and it should be easy for them to fix it
avatar 810
810 - comment - 6 Dec 2018

Please resolve the conflict.

avatar ggppdk
ggppdk - comment - 6 Dec 2018

Conflicts resolved

avatar 810
810 - comment - 6 Dec 2018

I have tested this item successfully on 70222c1


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18966.

avatar 810
810 - comment - 6 Dec 2018

I have tested this item successfully on 70222c1


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18966.

avatar 810 810 - test_item - 6 Dec 2018 - Tested successfully
avatar sshcli
sshcli - comment - 7 Dec 2018

I have tested this item successfully on 70222c1


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18966.

avatar sshcli sshcli - test_item - 7 Dec 2018 - Tested successfully
avatar Quy Quy - change - 7 Dec 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 7 Dec 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18966.

avatar mbabker
mbabker - comment - 12 Dec 2018

I still don't like this but at this point we're never going to get the right fixes in the core architecture, so here it goes.

avatar mbabker mbabker - close - 12 Dec 2018
avatar mbabker mbabker - merge - 12 Dec 2018
avatar mbabker mbabker - change - 12 Dec 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-12-12 05:41:54
Closed_By mbabker
Labels Added: ?

Add a Comment

Login with GitHub to post a comment