Skip to content
Snippets Groups Projects
Commit d8654de0 authored by Ted Bowman's avatar Ted Bowman Committed by Adam G-H
Browse files

Issue #3358570 by phenaproxima: InstalledPackage::scanForProjectName() can...

Issue #3358570 by phenaproxima: InstalledPackage::scanForProjectName() can cause PHP notices if the `project` key is not in the info file
parent 1488d68c
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,7 @@ final class InstalledPackage {
$info = file_get_contents($match[0]);
$info = Yaml::decode($info);
if (is_string($info['project']) && !empty($info['project'])) {
if (!empty($info['project'])) {
return $info['project'];
}
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\package_manager\Kernel;
use Drupal\Component\Serialization\Yaml;
use Drupal\fixture_manipulator\ActiveFixtureManipulator;
use Drupal\package_manager\InstalledPackage;
use Drupal\package_manager\InstalledPackagesList;
......@@ -121,6 +122,25 @@ class InstalledPackagesListTest extends PackageManagerKernelTestBase {
$this->assertNull($list->getPackageByDrupalProjectName('custom_module'));
$this->assertNull($list->getPackageByDrupalProjectName('custom_theme'));
// The `project` key has been removed from the info file.
(new ActiveFixtureManipulator())
->addProjectAtPath('projects/no_project_key')
->commitChanges();
$list = new InstalledPackagesList([
'drupal/no_project_key' => InstalledPackage::createFromArray([
'name' => 'drupal/no_project_key',
'version' => '1.0.0',
'type' => 'drupal-module',
'path' => $projects_path . '/no_project_key',
]),
]);
$info_file = $list['drupal/no_project_key']->path . '/no_project_key.info.yml';
$this->assertFileIsWritable($info_file);
$info = Yaml::decode(file_get_contents($info_file));
unset($info['project']);
file_put_contents($info_file, Yaml::encode($info));
$this->assertNull($list->getPackageByDrupalProjectName('no_project_key'));
// The project name is repeated.
(new ActiveFixtureManipulator())
->addProjectAtPath('projects/duplicate_project')
......
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