Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | simple_sitemap-fix-finishBatch-fatal-2713661-#2-8.x.patch | 523 bytes | ec0g |
Comments
Comment #2
ec0g CreditAttribution: ec0g as a volunteer and at Questex commentedWe went ahead and provided a quick patch. There aren't any tests around this issue with the patch.
Comment #3
ec0g CreditAttribution: ec0g as a volunteer and at Questex commentedComment #4
gbyte CreditAttribution: gbyte as a volunteer and commentedHi ec0g, any idea why
__CLASS__ . '::finishBatch'
stopped working and why[__CLASS__ , 'finishBatch']
apparently does? How did you come up with the fix?Comment #5
ec0g CreditAttribution: ec0g as a volunteer and at Questex commentedHi @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)))
infunction _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 acall_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.
Comment #6
ec0g CreditAttribution: ec0g as a volunteer and at Questex commentedLooks 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);
Comment #8
gbyte CreditAttribution: gbyte as a volunteer and commentedCommited to dev, thanks for your insights.