First I think this was just posted related to dev version recently, but I think that post was totally changed, so I decided to open a new one. Anyway this is a test on unstable1 and maybe not exactly triggered by same line of code. I'm not familiar with the code on this module so I'm going to just tell when it appears. I hope this can help you find the problem.

The warning:

recoverable fatal error: Argument 2 passed to _xmlsitemap_check_changed_link() must be an array, boolean given, called in ../sites/all/modules/xmlsitemap/xmlsitemap.module on line 487 and defined in ../sites/all/modules/xmlsitemap/xmlsitemap.module on line 385.

Steps followed to make it appear:

  1. I enable XML sitemap and XML sitemap node
  2. I go to /admin/settings/xmlsitemap/rebuild to rebuild the sitemap and import site content to sitemap
  3. I create new story and the error is triggered
  4. If I create another new story the error is not triggered
  5. I run cron and those new stories are included on sitemap
  6. I create a new story and the error is triggered again

It seems the error is triggered anytime the sitemap is up to date and a new story is published.

Comments

manfer’s picture

The problem must be that db_fetch_array on line 483 returns FALSE on those cases, so the variable existing is a boolean and the function call to _xmlsitemap_check_changed_link on line 487 expects an array as second argument not a boolean.

Changing line 487:

  $existing = db_fetch_array(db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount FROM {xmlsitemap} WHERE type = '%s' AND id = %d", $link['type'], $link['id'], 0, 1));

with:

  $existing = db_fetch_array(db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount FROM {xmlsitemap} WHERE type = '%s' AND id = %d", $link['type'], $link['id'], 0, 1));
  if (!$existing) {
    $existing = NULL;
  }

should solve the problem. But don't know if it is the best solution.

manfer’s picture

A warning will appear with that change:

user warning: Unknown column 'language' in 'field list' query: SELECT loc, lastmod, changefreq, changecount, priority, access, status, language FROM xmlsitemap WHERE type = 'node' AND id = 72 LIMIT 0, 1 in ../sites/all/modules/xmlsitemap/xmlsitemap.module on line 388.

Can be solved changing line 388 from:

    $original_link = db_fetch_array(db_query_range("SELECT loc, lastmod, changefreq, changecount, priority, access, status, language FROM {xmlsitemap} WHERE type = '%s' AND id = %d", $link['type'], $link['id'], 0, 1));

to:

    $original_link = db_fetch_array(db_query_range("SELECT loc, lastmod, changefreq, changecount, priority, access, status FROM {xmlsitemap} WHERE type = '%s' AND id = %d", $link['type'], $link['id'], 0, 1));

Again I must say I don't know how exactly the code works. It seems you are not using that language column parameter at all in _xmlsitemap_check_changed_link function and the change can be made. But maybe is something you are planning to use.

Dave Reid’s picture

Status: Active » Fixed

Ok yes I can duplicate this with the steps you provided (thank you!). Since db_fetch_array() can return FALSE if it's a new record. It would just be easier to remove the typecasting and let booleans be passed as a parameter. Thanks again for provided more details so this could be fixed!

As for the langauge column, you should run the update.php script. It adds the langauge column in xmlsitemap_update_16().

manfer’s picture

Well, It seems you need the array argument on that function. When it is not NULL you use that array inside the function to access some parameters of original_link.

If you change that argument to boolean I suppose you need more changes inside the function.

Maybe you really don't need that parameter at all and you can do that db_fetch inside the function always. By now inside the function the db_fetch is done only when original_link argument is not passed to function (NULL). But I don't know where else on all the module you call that function to know how much you should change.

In response of language I'm going to look a little more but, fresh install and no language column on MySQL xmlsitemap table. Update.php does not show any update needed (by the way it is not showing a 16 update on xmlsitemap in the version im currently testing, 6.x-2.0-unstable1). I'm going to look a little more to try to find a clue of what is going wrong and I will look to xmlsitemap.install too.

Maybe it is an stupid question. Would it be better if I do tests on dev version? Are you making all these changes available on dev version?

The answers to that stupid questions are probably yes. :)

Dave Reid’s picture

Oh, I think I added the language column after unstable1, but had the language column in the SQL, so that's a bug. I can roll an unstable2 shortly.

As far as a boolean for the parameter, db_fetch_array() will either return FALSE if the record wasn't found or the array from the db. So those are the only conditions that matter, which is what is checked in _xmlsitemap_check_changed_link(). We need to fetch the record outside of _xmlsitemap_check_changed_link() because we need to know if a record already exists for drupal_write_record(). And if variable_get('xmlsitemap_regenerate_needed', FALSE) is TRUE, we can skip _xmlsitemap_check_changed_link().

There's still a bit of weirdness going on between these two functions and I could probably clean it up a little bit, but it should be working properly on unstable2.

Dave Reid’s picture

I'm always making changes in the CVS/dev version, but Drupal only re-packages the dev version from CVS every 12 hours, so it's not always the extreme 'latest' code. You'd need to check the code out from CVS for that.

manfer’s picture

ok, no problem. Then better I do tests with co from last CVS version. Maybe more helpful that way. If I continue with unstable1 soon or later I would report something you have just solved. :)

pbeakley’s picture

I've got the same message when I add a new taxonomy term. The term is successfully added, and I get the scary message at the top.

recoverable fatal error: Argument 2 passed to _xmlsitemap_check_changed_link() must be an array, boolean given, called in ../sites/default/modules/xmlsitemap/xmlsitemap.module on line 544 and defined in ../default/modules/xmlsitemap/xmlsitemap.module on line 443.

Dave Reid’s picture

6.x-2.0-unstable2 is ready to download: http://drupal.org/node/554996

pbeakley’s picture

David -- we crossposted and then I edited my initial post. My errors are coming out of DIFFERENT module lines than the one posted (and I probably misposted this note, apologies). Do you think the new module will fix it?

Dave Reid’s picture

@pbeakley: Yes it should.

Status: Fixed » Closed (fixed)

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