You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using nocache database driver and accessing urls that are longer than the max length of the column it throws a 500 error for that page. This happend to advertisement links, where Meta/Google adds a lot of parameters to the url, causing it to exceed the varchar limit.
Only changing the column type to text was not possible due to the existing index on url. We have fixed this issue temporarily by creating a migration like this:
<?phpuseIlluminate\Database\Migrations\Migration;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Support\Facades\DB;
useIlluminate\Support\Facades\Schema;
returnnewclassextendsMigration
{
publicfunctionup()
{
// Drop index firstSchema::table('nocache_regions', function (Blueprint$table) {
$table->dropIndex('nocache_regions_url_index');
});
// Change column typeSchema::table('nocache_regions', function (Blueprint$table) {
$table->text('url')->change();
});
// Add index with length using raw SQLDB::statement('ALTER TABLE nocache_regions ADD INDEX nocache_regions_url_index (url(255))');
}
publicfunctiondown()
{
// Remove indexDB::statement('ALTER TABLE nocache_regions DROP INDEX nocache_regions_url_index');
// Change column back to varcharSchema::table('nocache_regions', function (Blueprint$table) {
$table->string('url', 255)->change();
});
// Recreate original indexSchema::table('nocache_regions', function (Blueprint$table) {
$table->index('url', 'nocache_regions_url_index');
});
}
};
How to reproduce
Set up half static caching
Use nocache tags on a page
Make use of nocache database driver
Visit a page with long url (for example with a lot of parameters)
See error 500 showing up as below:
Logs
SQLSTATE: String data, right truncated: 1406 Data too long for column 'url' at row 1 (Connection: mysql, SQL: insert into `nocache_regions` (`key`, `url`, `region`, `updated_at`, `created_at`)
Bug description
When using nocache database driver and accessing urls that are longer than the max length of the column it throws a 500 error for that page. This happend to advertisement links, where Meta/Google adds a lot of parameters to the url, causing it to exceed the
varchar
limit.Only changing the column type to
text
was not possible due to the existing index onurl
. We have fixed this issue temporarily by creating a migration like this:How to reproduce
Logs
Environment
Installation
Starter Kit using via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: