Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently we test for empty()
and return the current bundle in FeaturesAssigner::getBundle()
:
public function getBundle($name = NULL) {
if (empty($name)) {
return $this->currentBundle;
}
elseif (isset($this->bundles[$name])) {
return $this->bundles[$name];
}
return NULL;
}
In many places we use an empty string as the ID (machine name) of the default bundle. Example from FeaturesAssigner::findBundle()
:
if (!isset($bundle)) {
// Return the default bundle.
return $this->getBundle('');
}
An empty string $name
argument to ::getBundle(
) will therefore return the current bundle rather than the default one.
Proposed resolution
- Change the
DEFAULTBUNDLE
constant value from'_default_'
to''
so that it matches actual usage. - In
FeaturesAssigner::getBundle()
, test forisset()
oris_null()
rather thanempty()
.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#7 | features-bundle-2615634-7.patch | 893 bytes | nedjo |
|
Comments
Comment #2
dawehnerAdding a related issue: #2569149: Use ConfigEntity for features bundles
Comment #3
dawehnerWhat about using the constant in those places as well (see https://3v4l.org/FMWpe), so that
getBundle
would look like this:Comment #4
nedjoMost of the needed work has been rolled into #2569149: Use ConfigEntity for features bundles.
However, in
FeaturesAssigner::getBundle()
we should still changeto
Comment #5
nedjoThis is now minor cleanup.
Comment #7
nedjoComment #9
nedjo