Issue #2889438 by chr.fritsch, seanB, marcoscano, Wim Leers, rogerpfaff, phenaproxima, larowlan: Delete media delivered icons on uninstall
parent
337963d193
commit
e018da5082
|
|
@ -17,8 +17,16 @@ function media_install() {
|
||||||
|
|
||||||
$files = file_scan_directory($source, '/.*\.(svg|png|jpg|jpeg|gif)$/');
|
$files = file_scan_directory($source, '/.*\.(svg|png|jpg|jpeg|gif)$/');
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
// When reinstalling the media module we don't want to copy the icons when
|
||||||
|
// they already exist. The icons could be replaced (by a contrib module or
|
||||||
|
// manually), so we don't want to replace the existing files. Removing the
|
||||||
|
// files when we uninstall could also be a problem if the files are
|
||||||
|
// referenced somewhere else. Since showing an error that it was not
|
||||||
|
// possible to copy the files is also confusing, we silently do nothing.
|
||||||
|
if (!file_exists($destination . DIRECTORY_SEPARATOR . $file->filename)) {
|
||||||
file_unmanaged_copy($file->uri, $destination, FILE_EXISTS_ERROR);
|
file_unmanaged_copy($file->uri, $destination, FILE_EXISTS_ERROR);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Grant the "view media" permission to all users by default.
|
// Grant the "view media" permission to all users by default.
|
||||||
if (\Drupal::moduleHandler()->moduleExists('user')) {
|
if (\Drupal::moduleHandler()->moduleExists('user')) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\media\Functional;
|
||||||
|
|
||||||
|
use Drupal\Tests\BrowserTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests media Install / Uninstall logic.
|
||||||
|
*
|
||||||
|
* @group media
|
||||||
|
*/
|
||||||
|
class MediaInstallTest extends BrowserTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = ['media'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->drupalLogin($this->drupalCreateUser(['administer modules']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests reinstalling after being uninstalled.
|
||||||
|
*/
|
||||||
|
public function testReinstallAfterUninstall() {
|
||||||
|
$page = $this->getSession()->getPage();
|
||||||
|
$this->container->get('module_installer')->uninstall(['media'], FALSE);
|
||||||
|
$this->drupalGet('/admin/modules');
|
||||||
|
$page->checkField('modules[media][enable]');
|
||||||
|
$page->pressButton('Install');
|
||||||
|
// @todo Remove this if-statement in https://www.drupal.org/node/2895059
|
||||||
|
if ($page->find('css', 'h1')->getText() == 'Are you sure you wish to enable experimental modules?') {
|
||||||
|
$page->pressButton('Continue');
|
||||||
|
}
|
||||||
|
$this->assertSession()->pageTextNotContains('could not be moved/copied because a file by that name already exists in the destination directory');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue