pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
298 stars 443 forks source link

Default Theme - References crashing OJS #7410

Open israelcefrin opened 2 years ago

israelcefrin commented 2 years ago

Describe the bug If the citations table is empty and you attempt to render the article landing page, the journal crashes and returns a blank page and a error message in the log file.

To Reproduce Steps to reproduce the behavior:

  1. Truncate the citations table
  2. Access any article landing page
  3. See error

What application are you using? OJS, OMP or OPS version 3.2.X and 3.3.x

Additional information To make it work I had to remove this section from the templates/frontend/objects/article_details.tpl file

            {* References *}
            {if $parsedCitations->getCount() || $article->getCitations()}
                <div class="item references">
                    <h3 class="label">
                        {translate key="submission.citations"}
                    </h3>
                    <div class="value">
                        {if $parsedCitations->getCount()}
                            {iterate from=parsedCitations item=parsedCitation}
                                <p>{$parsedCitation->getCitationWithLinks()|strip_unsafe_html} {call_hook name="Templates::Article::Details::Reference" citation=$parsedCitation}</p>
                            {/iterate}
                        {elseif $article->getCitations()}
                            {$article->getCitations()|nl2br}
                        {/if}
                    </div>
                </div>
            {/if}
asmecher commented 2 years ago

@israelcefrin, can you check the PHP error log for details?

israelcefrin commented 2 years ago

This was the error in log file:

[Fri Sep 17 15:12:36.480710 2021] [cgi:error] [pid 16560:tid 47737042777856] [client 184.148.79.143:54025] AH01215: PHP Fatal error: Uncaught Error: Call to a member function getCount() on null in www/cache/t_compile/ed596c5afc1f74f6a9f28972d00e34affa67464c^addd65021fadf964339ab08cd1aa93ba59b14e9c_0.app.frontendobjectsarticledet.php:223: www/index.php, referer: https://domain.org/index.php/JOURNAL_ACRONYM/article/view/677/739

I opened the cached file and noticed it was the parsing citations issue.

asmecher commented 2 years ago

@israelcefrin, are you sure you're not using e.g. an outdated theme or something? The getCount call doesn't appear in OJS 3.2 or 3.3's article_details.tpl file, though it used to in OJS 3.1.x.