Problem/Motivation

I am using the latest update () of the module on a local development site and mirrored production site.

I have double checked all configuration and it is identical on both sites.

Visiting /sitemap.xml in the browser results in just that, a perfectly formed sitemap.

However, on the production site I see...

xml_sitemap_view_on_production

Digging deeper by looking into the page source, I can clearly see the offence! ...

xml_sitemap_view_local_vs_production

On the production site, the sitemap itself if perfectly intact but that extra first line won't budge no matter how many attempts at regenerating the map Ido.

Any ideas anyone?

Thank you

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sirclickalot created an issue. See original summary.

medha kumari’s picture

Assigned: Unassigned » medha kumari

Working on It.

medha kumari’s picture

Assigned: medha kumari » Unassigned
Status: Active » Needs review

Hi, I create MR for this. Please check and review. Thanks!

sirclickalot’s picture

Hi @medha kumari,

Thank you for this.

Before I try it out though, could you please explain what you found to be the 'cause' of the problem and how your patch deals with that?

medha kumari’s picture

Hi @sirclickalot,

Thank you for your message and for looking into this.

The cause of the problem was that a blank line (or some invisible whitespace) was appearing before the XML declaration (<?xml version="1.0"?>) in the sitemap output. XML files must start with this declaration at the very top—if there’s anything before it, browsers and parsers will throw an error.

This extra blank line was coming from the function that generates the XML. Sometimes, it adds unwanted spaces or newlines at the start or end of the output.

The patch fixes this by using the trim() function, which removes any extra spaces or blank lines from the beginning and end of the XML before it’s saved or sent to the browser. This ensures the XML declaration is always at the very start of the file, so the sitemap is valid and the error goes away.

Hope this helps clarify things!

gbyte’s picture

Version: 4.2.3 » 4.x-dev
Assigned: Unassigned » gbyte
Category: Support request » Task
Status: Needs review » Active

This extra blank line was coming from the function that generates the XML. Sometimes, it adds unwanted spaces or newlines at the start or end of the output

It's not the generator, it's your environment. See issues like

...and a few more.

However as this happens again and again, I will look into working around it in the module.

  • gbyte committed fe596bbb on 4.x
    feat: #3560227 Extra (blank) line generated on production site
    
    By:...
gbyte’s picture

Status: Active » Fixed

I have applied trimming to SitmeapWriter::outputMemory instead so custom plugins in the wild can take advantage.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sirclickalot’s picture

Given the 13000+ user base for this great little module coupled with impact of the fix in #10, might we be able to get a release out before Christmas?

gbyte’s picture

Given the 13000+ user base for this great little module coupled with impact of the fix in #10, might we be able to get a release out before Christmas?

I'm afraid this fix is relevant to a very small number of users with erroneous environments. The release will have to wait for further bug fixes and features.

sirclickalot’s picture

Status: Fixed » Closed (works as designed)
gbyte’s picture

Status: Closed (works as designed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.