Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When RSS feed for COM_FINDER is enabled, feed displayed via menu item alias give Error 500 #10961

Closed
ghost opened this issue Jun 29, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Jun 29, 2016

The RSS feed for COM_FINDER search throw an Error 500 for all feed type.
(This is an error i had already logged here : https://developer.joomla.org/joomlacode-archive/issue-30167.html)

Steps to reproduce the issue

1 - Set $offset value of configuration.php :

public $offset = 'Europe/Paris';
public $offset_user = 'UTC';

2 - Languages published in the website are : French (default), English.

3 - Set a "menu item alias" for com_finder and name it "search" :

4 - Try to access URL like the example below :
www.mywebsite.com/search?q=Mac&format=feed&type=rss

Expected result

Display of an Atom or RSS feed related to your search term.
This should also work if you have search feed for tags enabled.

Actual result

Error displaying the error page:
Unable to load renderer class: DateTime::__construct():
Failed to parse time string (jeudi 26 décembre 2013) at position 0 (j):
The timezone could not be found in the database

Note : 'jeudi 26 décembre 2013' is the date submitted in French.
English equivalent of : 'Thursday 26 December 2013'

System information (as much as possible)

Joomla version is : 3.5.1

PHP version is : 5.6

In language File for French (fr-FR.ini) you have the values set as below :
(the joomla original value is commented by ";")

; DATE_FORMAT_LC="l j F Y"
DATE_FORMAT_LC="j-m-Y"
; DATE_FORMAT_LC1="l j F Y"
DATE_FORMAT_LC1="j-m-Y"
; DATE_FORMAT_LC2="l j F Y H:i"
DATE_FORMAT_LC2="j-m-Y H:i"
; DATE_FORMAT_LC3="j F Y"
DATE_FORMAT_LC3="j-m-Y"
DATE_FORMAT_LC4="j/m/Y"
DATE_FORMAT_JS1="j/m/y"

Proposal of Solution

The reason of the issue (in my opinion) lies in file <joomla_path>/components/com_finder/views/search/view.feed.php
at line 87. We have a date formated as : JHtml::date($result->start_date, 'l d F Y').
If $result->start_date value does not match format 'l d F Y', the JHtml::date fails.

Given that in feed.php found in <joomla_path>/libraries/joomla/document/feed/feed.php
the type of feeditem date can only be RFC 822, ISO 8601 or Unix Timestamp :

Extract from feed.php :
/**
* Published date
*
* optional
*
* May be in one of the following formats:
*
* RFC 822:
* "Mon, 20 Jan 03 18:05:41 +0400"
* "20 Jan 03 18:05:41 +0000"
*
* ISO 8601:
* "2003-01-20T18:05:41+04:00"
*
* Unix:
* 1043082341
*
* @var string
* @SInCE 11.1
*/

I propose to always set date format as Unix timestamp to stay safe :

To fix this issue, in statement at line 87 from file <joomla_path>/components/com_finder/views/search/view.feed.php, replace the "l d F Y" by "U":

Before :
$item->date = intval($result->start_date) ? JHtml::date($result->start_date, '"l d F Y') : $result->indexdate;

After :
$item->date = intval($result->start_date) ? JHtml::date($result->start_date, 'U') : $result->indexdate;

What do you think ?

Attached is my version of : view.feed.php (renamed as view.feed.php.txt to be allowed for upload)
view.feed.php.txt
And this works on my website : www.anikijournal.com
Example : http://www.anikijournal.com/search?q=OTA&format=feed&type=atom

@ghost ghost changed the title When RSS feed for COM_FINDER is enabled, feed displayed throw menu item alias give Error 500 When RSS feed for COM_FINDER is enabled, feed displayed via menu item alias give Error 500 Jun 29, 2016
@brianteeman
Copy link
Contributor

@infograf768 could you take a look at this please as it works fine in english just not in french (assuming I have read this correctly)


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

@brianteeman
Copy link
Contributor

Closed as we have a pr for testing #11457

@ghost
Copy link
Author

ghost commented Aug 14, 2016

Very good. Thanks a lot for the PR.

@brianteeman
Copy link
Contributor

Can you test it please

@meditant
Copy link

meditant commented Mar 2, 2018

I have the same thing in joomla 3.8.5 (French configuration) and the same fix work

Best regards,


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

@infograf768
Copy link
Member

I confirm the issue is still present in 3.8.6RC

Error: Call to undefined method Joomla\CMS\Document\FeedDocument::addHeadLink(): DateTime::__construct(): Failed to parse time string (jeudi 02 novembre 2017) at position 0 (j): The timezone could not be found in the database

The PR stated above has nothing to do with the issue. The one concerned is #11557 which was closed.

@infograf768
Copy link
Member

Will make a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants