Skip to content
Snippets Groups Projects
Commit 93ff7b2e authored by catch's avatar catch
Browse files

Issue #3270556 by quietone: Handle NULL for max_filesize_per_file in...

Issue #3270556 by quietone: Handle NULL for max_filesize_per_file in d6\FieldInstanceSettings::convertSizeUnit

(cherry picked from commit 54816afa)
parent 1b8c1e95
No related branches found
No related tags found
23 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment,!3555Issue #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons,!3494Issue #3327018 by Spokje, longwave, xjm, mondrake: Update PHPStan to 1.9.3 and...,!3410Issue #3340128: UserLoginForm::submitForm has some dead code,!3389Issue #3325184 by Spokje, andypost, xjm, smustgrave: $this->configFactory is...,!3381Issue #3332363: Refactor Claro's menus-and-lists stylesheet,!3307Issue #3326193: CKEditor 5 can grow past the viewport when there is a lot of content,!3236Issue #3332419: Refactor Claro's messages stylesheet,!3231Draft: Issue #3049525 by longwave, fougere, larowlan, kim.pepper, AaronBauman, Wim...,!3212Issue #3294003: Refactor Claro's entity-meta stylesheet,!3194Issue #3330981: Fix PHPStan L1 error "Relying on entity queries to check access by default is deprecated...",!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3024Issue #3307509: Empty option for views bulk form,!2972Issue #1845004: Replace custom password hashing library with PHP 5.5 password_hash(),!2719Issue #3110137: Remove Classy from core.,!2688Issue #3261452: [PP-1] Remove tracker module from core,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2296Issue #3100732: Allow specifying `meta` data on JSON:API objects,!1626Issue #3256642: Make life better for database drivers that extend another database driver
......@@ -49,7 +49,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
case 'imagefield_widget':
$settings['file_extensions'] = $widget_settings['file_extensions'];
$settings['file_directory'] = $widget_settings['file_path'];
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file'] ?? '');
$settings['alt_field'] = $widget_settings['alt'];
$settings['alt_field_required'] = $widget_settings['custom_alt'];
$settings['title_field'] = $widget_settings['title'];
......
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d6;
use Drupal\field\Plugin\migrate\process\d6\FieldInstanceSettings;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;
// cspell:ignore imagefield
/**
* @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldInstanceSettings
* @group field
*/
class FieldInstanceSettingsTest extends UnitTestCase {
/**
* @covers ::getSettings
*
* @dataProvider getSettingsProvider
*/
public function testGetSettings($field_type, $instance_settings, $expected) {
$instance_settings = unserialize($instance_settings);
$migration = $this->createMock(MigrationInterface::class);
$plugin = new FieldInstanceSettings([], 'd6_field_field_settings', [], $migration);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();
$result = $plugin->transform([
$field_type,
$instance_settings,
NULL,
], $executable, $row, 'foo');
$this->assertSame($expected, $result);
}
/**
* Provides field settings for testGetSettings().
*/
public function getSettingsProvider() {
return [
'imagefield size set' => [
'imagefield_widget',
'a:14:{s:15:"file_extensions";s:11:"gif jpg png";s:9:"file_path";N;s:18:"progress_indicator";N;s:21:"max_filesize_per_file";s:3:"10M";s:21:"max_filesize_per_node";N;s:14:"max_resolution";N;s:14:"min_resolution";N;s:3:"alt";N;s:10:"custom_alt";i:1;s:5:"title";N;s:12:"custom_title";i:1;s:10:"title_type";N;s:13:"default_image";N;s:17:"use_default_image";N;}',
[
'file_extensions' => 'gif jpg png',
'file_directory' => NULL,
'max_filesize' => '10MB',
'alt_field' => NULL,
'alt_field_required' => 1,
'title_field' => NULL,
'title_field_required' => 1,
'max_resolution' => '',
'min_resolution' => '',
],
],
'imagefield size NULL' => [
'imagefield_widget',
'a:14:{s:15:"file_extensions";s:11:"gif jpg png";s:9:"file_path";N;s:18:"progress_indicator";N;s:21:"max_filesize_per_file";N;s:21:"max_filesize_per_node";N;s:14:"max_resolution";N;s:14:"min_resolution";N;s:3:"alt";N;s:10:"custom_alt";i:1;s:5:"title";N;s:12:"custom_title";i:1;s:10:"title_type";N;s:13:"default_image";N;s:17:"use_default_image";N;}',
[
'file_extensions' => 'gif jpg png',
'file_directory' => NULL,
'max_filesize' => '',
'alt_field' => NULL,
'alt_field_required' => 1,
'title_field' => NULL,
'title_field_required' => 1,
'max_resolution' => '',
'min_resolution' => '',
],
],
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment