Skip to content

Commit

Permalink
Merge branch '4.x' into bugfix/16227-apply-field-save-old-and-new-set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
brandonkelly committed Dec 1, 2024
2 parents 5651287 + 718173a commit f254fd3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased

- Fixed an error that could occur when duplicating an element with an Assets field that had a dynamic subpath. ([#16214](https://github.com/craftcms/cms/issues/16214))
- Reduced the likelihood of a deadlock error occurring when updating search indexes. ([#15221](https://github.com/craftcms/cms/issues/15221))
- Fixed a bug where renaming asset folders could move them to the webroot on Windows. ([#16215](https://github.com/craftcms/cms/issues/16215))

## 4.13.3 - 2024-11-22

Expand Down
12 changes: 7 additions & 5 deletions src/fs/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,18 @@ public function deleteDirectory(string $path): void
*/
public function renameDirectory(string $path, string $newName): void
{
if (!is_dir($this->prefixPath($path))) {
$fullPath = $this->prefixPath($path);

if (!is_dir($fullPath)) {
throw new FsObjectNotFoundException('No folder exists at path: ' . $path);
}

$components = explode("/", $this->prefixPath($path));
$components = explode(DIRECTORY_SEPARATOR, $fullPath);
array_pop($components);
$components[] = $newName;
$newPath = implode("/", $components);
$newPath = implode(DIRECTORY_SEPARATOR, $components);

@rename($this->prefixPath($path), $newPath);
@rename($fullPath, $newPath);
}

/**
Expand Down Expand Up @@ -413,7 +415,7 @@ protected function prefixPath(string $path = ''): string
throw new FsException("The path `$path` is not contained.");
}

return $this->getRootPath() . DIRECTORY_SEPARATOR . $path;
return $this->getRootPath() . DIRECTORY_SEPARATOR . FileHelper::normalizePath($path);
}

/**
Expand Down
16 changes: 15 additions & 1 deletion src/services/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use craft\search\SearchQueryTermGroup;
use Throwable;
use yii\base\Component;
use yii\db\Exception;
use yii\db\Expression;
use yii\db\Schema;

Expand Down Expand Up @@ -483,7 +484,20 @@ private function _indexKeywords(ElementInterface $element, string $keywords, ?st
}

// Insert/update the row in searchindex
Db::insert(Table::SEARCHINDEX, $columns);
for ($try = 0; $try < 3; $try++) {
try {
Db::insert(Table::SEARCHINDEX, $columns);
return;
} catch (Exception $e) {
if (str_contains($e->getPrevious()?->getMessage(), 'deadlock')) {
// A gap lock was probably hit. Try again in one second
// https://github.com/craftcms/cms/issues/15221
sleep(1);
} else {
throw $e;
}
}
}
}

/**
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/helpers/DateTimeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,6 @@ public function isInvalidIntervalStringDataProvider(): array
[true, '1 year'],
[true, '1 month'],
[true, '1 minutes'],

[false, ''],
[false, 'random string'],

];
}

Expand Down

0 comments on commit f254fd3

Please sign in to comment.