refactor(migrations): replace 191 value with more relevant one

This commit is contained in:
Yassine Doghri 2021-12-21 14:15:10 +00:00
parent a9989d841a
commit 057559183c
6 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ if (! function_exists('get_browser_language')) {
}
if (! function_exists('slugify')) {
function slugify(string $text, int $maxLength = 191): string
function slugify(string $text, int $maxLength = 128): string
{
// trim text to the nearest whole word if too long
if (strlen($text) > $maxLength) {

View File

@ -108,7 +108,7 @@ class EpisodeModel extends Model
protected $validationRules = [
'podcast_id' => 'required',
'title' => 'required',
'slug' => 'required|regex_match[/^[a-zA-Z0-9\-]{1,191}$/]',
'slug' => 'required|regex_match[/^[a-zA-Z0-9\-]{1,128}$/]',
'audio_id' => 'required',
'description_markdown' => 'required',
'number' => 'is_natural_no_zero|permit_empty',

View File

@ -51,7 +51,7 @@ class PageModel extends Model
protected $validationRules = [
'title' => 'required',
'slug' =>
'required|regex_match[/^[a-zA-Z0-9\-]{1,191}$/]|is_unique[pages.slug,id,{id}]',
'required|regex_match[/^[a-zA-Z0-9\-]{1,128}$/]|is_unique[pages.slug,id,{id}]',
'content_markdown' => 'required',
];

View File

@ -306,7 +306,7 @@ class PodcastImportController extends BaseController
$textToSlugify = $this->request->getPost('slug_field') === 'title'
? (string) $item->title
: basename((string) $item->link);
$slug = slugify($textToSlugify, 185);
$slug = slugify($textToSlugify, 120);
if (in_array($slug, $slugs, true)) {
$slugNumber = 2;
while (in_array($slug . '-' . $slugNumber, $slugs, true)) {

View File

@ -28,7 +28,7 @@ class AddAnalyticsWebsiteByBrowser extends Migration
],
'browser' => [
'type' => 'VARCHAR',
'constraint' => 191,
'constraint' => 128,
],
'hits' => [
'type' => 'INT',

View File

@ -26,7 +26,7 @@ class AddAnalyticsUnknownUseragents extends Migration
],
'useragent' => [
'type' => 'VARCHAR',
'constraint' => 191,
'constraint' => 255,
'unique' => true,
],
'hits' => [