Created
July 25, 2022 18:13
-
-
Save ivangrozni/64536c3e0634251e498292c26b99cf8a to your computer and use it in GitHub Desktop.
ldp-1555-simple_sitemap-3299827-php81-compatibility.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2a457499e437b0d327c15a76560edaf32cd3c77f Mon Sep 17 00:00:00 2001 | |
From: Lio Novelli <liopold@drunomics.com> | |
Date: Mon, 25 Jul 2022 20:04:05 +0200 | |
Subject: [PATCH] #3299827: Fix php8.1 compatibility in strlen. | |
--- | |
src/Commands/SimplesitemapCommands.php | 2 +- | |
.../SitemapGenerator/DefaultSitemapGenerator.php | 4 ++-- | |
2 files changed, 3 insertions(+), 3 deletions(-) | |
diff --git a/src/Commands/SimplesitemapCommands.php b/src/Commands/SimplesitemapCommands.php | |
index db5b9ee..e1e98eb 100644 | |
--- a/src/Commands/SimplesitemapCommands.php | |
+++ b/src/Commands/SimplesitemapCommands.php | |
@@ -64,7 +64,7 @@ class SimplesitemapCommands extends DrushCommands { | |
*/ | |
public function rebuildQueue(array $options = ['variants' => '']) { | |
$variants = array_keys($this->generator->getSitemapManager()->getSitemapVariants(NULL, FALSE)); | |
- if (strlen($options['variants']) > 0) { | |
+ if (!empty($options['variants']) && strlen($options['variants']) > 0) { | |
$chosen_variants = array_map('trim', array_filter(explode(',', $options['variants']))); | |
if (!empty($erroneous_variants = array_diff($chosen_variants, $variants))) { | |
$message = 'The following variants do not exist: ' . implode(', ', $erroneous_variants) | |
diff --git a/src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php b/src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php | |
index abf6e39..835d689 100755 | |
--- a/src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php | |
+++ b/src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php | |
@@ -124,10 +124,10 @@ class DefaultSitemapGenerator extends SitemapGeneratorBase { | |
foreach ($url_data['images'] as $image) { | |
$this->writer->startElement('image:image'); | |
$this->writer->writeElement('image:loc', $image['path']); | |
- if (strlen($image['title']) > 0) { | |
+ if (!empty($image['title']) && strlen($image['title']) > 0) { | |
$this->writer->writeElement('image:title', $image['title']); | |
} | |
- if (strlen($image['alt']) > 0) { | |
+ if (!empty($image['title']) && strlen($image['alt']) > 0) { | |
$this->writer->writeElement('image:caption', $image['alt']); | |
} | |
$this->writer->endElement(); | |
-- | |
GitLab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment