Skip to content

Commit f3a9129

Browse files
phansysfranmomu
authored andcommitted
[Sluggable] Cast slug to string before passing it as argument 2 to preg_match()
1 parent 2d49e02 commit f3a9129

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ a release.
2727
- Tree: In `ClosureTreeRepository::removeFromTree()` and `NestedTreeRepository::removeFromTree()` when something fails in the transaction, it uses the `code` from the original exception to construct the `\Gedmo\Exception\RuntimeException` instance instead of `null`.
2828

2929
#### Fixed
30+
- Sluggable: Cast slug to string before passing it as argument 2 to `preg_match()` (#2473)
3031
- Sortable: [SortableGroup] Fix sorting date columns in SQLite (#2462).
3132
- PHPDoc of `AbstractMaterializedPath::removeNode()` and `AbstractMaterializedPath::getChildren()`
3233

src/Sluggable/Handler/InversedRelativeSlugHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function onSlugCompletion(SluggableAdapter $ea, array &$config, $object,
106106
continue;
107107
}
108108

109-
$objectSlug = $meta->getReflectionProperty($mappedByConfig['slug'])->getValue($object);
109+
$objectSlug = (string) $meta->getReflectionProperty($mappedByConfig['slug'])->getValue($object);
110110
if (preg_match("@^{$oldSlug}@smi", $objectSlug)) {
111111
$objectSlug = str_replace($oldSlug, $slug, $objectSlug);
112112
$meta->getReflectionProperty($mappedByConfig['slug'])->setValue($object, $objectSlug);

src/Sluggable/Handler/TreeSlugHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function onSlugCompletion(SluggableAdapter $ea, array &$config, $object,
146146
continue;
147147
}
148148

149-
$objectSlug = $meta->getReflectionProperty($config['slug'])->getValue($object);
149+
$objectSlug = (string) $meta->getReflectionProperty($config['slug'])->getValue($object);
150150
if (preg_match("@^{$target}{$config['pathSeparator']}@smi", $objectSlug)) {
151151
$objectSlug = str_replace($target, $slug, $objectSlug);
152152
$meta->getReflectionProperty($config['slug'])->setValue($object, $objectSlug);

0 commit comments

Comments
 (0)