news icon indicating copy to clipboard operation
news copied to clipboard

"Article no longer available" when displaying single view of one singular article

Open topsnet-holgerd opened this issue 4 years ago • 12 comments

Bug Report

Current Behavior When I updated news from version 7.1.0 to version 7.2.0, the view of one single article disappeared in the frontend, It's not the view out of the list but it's the detailed view of only one article. The view of the article ist replaced by "The news record is not available anymore." The article itself has not been archived or similar action, only updating news to 7.2.0 leads to this fault. Update to version 7.3.1 didn't solve the problem.

Expected behavior/output The detailed view of one singular article as a content element should be possible from versions 7.2.0 upwards.

Environment

  • TYPO3 version(s): 8.7.27
  • news version: 7.2.0
  • Is your TYPO3 installation set up with Composer (Composer Mode): no
  • OS: Server Ubuntu 16.04, Client Windows 10

Possible Solution

Additional context Add any other context about the problem here

topsnet-holgerd avatar Sep 09 '19 09:09 topsnet-holgerd

I have the same problem. After updating the news extension, the output of a specific news article via the detail view output no longer works. Error message in my frontend:

Page Not Found Reason: No news entry found.

I was able to fix the news extension dirty, but there's certainly a nicer solution. Here is my wordaround:

file: /typo3conf/ext/news/Classes/Controller/NewsController.php

Line 370, I have added the following:

// set single News entry if it was set in plugin configuration
if (is_null($news) && (int)$this->settings['singleNews'] > 0) {
    $news = (int)$this->settings['singleNews'];
}

I would be happy if this can be fixed in the next version.

eckonator avatar Oct 25 '19 12:10 eckonator

Dear eckonator, thank you, works for me, as well with specific items as with single articles out of a list. First I took the code out of the email, that was sent to me, with an else $news = null. With this displaying single items out of a list was not possible. But with the change as described above everything ist fine. Best regards

topsnet-holgerd avatar Oct 30 '19 09:10 topsnet-holgerd

can you please give a description how this can be reproduced with latest news version. thx

georgringer avatar Oct 31 '19 20:10 georgringer

Hi Georg, in my case it‘s simple to reproduce: Create a detail view page and let it show a specific news article choosen in flexform. In latest news version happened in frontend the error which i descriped. Hope it’s clear?

eckonator avatar Oct 31 '19 20:10 eckonator

Yes, as well in my case Sorry, closed the issue by mistake, reopened it a few minutes later ...

topsnet-holgerd avatar Nov 04 '19 13:11 topsnet-holgerd

Dear Georg, dear eckonator, I'm sorry, but this issue has not been solved. Even if eckonators workaround did it in Typo3 8.7, it currently throws exceptions in Typo3 9.5. If I take news 7.3.1 (which can be used in T3 9.5) with eckonators workaround, I get

(1/1) #1588784142 BadMethodCallException
Cannot unserialize TYPO3\CMS\Core\Locking\FileLockStrategy
in /var/www/clients/client14/web242/web/typo3_src-9.5.20/typo3/sysext/core/Classes/Security/BlockSerializationTrait.php line 34
     * Deny object deserialization.
     */
    public function __wakeup()
    {
        throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__, 1588784142);
    }
}
at TYPO3\CMS\Core\Locking\FileLockStrategy->__wakeup()

But when I change to news 8.3.0 and paste the workaround of eckonator to NewsController.php, the exception is

(1/1) Error
Call to a member function getUid() on integer
in /var/www/clients/client14/web242/web/public/typo3conf/ext/news/Classes/Utility/Cache.php line 62
    {
        $cacheTags = [];
        foreach ($newsRecords as $news) {
            // cache tag for each news record
            $cacheTags[] = 'tx_news_uid_' . $news->getUid();

            if ($news->_getProperty('_localizedUid')) {
                $cacheTags[] = 'tx_news_uid_' . $news->_getProperty('_localizedUid');
            }
at GeorgRinger\News\Utility\Cache::addCacheTagsByNewsRecords(array(1115))

I would appreciate, if this issue can be solved anyway, Even if single news display seems not to be popular, I need it for this one project.

topsnet-holgerd avatar Aug 04 '20 10:08 topsnet-holgerd

Hi Georg, in my case it‘s simple to reproduce: Create a detail view page and let it show a specific news article choosen in flexform. In latest news version happened in frontend the error which i descriped. Hope it’s clear?

Dear Eckonator, unfortunately your workaround, that works fine in Typo3 8.7, currently throws exception in Typo3 9.5. Do you have any idea? I noticed, that displaying a selected list with one article works, but I've nearly 60 pages, where this has to be applied and the template of selected list as well.

topsnet-holgerd avatar Aug 04 '20 13:08 topsnet-holgerd

Hi Georg, in my case it‘s simple to reproduce: Create a detail view page and let it show a specific news article choosen in flexform. In latest news version happened in frontend the error which i descriped. Hope it’s clear?

Dear Eckonator, unfortunately your workaround, that works fine in Typo3 8.7, currently throws exception in Typo3 9.5. Do you have any idea? I noticed, that displaying a selected list with one article works, but I've nearly 60 pages, where this has to be applied and the template of selected list as well.

Hi @topsnet-holgerd, I have just tested the behaviour under TYPO3 9.5.19 and the news extension 7.3.1 and 8.3.0. The result is that in both versions the display of a specific news message works without having to change the code. So I guess your problem is somewhere else.

eckonator avatar Aug 04 '20 14:08 eckonator

Hi @topsnet-holgerd, I have just tested the behaviour under TYPO3 9.5.19 and the news extension 7.3.1 and 8.3.0. The result is that in both versions the display of a specific news message works without having to change the code. So I guess your problem is somewhere else.

Dear eckonator, dear Georg, thanks for replying. We found out, that our problem has been, that the news are of type 1 (internal links). In NewsController.php line 370 (version 8.3.0) $news ist set to null, if of type 1 or 2. So, this is a very special case, where we have internal links that should be displayed in single mode. We are having success in displaying such a single news, when commenting line 370 //$news = null; I wonder, if this changing leads to any unexpected and unwanted side effects.

topsnet-holgerd avatar Aug 04 '20 15:08 topsnet-holgerd

can you please give a description how this can be reproduced with latest news version. thx

Dear Georg, this issue now is near its end. In line 370 of the NewsController you are nulling the news object, if it is a shortcut or an internal or external link. I'm wondering, for what purpose this happens. Would you mind, to think about it once again and to let a news be displayed in single mode view, even if its from type 1 or 2. I would appreciate, if that will take place in future versions of news. Best regards

topsnet-holgerd avatar Aug 07 '20 14:08 topsnet-holgerd

it is only set to null if the setting isShortcut is set to 1 which is the case if the news is included via insert record content element. this setting can also be removed by you

georgringer avatar Mar 03 '21 19:03 georgringer

it is only set to null if the setting isShortcut is set to 1 which is the case if the news is included via insert record content element. this setting can also be removed by you

The code says:

if ($news && !($this->settings['isShortcut'] ?? false) && ($news->getType() === '1' || $news->getType() === '2')) {
    $news = null;
}

The little ! means that it's set to null if the setting isShortcut is set to 0 (or not set).

This can for example happen if you have a news article in the default language, and a translation which is set to type 1 or 2. If you switch languages you won't be forwarded to the internal/external URL but instead get an error message "the news record is not available anymore"

Example in the wild: https://nat.au.dk/om-fakultetet/nyheder/archive/2021/juni shows a list of Danish news articles. The article "Lektor Ebbe S. Andersen modtager Elastyrenprisen 2021" is a link to the detail view. The English version (language link in top of page) of that list (only two items have been translated) shows that the news item in that language is an external link. If you open the detail view of the Danish article it displays the article. If you then switch to English the error "the news record is not available anymore" is shown.

It seems that these news types need to have some redirect handling in the detail action.

github1maxserv avatar Oct 29 '21 07:10 github1maxserv