RSS issue after 10.11.2 and 10.11.3 upgrade (from 9.11.4)

Hi,

I upgraded my xwiki 8.11.4 to 10.11.2 (and 10.11.3) and since 10.11.2 my RSS reader (thunderbird) display entries with “localhost” URL :frowning:

Like I explain in https://forum.xwiki.org/t/need-help-to-store-raw-data-html-code-in-a-page/2564 I generate RSS feed into plain text 1.0 page: Public.Rss.Rss and read my RSS feed with this URL:
https://correct.url.fr/bin/get/Public/Rss/Rss?outputSyntax=plain

Since 10.11.x upgrade my feed entries display localhost and I try to figure out what is the issue source, and
I noticed that in view mode, Public.Rss.Rss display: localhost

[deleted] because it is scheduler issue.

Could you give me some advice about this issue?

Ty
Pascal B

Can you show me the code that you use to generate the RSS feed and that’s returning the “wrong” URL?

If I understand, when you use the “get” action it’s ok but when you use the “view” action it’s not. Well first we need to see the code you use, maybe you have some if based on the action or you use some API that has that?

Ok here the correct description (sorry but trying to debug :slight_smile: ):
I have a page “Personnalisation/GenPublicRSS” with velocity code who’s generate my “static” RSS page, when I open GenPublicRSS in view mode.
My scheduler periodicely open my page GenPublicRSS to refresh RSS feed and since 10.11.x, my RSS feed displayed “localhost”… but only when lauched by scheduler!
If I open “GenPublicRSS” with my browser, my RSS feed entries are fine.

My script in scheduler is:

xwiki.getDocument("Personnalisation.GenPublicRSS").getRenderedContent()

and code of “Personnalisation/GenPublicRSS”:

{{velocity}}
## Généré le feed RSS (entrées XML) dans $MyPublicRSSDocName
## L’exécution du script doit être planifié dans le scheduler
## Ver. 1.0 du 09/03/2018

#set($MyPublicRSSDocName = 'Public.Rss.Rss')
#set($MySpaces = ['FormSMQ','Encyclopédie','FAQ','Blog','Public'])
##set($MyTags = ['SMQ'])
#set($MyTags = '')
#set($LimitEntries = 10)
Lien du feed RSS: https://iwiki.din.developpement-durable.gouv.fr/bin/get/Public/Rss/Rss?outputSyntax=plain
Enregistre le feed RSS des espaces **"$MySpaces"** et des tags **"$MyTags"** dans la page publique: [[$MyPublicRSSDocName]]
(Code copié de [[Main.WebRss]])

#*
#if (("$!request.xpage" == 'plain' || "$!request.xpage" == 'rdf') && "$!request.outputSyntax" != 'plain')
  $response.sendRedirect($xwiki.getURL($doc.fullName, 'view', 'xpage=plain&outputSyntax=plain'))
#end
#if ("$!request.xpage" == 'plain' && "$!request.outputSyntax" == 'plain')
  $response.setContentType('application/rss+xml')
*#
  ## ======================
  ## Compute Query to find documents
  ## ======================
  #if("$!{MyTags}" != '')
    ## RSS feed for documents tagged with $request.tag
    #set ($query = 'from doc.object(XWiki.TagClass) as tag where (')
    #foreach ($tag in $MyTags)
      #set ($query = "$query :tag${foreach.count} member of tag.tags")
      #if ($foreach.hasNext)
        #set ($query = "$query OR ")
      #end
    #end
    #set ($query = "$query) AND ")
  #else
    #set ($query = 'where')
  #end
  #if("$!{MySpaces}" == '')
    ## RSS feed for the whole wiki
    #set ($query = "$query 1=1")
  #else
    ## RSS feed for spaces
    #set ($query = "$query (")
    #foreach ($space in $MySpaces)
      #set ($query = "$query doc.space=:space${foreach.count} OR doc.space LIKE :space_nested${foreach.count}")
      #if ($foreach.hasNext)
        #set ($query = "$query OR ")
      #end
    #end
    #set ($query = "$query)")
  #end
  #set ($query = "$query order by doc.date desc")
  ## ==============
  ## Bind Query parameters
  ## ==============
  ## Bind query parameters depending on the passed query string parameters
  #set ($queryObject = $services.query.xwql($query).addFilter('hidden/document').addFilter('currentlanguage').setLimit($LimitEntries).setOffset(0))
  #if("$!{MyTags}" != '')
    #foreach ($tag in $MyTags)
      #set ($queryObject = $queryObject.bindValue("tag${foreach.count}", $tag))
    #end
  #end
  #if("$!{MySpaces}" != '')
    #foreach ($space in $MySpaces)
      #set ($queryObject = $queryObject.bindValue("space${foreach.count}", $space))
      #set ($queryObject = $queryObject.bindValue("space_nested${foreach.count}", "${space}.%"))
    #end
  #end
  ## ================
  ## Compute feed description
  ## ================
  ## 4 cases to handle: no spaces and tags specified, only spaces specified, only tags specified and spaces and tags specified
  #if ("$!{MySpaces}" != '')
    #if ("$!{MyTags}" != '')
      #set ($description = $services.localization.render('activity.rss.feed.tagsAndSpaces.description', [$stringtool.join($MyTags, ','), $stringtool.join($MySpaces, ',')]))
    #else
      #set ($description = $services.localization.render('activity.rss.feed.spaces.description', [$stringtool.join($MySpaces, ',')]))
    #end
  #else
    #if ("$!{MyTags}" != '')
      #set ($description = $services.localization.render('activity.rss.feed.tags.description', [$stringtool.join($MyTags, ',')]))
    #else
      #set ($description = $services.localization.render('activity.rss.feed.description'))
    #end
  #end
  ## =====================
  ## Execute query and generate feed
  ## =====================
  #set ($feed = $xwiki.feed.getWebFeed($queryObject.execute()))
  ## Modifie le champ description et la date de maj pour les franciser
  #foreach($MyId in $feed.entries)
    #if ( $MyId.description.value )
      ##* $MyId.description.value $MyId.updatedDate - $datetool.format("E dd MMMM yyyy à HH:mm:ss", $MyId.updatedDate, $services.localization.getCurrentLocale())
   ## Version 1.12, page modifiée par Michel GIBELLI, le jeu. 08 mars 2018 à 11:55:07
   ## Version 1.12, page crée par xxx et modifiée par yyyy le jeu. 08 mars 2018 à 11:55:07.
      #set ($MyString=$MyId.description.value)
   #set ($ToIndex=$MyString.indexOf(' edited by '))
   #set ($MyString = $MyString.substring(0,$ToIndex))
      ##set ($MyString = $MyString.replaceFirst(' edited by ', ', page modifiée par '))
      ###set ($MyString = $MyString.split(' on ', 2))
      ##  $datetool.toDate( convertit une date string en date mais je récupère plutôt la date ailleurs "jeu. 01 février 2018 à 15:47:10"
      #set ($MyStrDate = $datetool.format("E dd MMMM yyyy à HH:mm:ss", $MyId.updatedDate, $services.localization.getCurrentLocale()))
      ##set ($MyString = "$MyString[0], le  $MyStrDate.")
      #if ("$MyId.author" == "$MyId.contributors[0]")
  #set ($MyString = $MyString + ', page créée et modifiée par ' + $MyId.author + ' le ' + $MyStrDate + '.')
   #else
     #set ($MyString = $MyString + ', page créée par ' + $MyId.author + ' et dernièrement modifiée par ' + $MyId.contributors[0] + ' le ' + $MyStrDate + '.')
   #end
          #set ($MyString = $MyString + '<br><br>Rappel: pour retrouver cette page, cliquez sur le lien du site indiqué ci-dessus.')
   #set ($MyId.description.value=$MyString)
   ##  Met l'expéditeur de l'entrée RSS = contributeur
   ##set ($MyId.author.value="$MyId.contributors[0]")
   ##set ($MyId.modules[0].creators[0]="$MyId.contributors[0]")
   #set ($MyId.modules[0].creator="$MyId.contributors[0]")
    #end
  #end
  #set ($feedURI = $xwiki.getDocument('Main.WebHome').getExternalURL('view'))
  #set ($discard = $feed.setLink($feedURI))
  #set ($discard = $feed.setUri($feedURI))
  #set ($discard = $feed.setAuthor('XWiki'))
  #set ($discard = $feed.setTitle($services.localization.render('activity.rss.feed.description')))
  #set ($discard = $feed.setDescription($description))
  #set ($discard = $feed.setLanguage("$xcontext.locale"))
  #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))
  ## $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))
  #*
    ## Debug
    Début feed:
    $feed
    Fin feed
    $xwiki.getXWikiPreference('feed_type', 'rss_2.0')
    ----
    Début json feed:
    $jsontool.serialize($feed) 
    Fin Json feed
    Début getFeedOutput
    $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))
    Fin getFeedOutput
    $services.rendering.getAvailableRendererSyntaxes()
    #set ($MyFeed = $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0')))
  *#
  ##enregistre le feed RSS dans la page
  #set($MyPublicRSS = $xwiki.getDocument($MyPublicRSSDocName))
  #set ($discard=$MyPublicRSS.setContentType('application/rss+xml'))
  #set ($discard=$MyPublicRSS.setSyntaxId('plain/1.0'))
  #set ($discard=$MyPublicRSS.setContent("$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))"))
##set ($discard=$MyPublicRSS.setContent($jsontool.serialize($feed)))
  #set ($discard=$MyPublicRSS.save())
  [[$MyPublicRSS]] sauvés
##end
{{/velocity}}

When you trigger a scheduler job, the xwiki context is saved and this context is going to be used for all subsequent executions. So you probably just triggered the job with localhost in the URL as the server name.

I didn’t change server name after upgrade…
Do you mean I must stop and start my scheduled job to fix?

Ok I never use localhost because it is an external server. Maybe I launched some tunneling (during upgrade process)?
Anyways I will reboot my server to see if my issue is fixed.

You just need to untrigger and retrigger the job…

yes ty I already did it but I want to see if this issue persist after a tomcat restart.

and it worked?

Indeed the xwiki context will be resaved at startup based on the first request in the system.

ok thxs I try to not forget this point at next upgrade :slight_smile: