Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelogs/v4.7.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Release Date: Unreleased
- **Database:** Fixed a bug where `SQLite3\Connection::_foreignKeyData()` did not escape table identifiers in `PRAGMA foreign_key_list`, causing syntax errors on table names containing hyphens or schemas.
- **Database:** Fixed a bug where `SQLite3\Table::dropIndexes()` used single-quoted string literals instead of escaped identifiers in `DROP INDEX IF EXISTS`, causing syntax errors on index names containing quotes or special characters.
- **Helpers:** Fixed a bug where `excerpt()` threw a `TypeError` when `$phrase` was not found in `$text` or when `$phrase` was `null` and `$radius` was an odd integer. When `$phrase` is not found, `excerpt()` now falls back to extracting an excerpt from the beginning of `$text`.
- **Helpers:** Fixed a bug in `plural()` where the regex for `matrix`, `vertex`, and `index` lacked non-capturing grouping and an end-of-string anchor for the `ix` alternative, causing incorrect pluralization of words like `complex`, `sex`, and strings containing `matrix` before the end. Expanded `plural()` and `singular()` to support additional words ending in `ix` or `ex` (`apex`, `appendix`, `codex`, `cortex`, `latex`, `murex`, `vortex`).
- **Helpers:** Fixed bugs in `ArrayHelper::dotKeyExists()` where `'0'` path segments caused early loop termination, non-array intermediate values threw a `TypeError`, and paths with segments after a wildcard failed when the wildcard matched multiple elements.
- **Helpers:** Fixed escaping of attribute values in HTML media helpers to prevent malformed HTML and attribute injection.
- **HTTP:** Fixed a bug where query-string based routing truncated additional query parameters in `SiteURIFactory::parseRequestURI()` due to incorrect array index access.
Expand Down
44 changes: 22 additions & 22 deletions system/Helpers/inflector_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function singular(string $string): string

// Arranged in order.
$singularRules = [
'/(matr)ices$/' => '\1ix',
'/(vert|ind)ices$/' => '\1ex',
'/(matr|append)ices$/' => '\1ix',
'/(vert|ind|vort|cort|cod|lat|mur|ap)ices$/' => '\1ex',
'/^(ox)en/' => '\1',
'/(alias)es$/' => '\1',
'/([octop|vir])i$/' => '\1us',
Expand Down Expand Up @@ -89,26 +89,26 @@ function plural(string $string): string
}

$pluralRules = [
'/(quiz)$/' => '\1zes', // quizzes
'/^(ox)$/' => '\1\2en', // ox
'/([m|l])ouse$/' => '\1ice', // mouse, louse
'/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
'/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
'/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
'/(hive)$/' => '\1s', // archive, hive
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
'/sis$/' => 'ses', // basis, diagnosis
'/([ti])um$/' => '\1a', // datum, medium
'/(p)erson$/' => '\1eople', // person, salesperson
'/(m)an$/' => '\1en', // man, woman, spokesman
'/(c)hild$/' => '\1hildren', // child
'/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
'/(bu|campu)s$/' => '\1\2ses', // bus, campus
'/(alias|status|virus)$/' => '\1es', // alias
'/(octop)us$/' => '\1i', // octopus
'/(ax|cris|test)is$/' => '\1es', // axis, crisis
'/s$/' => 's', // no change (compatibility)
'/$/' => 's',
'/(quiz)$/' => '\1zes', // quizzes
'/^(ox)$/' => '\1\2en', // ox
'/([m|l])ouse$/' => '\1ice', // mouse, louse
'/(matr|vert|ind|vort|append|cort|cod|lat|mur|ap)(?:ix|ex)$/' => '\1ices', // matrix, vertex, index, vortex, appendix, cortex, codex, latex, murex, apex
'/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
'/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
'/(hive)$/' => '\1s', // archive, hive
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
'/sis$/' => 'ses', // basis, diagnosis
'/([ti])um$/' => '\1a', // datum, medium
'/(p)erson$/' => '\1eople', // person, salesperson
'/(m)an$/' => '\1en', // man, woman, spokesman
'/(c)hild$/' => '\1hildren', // child
'/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
'/(bu|campu)s$/' => '\1\2ses', // bus, campus
'/(alias|status|virus)$/' => '\1es', // alias
'/(octop)us$/' => '\1i', // octopus
'/(ax|cris|test)is$/' => '\1es', // axis, crisis
'/s$/' => 's', // no change (compatibility)
'/$/' => 's',
];

foreach ($pluralRules as $rule => $replacement) {
Expand Down
129 changes: 78 additions & 51 deletions tests/system/Helpers/InflectorHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,45 @@ protected function setUp(): void
public function testSingular(): void
{
$strings = [
'matrices' => 'matrix',
'oxen' => 'ox',
'aliases' => 'alias',
'octupus' => 'octupus',
'shoes' => 'shoe',
'buses' => 'bus',
'campus' => 'campus',
'campuses' => 'campus',
'mice' => 'mouse',
'movies' => 'movie',
'series' => 'series',
'hives' => 'hive',
'lives' => 'life',
'analyses' => 'analysis',
'men' => 'man',
'people' => 'person',
'children' => 'child',
'statuses' => 'status',
'news' => 'news',
'us' => 'us',
'tests' => 'test',
'queries' => 'query',
'dogs' => 'dog',
'cats' => 'cat',
'families' => 'family',
'countries' => 'country',
'matrices' => 'matrix',
'vertices' => 'vertex',
'indices' => 'index',
'apices' => 'apex',
'appendices' => 'appendix',
'codices' => 'codex',
'cortices' => 'cortex',
'latices' => 'latex',
'murices' => 'murex',
'vortices' => 'vortex',
'complexes' => 'complex',
'sexes' => 'sex',
'annexes' => 'annex',
'duplexes' => 'duplex',
'oxen' => 'ox',
'aliases' => 'alias',
'octupus' => 'octupus',
'shoes' => 'shoe',
'buses' => 'bus',
'campus' => 'campus',
'campuses' => 'campus',
'mice' => 'mouse',
'movies' => 'movie',
'series' => 'series',
'hives' => 'hive',
'lives' => 'life',
'analyses' => 'analysis',
'men' => 'man',
'people' => 'person',
'children' => 'child',
'statuses' => 'status',
'news' => 'news',
'us' => 'us',
'tests' => 'test',
'queries' => 'query',
'dogs' => 'dog',
'cats' => 'cat',
'families' => 'family',
'countries' => 'country',
];

foreach ($strings as $pluralizedString => $singularizedString) {
Expand All @@ -70,31 +83,45 @@ public function testSingular(): void
public function testPlural(): void
{
$strings = [
'searches' => 'search',
'matrices' => 'matrix',
'oxen' => 'ox',
'aliases' => 'alias',
'octupus' => 'octupus',
'shoes' => 'shoe',
'buses' => 'bus',
'mice' => 'mouse',
'movies' => 'movie',
'series' => 'series',
'hives' => 'hive',
'lives' => 'life',
'analyses' => 'analysis',
'men' => 'man',
'people' => 'person',
'children' => 'child',
'statuses' => 'status',
'news' => 'news',
'us' => 'us',
'tests' => 'test',
'queries' => 'query',
'dogs' => 'dog',
'cats' => 'cat',
'families' => 'family',
'countries' => 'country',
'searches' => 'search',
'matrices' => 'matrix',
'vertices' => 'vertex',
'indices' => 'index',
'apices' => 'apex',
'appendices' => 'appendix',
'codices' => 'codex',
'cortices' => 'cortex',
'latices' => 'latex',
'murices' => 'murex',
'vortices' => 'vortex',
'complexes' => 'complex',
'sexes' => 'sex',
'annexes' => 'annex',
'duplexes' => 'duplex',
'matrix_ids' => 'matrix_id',
'oxen' => 'ox',
'aliases' => 'alias',
'octupus' => 'octupus',
'shoes' => 'shoe',
'buses' => 'bus',
'mice' => 'mouse',
'movies' => 'movie',
'series' => 'series',
'hives' => 'hive',
'lives' => 'life',
'analyses' => 'analysis',
'men' => 'man',
'people' => 'person',
'children' => 'child',
'statuses' => 'status',
'news' => 'news',
'us' => 'us',
'tests' => 'test',
'queries' => 'query',
'dogs' => 'dog',
'cats' => 'cat',
'families' => 'family',
'countries' => 'country',
];

foreach ($strings as $pluralizedString => $singularizedString) {
Expand Down
Loading