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

Feed format: Returns empty file for empty query result #1419

Closed
s7eph4n opened this issue Feb 24, 2016 · 3 comments
Closed

Feed format: Returns empty file for empty query result #1419

s7eph4n opened this issue Feb 24, 2016 · 3 comments
Assignees
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error

Comments

@s7eph4n
Copy link
Contributor

s7eph4n commented Feb 24, 2016

When a query returns a result with 0 entries the feed format will return an empty file (looks like an HTTP 500, but isn't).
I don't know the spec for RSS, so this may actually be correct behavior, but intuitively I would have expected some valid XML, just without any entries. Something like

<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Testwiki</title>
        <link>http://127.0.0.1/mw/index.php/Special:Ask</link>
        <description>From Testwiki</description>
        <language>en</language>
        <generator>MediaWiki 1.27alpha</generator>
        <lastBuildDate>Wed, 24 Feb 2016 23:04:48 GMT</lastBuildDate>
    </channel>
</rss>
@JeroenDeDauw JeroenDeDauw added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Feb 25, 2016
@JeroenDeDauw
Copy link
Member

I don't know the spec either, but this is also how I expect it to work.

@mwjames
Copy link
Contributor

mwjames commented Feb 25, 2016

After a superficial look into FeedResultPrinter, how about?

    protected function getResultText( SMWQueryResult $res, $outputMode ) {

        if ( $outputMode == SMW_OUTPUT_FILE ) {
            if ( $res->getCount() == 0 ){
                $res->addErrors( array( $this->getContext()->msg( 'smw_result_noresults' )->inContentLanguage()->text() ) );
-               return '';
+           //  return '';

to return something like:

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>mw-26-00</title>
<link>
http://localhost:8080/mw-26-00/index.php/Special:Ask
</link>
<description>From mw-26-00</description>
<language>en</language>
<generator>MediaWiki 1.26.0</generator>
<lastBuildDate>Thu, 25 Feb 2016 09:13:48 GMT</lastBuildDate>
</channel>
</rss>

@s7eph4n
Copy link
Contributor Author

s7eph4n commented Feb 25, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Projects
None yet
Development

No branches or pull requests

3 participants