When I try to enable the XML SiteMap module, I get the following nasty error screen. The module seems to enable after visiting the the Extend and Configuration pages but does not provide a positive user experience.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deaconblues’s picture

Issue summary: View changes
FileSize
1.97 KB

See the attached patch for the fixed that worked for me. Adding a null value check for the $this variable in the affected area. I'm not getting the crash at this point.

deaconblues’s picture

Issue summary: View changes
deaconblues’s picture

Status: Active » Needs review
deaconblues’s picture

This patch is ready for review. Can someone check it out and let me know if it works?

paulmckibben’s picture

Status: Needs review » Needs work

Hi deaconblues,

Thanks for your patch. I'm trying to reproduce your original issue by enabling the xmlsitemap module on Drupal 8.0.0 beta12, and I don't experience your issue. Can you tell me the exact steps you took to encounter the issue?

That said, looking at the code, there is indeed a problem: $this will always be null, because the function _xmlsitemap_get_blurb() is not a method in an object. So your patch does not actually go far enough. Replace each instance of:

  $this->l()

with:

  \Drupal::l()

And that should do the trick!

deaconblues’s picture

I was able to reproduce this using Drupal core 8.0.0-beta11 and XML sitemap 8.x-1.x-dev (2015-May-15). When enabling the XML Sitemap module, I received the screenshot above but everything seemed to be OK if I just navigated to the rest of the configuration pages.

I noticed that $this was always null but just added the null check as I assumed that there would be additional functionality coming that would use the variable in later releases. If this has been corrected in beta12 and the 2015-Jun-30 release of XML Sitemap then we can close this ticket out as fixed.

afoster’s picture

Confirming This error with beta-15 and latest dev (Downloaded Oct 1) via $drush dl xmlsitemap-8.x-1.x--dev

When visiting - http://dww.dev/admin/config/search/xmlsitemap

"Fatal error: Using $this when not in object context in /XXXXXX/modules/xmlsitemap/xmlsitemap.module on line 2272"

I'm on PHP 5.6.10

benelori’s picture

Status: Needs work » Needs review
FileSize
1.84 KB

The problem is as described #5. Uploaded a patch mirroring that.

benelori’s picture

Status: Needs review » Needs work

I uploaded a patch with the wrong path, so it won't apply for sure. I'll be back shortly with a fixed patch.

benelori’s picture

Status: Needs work » Needs review
FileSize
1.74 KB
swentel’s picture

Status: Needs review » Needs work

That would probably work out well, however, xmlsitemap_help() is out of sync completely, so we'd better fix that along the way too.

deaconblues’s picture

I tried the patch that benelori uploaded on version 8.05 and it seems to have cleared the immediate crash in that part of the module. Can we pass this patch and get it applied to the Dev branch?

pguillard’s picture

What is the plan to get xmlsitemap_help() in sync ?
If I can be helpful... Because it would be good to commit this one !

pguillard’s picture

Status: Needs work » Needs review
juampynr’s picture

Status: Needs review » Closed (duplicate)

This got fixed at #2459595: Rebuild has error when Language enabled. Marking as duplicate and closing.

The last submitted patch, 8: fatal-error-fix-2505903-8.patch, failed testing.

Status: Closed (duplicate) » Needs work

The last submitted patch, 10: fatal-error-fix-2505903-10.patch, failed testing.

amateescu’s picture

Status: Needs work » Closed (duplicate)