barrelstrength / sprout

Sprout Marketing Suite modules for Craft CMS applications
https://sprout.barrelstrengthdesign.com
Other
2 stars 6 forks source link

sitemap-singles.xml type error: must be of type int, null given #321

Closed strahey closed 2 weeks ago

strahey commented 1 month ago

Description

sitemap.xml generates a link to sitemap-singles.xml which generates an error: BarrelStrength\Sprout\sitemaps\sitemaps\XmlSitemap::getDynamicSitemapElements(): Argument #3 ($pageNumber) must be of type int, null given, called in /var/www/html/vendor/barrelstrength/sprout/src/sitemaps/controllers/XmlSitemapController.php on line 71

  1. in /var/www/html/vendor/barrelstrength/sprout/src/sitemaps/sitemaps/XmlSitemap.phpat line 43
  2. in /var/www/html/vendor/barrelstrength/sprout/src/sitemaps/controllers/XmlSitemapController.php at line 71– BarrelStrength\Sprout\sitemaps\sitemaps\XmlSitemap::getDynamicSitemapElements('singles', 'singles', null, [1 => craft\models\Site], ...)
  3. BarrelStrength\Sprout\sitemaps\controllers\XmlSitemapController::actionRenderXmlSitemap('singles', null)
  4. in /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php at line 57– call_user_func_array([BarrelStrength\Sprout\sitemaps\controllers\XmlSitemapController, 'actionRenderXmlSitemap'], ['singles', null])
  5. in /var/www/html/vendor/yiisoft/yii2/base/Controller.php at line 178– [yii\base\InlineAction::runWithParams](https://www.yiiframework.com/doc-2.0/yii-base-inlineaction.html#runWithParams()-detail)(['sitemapMetadataUid' => 'singles'])
  6. in /var/www/html/vendor/yiisoft/yii2/base/Module.php at line 552– [yii\base\Controller::runAction](https://www.yiiframework.com/doc-2.0/yii-base-controller.html#runAction()-detail)('render-xml-sitemap', ['sitemapMetadataUid' => 'singles'])
  7. in /var/www/html/vendor/craftcms/cms/src/web/Application.php at line 341– [yii\base\Module::runAction](https://www.yiiframework.com/doc-2.0/yii-base-module.html#runAction()-detail)('sprout-module-sitemaps/xml-sitem...', ['sitemapMetadataUid' => 'singles'])
  8. in /var/www/html/vendor/yiisoft/yii2/web/Application.php at line 103– craft\web\Application::runAction('sprout-module-sitemaps/xml-sitem...', ['sitemapMetadataUid' => 'singles'])
  9. in /var/www/html/vendor/craftcms/cms/src/web/Application.php at line 309– [yii\web\Application::handleRequest](https://www.yiiframework.com/doc-2.0/yii-web-application.html#handleRequest()-detail)(craft\web\Request)
  10. in /var/www/html/vendor/yiisoft/yii2/base/Application.php at line 384– craft\web\Application::handleRequest(craft\web\Request)
  11. in /var/www/html/web/index.php at line 12– [yii\base\Application::run](https://www.yiiframework.com/doc-2.0/yii-base-application.html#run()-detail)()

How to reproduce

go to /sitemap-singles.xml error will be displayed

i was able to stop the error by editing vendor/barrelstrength/sprout/src/sitemaps/controllers/XmlSitemapController.php changing line 26 from: public function actionRenderXmlSitemap(string $sitemapMetadataUid = null, int $pageNumber = null): Response

to public function actionRenderXmlSitemap(string $sitemapMetadataUid = null, int $pageNumber = 0): Response

Sprout Version

4.44.444-beta.2

Craft Version

Craft Pro 4.8.9

Database Type Version

MariaDB 10.4.33

strahey commented 1 month ago

PHP version 8.1.27

BenParizek commented 2 weeks ago

@strahey This has been resolved in Sitemaps v4.45.2