strange behavior. pdf void on second load

Phoca PDF - creating PDF documents in Joomla! CMS
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

strange behavior. pdf void on second load

Post by nbit »

Hi,
I have a very strange behavior and I am not able to figure out the cause.
I have PDF cache setting disabled.

When I click on the pdf link in an article, I get the pdf with the content of the article, but if I click again and reload the PDF, then I get a void PDF with footer, title is replaced by "Category - Site name" and no content at all.
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post by nbit »

some more informations: it seems a cache related problem cause first time I open the pdf, I can see it, but if I try to open it again, I get a void pdf (I get the pdf but without content inside), if I purge joomla cache, I can open the pdf with the content again, then if I reopen it, i get the void pdf again
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post by nbit »

further information: disabling joomla conservative cache no problem, enabling joomla conservative caching I have the problem again.
I repeat, first time the article pdf is correct, second time I load it, it is void, there is the pdf but wrong title and no content
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

Hi,

hmmm, hard to say what can be wrong with conservative caching. If the first load is OK, this means everything is working OK with transforming HTML to PDF (no error, etc.)

Testing now, the second time, the view.pdf.php is not more asked for output, so there is nothing to change as it is inactive second time. I will try to investiage if there is a way to change it or disable cache for the PDF document :idea:

Jan
If you find Phoca extensions useful, please support the project
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

For now, the only idea is to do modification in this file:

components\com_content\controller.php

on line cca. 118 (at the bottom of the file)

FROM:

Code: Select all

parent::display($cachable, $safeurlparams);
TO:

Code: Select all

$format = $this->input->getCmd('format', '');
if ($format == 'pdf') {
   $cachable = false;
}
parent::display($cachable, $safeurlparams);
which disables caching for PDF documents. After making this modification, PDF should be always displayed.

Jan
If you find Phoca extensions useful, please support the project
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post by nbit »

Hi Jan, just for a clarification, were you able to reproduce the issue on your testing system, or it is just my issue?

I don't think it's a good idea to override components\com_content\controller.php as far as I know that file shouldn't be templatable and com_content is the most important component for us, I wouldn't mess with it.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

nbit wrote: 09 Sep 2020, 17:39 Hi Jan, just for a clarification, were you able to reproduce the issue on your testing system, or it is just my issue?
Yes, I got the same results on my test site.

The problem is, it is not managable in the Phoca PDF files, so this is why I suggested the edit of the controller. For now I don't know any better solution.

Because content is just build in view.pdf.php file inside com_content component. In this file, there is not possible to set the caching as this file is not called when using cache. All other files, where you can manage it, are core com_content files.

The modification is done the way, it does not affect any other part of the system. This is why it includes condition to disable the cache only for PDF output. So the modification is inactive all the time except displaying PDF document.

Unfortunately we are strongly limited here because most of data manipulation just happens in com_content component.

Jan
If you find Phoca extensions useful, please support the project
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post by nbit »

Hi Jan,
isn't it even possible to forbid the creation of the cached page from the plugin or to erase the cached page from the plugin?
I mean, you can't control the cache generation, but you can remove the pdf view from the cache so on the next load it creates it again?
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post by nbit »

I see that some plugins do something similar, a cache split depending by the view or by some parameters
they extend the base class adding something like this, but I have not enough knowledge for adapting this to our situation

public function display($cachable = false, $urlparams = array())

{
$urlparams['my_param'] = 'INT';
return parent::display($cachable, $urlparams);

}

so it looks they call the same function, just adding a new urlparam depending by the view for which they want to generate a separate cache. if we can generate a separate cache for the pdf when the pdf is first generated, then we should fix the issue, right?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

Our problem is, we are not running parent::display method because in such case PDF will be not rendered:

Image

So we cannot add $cachable variables to parent display as we don't run it.

The other problem is, parent display accepts $tpl variable not $cachable variable in view. And unfortunately we have only view part.

The part which accepts $cachable is the controller part, but the controller part is not a part of Phoca PDF but part of Com Content (Article) :idea:

Jan
If you find Phoca extensions useful, please support the project
Post Reply