backdrop-contrib / xmlsitemap

Provides a sitemap that conforms to the sitemaps.org specification.
GNU General Public License v2.0
1 stars 12 forks source link

If set to skip 301 pages then Update fails with error #124

Closed yorkshire-pudding closed 3 weeks ago

yorkshire-pudding commented 8 months ago

Steps to reproduce

  1. On admin/config/search/xmlsitemap/settings select 'Skip pages that have 301 redirects set.' and click 'Save configuration'
  2. Go to admin/config/search/xmlsitemap
  3. Select a sitemap using the checkbox
  4. Select 'Update cached files" and click 'Update'

Expected result Sitemap updates

Actual result Fatal error:

Error: Call to undefined function redirect_fetch_rids_by_path() in xmlsitemap_generate_chunk() (line 208 of /app/docroot/modules/contrib/xmlsitemap/xmlsitemap.generate.inc)

image

The function is still there in the Drupal 7.x-2.x branch (as well as 7.x-1.x) so it was removed during the move to core Backdrop, but I can't figure out why it was removed or if there is an equivalent function that should be used here. Perhaps @quicksketch can shed some light on this point?

redirect_fetch_rids_by_path() ```php /** * Fetches multiple URL redirect IDs from the database by {redirect}.source. * * @param $source * The source of the URL redirect. * @param $language * Language of the source URL. * @param $enabled_only * Boolean that indicates whether to only load enabled redirects. * * @return array * An indexed array of IDs, or an empty array if there is no result set. */ function redirect_fetch_rids_by_path($source, $language, $enabled_only = FALSE) { static $status_field_exists = NULL; if (!isset($status_field_exists)) { // Prevent errors if redirect_update_7101() has not yet been run. $status_field_exists = db_field_exists('redirect', 'status'); } // Run a case-insensitive query for matching RIDs first. $rid_query = db_select('redirect'); $rid_query->addField('redirect', 'rid'); if ($enabled_only && $status_field_exists) { $rid_query->condition('status', 1); } if ($source != variable_get('site_frontpage', 'node')) { $rid_query->condition('source', db_like($source), 'LIKE'); } else { $source_condition = db_or(); $source_condition->condition('source', db_like($source), 'LIKE'); $source_condition->condition('source', ''); $rid_query->condition($source_condition); } $rid_query->condition('language', array($language, LANGUAGE_NONE)); $rid_query->addTag('redirect_fetch'); $rids = $rid_query->execute()->fetchCol(); return $rids; } ```
laryn commented 3 weeks ago

@yorkshire-pudding Sorry I missed this issue when you first filed it. But I think this error was also sniffed out by PHPStan in the recent Coding Standards issue. It should be fixed in dev and in the next release. Please reopen if you are still having issues, though!