Commit fc12fcc7 authored by larowlan's avatar larowlan

Merged 8.8.1.

parents 93335fc8 db022d57
......@@ -653,7 +653,7 @@
"dist": {
"type": "path",
"url": "core",
"reference": "6b3cd6ac644f517213b17a9b359b0c9071b8a69e"
"reference": "2efa7c2f31a06cd72276875e68d39df692ed0d62"
},
"require": {
"asm89/stack-cors": "^1.1",
......@@ -677,7 +677,7 @@
"ext-xml": "*",
"guzzlehttp/guzzle": "^6.3",
"masterminds/html5": "^2.1",
"pear/archive_tar": "^1.4.8",
"pear/archive_tar": "^1.4.9",
"php": ">=7.0.8",
"stack/builder": "^1.0",
"symfony-cmf/routing": "^1.4",
......@@ -1356,16 +1356,16 @@
},
{
"name": "pear/archive_tar",
"version": "1.4.8",
"version": "1.4.9",
"source": {
"type": "git",
"url": "https://github.com/pear/Archive_Tar.git",
"reference": "442bdffb7edb84c898cfd94f7ac8500e49d5bbb5"
"reference": "c5b00053770e1d72128252c62c2c1a12c26639f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/442bdffb7edb84c898cfd94f7ac8500e49d5bbb5",
"reference": "442bdffb7edb84c898cfd94f7ac8500e49d5bbb5",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/c5b00053770e1d72128252c62c2c1a12c26639f0",
"reference": "c5b00053770e1d72128252c62c2c1a12c26639f0",
"shasum": ""
},
"require": {
......@@ -1418,7 +1418,7 @@
"archive",
"tar"
],
"time": "2019-10-21T13:31:24+00:00"
"time": "2019-12-04T10:17:28+00:00"
},
{
"name": "pear/console_getopt",
......
......@@ -24,7 +24,7 @@
"guzzlehttp/psr7": "1.6.1",
"masterminds/html5": "2.3.0",
"paragonie/random_compat": "v9.99.99",
"pear/archive_tar": "1.4.8",
"pear/archive_tar": "1.4.9",
"pear/console_getopt": "v1.4.2",
"pear/pear-core-minimal": "v1.10.9",
"pear/pear_exception": "v1.0.0",
......
......@@ -46,7 +46,7 @@
"zendframework/zend-diactoros": "^1.8",
"composer/semver": "^1.0",
"asm89/stack-cors": "^1.1",
"pear/archive_tar": "^1.4.8"
"pear/archive_tar": "^1.4.9"
},
"conflict": {
"drupal/pathauto": "<1.6",
......
......@@ -425,10 +425,9 @@ function install_begin_request($class_loader, &$install_state) {
}
$GLOBALS['conf']['container_service_providers']['InstallerConfigOverride'] = 'Drupal\Core\Installer\ConfigOverride';
// Only allow dumping the container once the hash salt has been created. Note,
// InstallerKernel::createFromRequest() is not used because Settings is
// Note, InstallerKernel::createFromRequest() is not used because Settings is
// already initialized.
$kernel = new InstallerKernel($environment, $class_loader, (bool) Settings::get('hash_salt', FALSE));
$kernel = new InstallerKernel($environment, $class_loader, FALSE);
$kernel::bootEnvironment();
$kernel->setSitePath($site_path);
$kernel->boot();
......
......@@ -54,10 +54,10 @@ public function remove($file_path) {
*/
public function extract($path, array $files = []) {
if ($files) {
$this->tar->extractList($files, $path);
$this->tar->extractList($files, $path, '', FALSE, FALSE);
}
else {
$this->tar->extract($path);
$this->tar->extract($path, FALSE, FALSE);
}
return $this;
......
......@@ -15,6 +15,8 @@ class InstallerKernel extends DrupalKernel {
protected function initializeContainer() {
// Always force a container rebuild.
$this->containerNeedsRebuild = TRUE;
// Ensure the InstallerKernel's container is not dumped.
$this->allowDumping = FALSE;
$container = parent::initializeContainer();
return $container;
}
......
......@@ -131,7 +131,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($archiver->listContent() as $file) {
$files[] = $file['filename'];
}
$archiver->extractList($files, $this->settings->get('config_sync_directory'));
$archiver->extractList($files, $this->settings->get('config_sync_directory'), '', FALSE, FALSE);
$this->messenger()->addStatus($this->t('Your configuration files were successfully uploaded and are ready for import.'));
$form_state->setRedirect('config.sync');
}
......
......@@ -992,7 +992,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
$values = [
'uid' => $user->id(),
'status' => 0,
'filename' => $file_info->getClientOriginalName(),
'filename' => trim($file_info->getClientOriginalName(), '.'),
'uri' => $file_info->getRealPath(),
'filesize' => $file_info->getSize(),
];
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\file\Functional;
use Drupal\file\Entity\File;
/**
* Tests the 'managed_file' element type.
*
......@@ -156,6 +158,21 @@ public function testManagedFileRemoved() {
$this->assertRaw('The file referenced by the Managed <em>file &amp; butter</em> field does not exist.');
}
/**
* Tests file names have leading . removed.
*/
public function testFileNameTrim() {
file_put_contents('public://.leading-period.txt', $this->randomString(32));
$last_fid_prior = $this->getLastFileId();
$this->drupalPostForm('file/test/0/0/0', [
'files[file]' => \Drupal::service('file_system')->realpath('public://.leading-period.txt'),
], t('Save'));
$next_fid = $this->getLastFileId();
$this->assertGreaterThan($last_fid_prior, $next_fid);
$file = File::load($next_fid);
$this->assertEquals('leading-period.txt', $file->getFilename());
}
/**
* Ensure a file entity can be saved when the file does not exist on disk.
*/
......
......@@ -510,7 +510,12 @@ protected function processInputValues(array $source_field_values, array $form, F
$form_state->set('media', array_values($media));
// Save the selected items in the form state so they are remembered when an
// item is removed.
$form_state->set('current_selection', array_filter(explode(',', $form_state->getValue('current_selection'))));
$media = $this->entityTypeManager->getStorage('media')
->loadMultiple(explode(',', $form_state->getValue('current_selection')));
// Any ID can be passed to the form, so we have to check access.
$form_state->set('current_selection', array_filter($media, function ($media_item) {
return $media_item->access('view');
}));
$form_state->setRebuild();
}
......@@ -806,13 +811,9 @@ protected function getSourceFieldName(MediaTypeInterface $media_type) {
* An array containing the pre-selected media items keyed by ID.
*/
protected function getPreSelectedMediaItems(FormStateInterface $form_state) {
// Get the current selection from the form state.
// Get the pre-selected media items from the form state.
// @see ::processInputValues()
$media_ids = $form_state->get('current_selection');
if (!$media_ids) {
return [];
}
return $this->entityTypeManager->getStorage('media')->loadMultiple($media_ids);
return $form_state->get('current_selection') ?: [];
}
/**
......@@ -823,7 +824,7 @@ protected function getPreSelectedMediaItems(FormStateInterface $form_state) {
*
* @return \Drupal\media\MediaInterface[]
* An array containing the added media items keyed by delta. The media items
* won't have an ID untill they are saved in ::submitForm().
* won't have an ID until they are saved in ::submitForm().
*/
protected function getAddedMediaItems(FormStateInterface $form_state) {
return $form_state->get('media') ?: [];
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\media_library\FunctionalJavascript;
use Drupal\media\Entity\Media;
use Drupal\media_library\MediaLibraryState;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
......@@ -18,6 +19,35 @@ class WidgetAccessTest extends MediaLibraryTestBase {
*/
public function testWidgetAccess() {
$assert_session = $this->assertSession();
$session = $this->getSession();
$this->createMediaItems([
'type_one' => ['Horse', 'Bear'],
]);
$account = $this->drupalCreateUser(['create basic_page content']);
$this->drupalLogin($account);
// Assert users can not select media items they do not have access to.
$unpublished_media = Media::create([
'name' => 'Mosquito',
'bundle' => 'type_one',
'field_media_test' => 'Mosquito',
'status' => FALSE,
]);
$unpublished_media->save();
// Visit a node create page.
$this->drupalGet('node/add/basic_page');
// Set the hidden value and trigger the mousedown event on the button via
// JavaScript since the field and button are hidden.
$session->executeScript("jQuery('[data-media-library-widget-value=\"field_unlimited_media\"]').val('1,2,{$unpublished_media->id()}')");
$session->executeScript("jQuery('[data-media-library-widget-update=\"field_unlimited_media\"]').trigger('mousedown')");
$this->assertElementExistsAfterWait('css', '.js-media-library-item');
// Assert the published items are selected and the unpublished item is not
// selected.
$assert_session->pageTextContains('Horse');
$assert_session->pageTextContains('Bear');
$assert_session->pageTextNotContains('Mosquito');
$this->drupalLogout();
$role = Role::load(RoleInterface::ANONYMOUS_ID);
$role->revokePermission('view media');
......
......@@ -568,6 +568,29 @@ public function testWidgetUploadAdvancedUi() {
$this->pressInsertSelected('Added one media item.');
$assert_session->pageTextContains($file_system->basename($jpg_uri_2));
// Assert users can not select media items they do not have access to.
$unpublished_media = Media::create([
'name' => 'Mosquito',
'bundle' => 'type_one',
'field_media_test' => 'Mosquito',
'status' => FALSE,
]);
$unpublished_media->save();
$this->openMediaLibraryForField('field_unlimited_media');
$this->switchToMediaType('Three');
// Set the hidden field with the current selection via JavaScript and upload
// a file.
$this->getSession()->executeScript("jQuery('.js-media-library-add-form-current-selection').val('1,2,{$unpublished_media->id()}')");
$this->addMediaFileToField('Add files', $this->container->get('file_system')->realpath($png_uri_3));
// Assert the pre-selected items are shown.
$this->getSelectionArea();
// Assert the published items are selected and the unpublished item is not
// selected.
$this->waitForText(Media::load(1)->label());
$this->waitForText(Media::load(2)->label());
$assert_session->pageTextNotContains('Mosquito');
$page->find('css', '.ui-dialog-titlebar-close')->click();
// Assert we can also remove selected items from the selection area in the
// upload form.
$this->openMediaLibraryForField('field_unlimited_media');
......
......@@ -406,4 +406,12 @@ public static function trustedCallbacks() {
return ['preRenderCacheTags'];
}
/**
* Use a plain Symfony response object to output the current install_profile.
*/
public function getInstallProfile() {
$install_profile = \Drupal::installProfile() ?: 'NONE';
return new Response('install_profile: ' . $install_profile);
}
}
......@@ -204,3 +204,10 @@ system_test.custom_cache_control:
_controller: '\Drupal\system_test\Controller\SystemTestController::getCacheableResponseWithCustomCacheControl'
requirements:
_access: 'TRUE'
system_test.install_profile:
path: '/system-test/get-install-profile'
defaults:
_controller: '\Drupal\system_test\Controller\SystemTestController::getInstallProfile'
requirements:
_access: 'TRUE'
<?php
namespace Drupal\FunctionalTests\Installer;
/**
* Tests re-visiting the installer after a successful installation.
*
* @group Installer
*/
class InstallerPostInstallTest extends InstallerTestBase {
/**
* {@inheritdoc}
*/
protected $profile = 'minimal';
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Confirms that visiting the installer does not break things post-install.
*/
public function testVisitInstallerPostInstall() {
\Drupal::service('module_installer')->install(['system_test']);
// Clear caches to ensure that system_test's routes are available.
$this->resetAll();
// Confirm that the install_profile is correct.
$this->drupalGet('/system-test/get-install-profile');
$this->assertText('minimal');
// Make an anonymous visit to the installer
$this->drupalLogout();
$this->visitInstaller();
// Ensure that the install profile is still correct.
$this->drupalGet('/system-test/get-install-profile');
$this->assertText('minimal');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment