Using Drupal 8.0.3 and simple_xml 8.2.2. We have a site with 10K+ articles we needed to have listed in our sitemap.xml file. We have the "Maxium link in a sitemap" setting at 5000 and "Refresh batch every n links" at 1500. We tried generating the sitemap with drush by running:

drush simple_sitemap-generate

Got the following error on the last batch iteration:

Fatal error: Call to undefined function Drupal\simple_sitemap\Batch::finishBatch() in /usr/local/drush8/vendor/drush/drush/commands/core/drupal/batch.inc on line 231
Drush command terminated abnormally due to an unrecoverable error.                                                                                 [error]
Error: Call to undefined function Drupal\simple_sitemap\Batch::finishBatch() in
/usr/local/drush8/vendor/drush/drush/commands/core/drupal/batch.inc, line 231
The external command could not be executed due to an application error.   

Comments

ec0g created an issue. See original summary.

ec0g’s picture

We went ahead and provided a quick patch. There aren't any tests around this issue with the patch.

ec0g’s picture

Status: Active » Needs review
gbyte’s picture

Hi ec0g, any idea why __CLASS__ . '::finishBatch' stopped working and why [__CLASS__ , 'finishBatch'] apparently does? How did you come up with the fix?

ec0g’s picture

Hi @gbyte,

I had built a batched import featured earlier and from the samples I saw I used an array to point to the location of 'finished'. Which is why I decided to try the array. It resolved our need in all of our environments for several D8 sites.

That's a really good question though. I didn't have time to think about it earlier, but I did some digging just now.

The value of the 'finished' array key gets passed as the first parameter to call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000))) in function _batch_finished() which is part of batch.inc. Since __CLASS__ . '::finishBatch' is the location of a static function (including the namespace) it should be able to be used as a callable in a call_user_func_array($callable) function.

I'm going to look into it a little bit more. We haven't updated Drupal yet, so we're using the same core codebase. We did have some trouble upgrading the module from the dev version to the 8.x-2.2 version, but after upgrading we used the 8.x-2.2 version to generate the sitemaps for 3 sites, each one with over 10K entities.

Thanks for jumping in quickly. I'll update here if I have any new information.

ec0g’s picture

Looks like an issue with this closure in Drush v8.0.5:

vendor/drush/drush/commands/core/drupal/batch.inc
$batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, $elapsed);

  • gbyte.co committed f33f00d on 8.x-2.x authored by ec0g
    Issue #2713661 by ec0g: Fatal error: Call to undefined function Drupal\...
gbyte’s picture

Version: 8.x-2.2 » 8.x-2.x-dev
Status: Needs review » Fixed

Commited to dev, thanks for your insights.

Status: Fixed » Closed (fixed)

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