mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-06 18:31:05 +00:00
refactor(migrations): replace 191 value with more relevant one
This commit is contained in:
parent
a9989d841a
commit
057559183c
@ -23,7 +23,7 @@ if (! function_exists('get_browser_language')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! function_exists('slugify')) {
|
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
|
// trim text to the nearest whole word if too long
|
||||||
if (strlen($text) > $maxLength) {
|
if (strlen($text) > $maxLength) {
|
||||||
|
@ -108,7 +108,7 @@ class EpisodeModel extends Model
|
|||||||
protected $validationRules = [
|
protected $validationRules = [
|
||||||
'podcast_id' => 'required',
|
'podcast_id' => 'required',
|
||||||
'title' => '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',
|
'audio_id' => 'required',
|
||||||
'description_markdown' => 'required',
|
'description_markdown' => 'required',
|
||||||
'number' => 'is_natural_no_zero|permit_empty',
|
'number' => 'is_natural_no_zero|permit_empty',
|
||||||
|
@ -51,7 +51,7 @@ class PageModel extends Model
|
|||||||
protected $validationRules = [
|
protected $validationRules = [
|
||||||
'title' => 'required',
|
'title' => 'required',
|
||||||
'slug' =>
|
'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',
|
'content_markdown' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ class PodcastImportController extends BaseController
|
|||||||
$textToSlugify = $this->request->getPost('slug_field') === 'title'
|
$textToSlugify = $this->request->getPost('slug_field') === 'title'
|
||||||
? (string) $item->title
|
? (string) $item->title
|
||||||
: basename((string) $item->link);
|
: basename((string) $item->link);
|
||||||
$slug = slugify($textToSlugify, 185);
|
$slug = slugify($textToSlugify, 120);
|
||||||
if (in_array($slug, $slugs, true)) {
|
if (in_array($slug, $slugs, true)) {
|
||||||
$slugNumber = 2;
|
$slugNumber = 2;
|
||||||
while (in_array($slug . '-' . $slugNumber, $slugs, true)) {
|
while (in_array($slug . '-' . $slugNumber, $slugs, true)) {
|
||||||
|
@ -28,7 +28,7 @@ class AddAnalyticsWebsiteByBrowser extends Migration
|
|||||||
],
|
],
|
||||||
'browser' => [
|
'browser' => [
|
||||||
'type' => 'VARCHAR',
|
'type' => 'VARCHAR',
|
||||||
'constraint' => 191,
|
'constraint' => 128,
|
||||||
],
|
],
|
||||||
'hits' => [
|
'hits' => [
|
||||||
'type' => 'INT',
|
'type' => 'INT',
|
||||||
|
@ -26,7 +26,7 @@ class AddAnalyticsUnknownUseragents extends Migration
|
|||||||
],
|
],
|
||||||
'useragent' => [
|
'useragent' => [
|
||||||
'type' => 'VARCHAR',
|
'type' => 'VARCHAR',
|
||||||
'constraint' => 191,
|
'constraint' => 255,
|
||||||
'unique' => true,
|
'unique' => true,
|
||||||
],
|
],
|
||||||
'hits' => [
|
'hits' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user