Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace direct access to sites with getSites #305

Merged

Conversation

LOBsTerr
Copy link
Member

@LOBsTerr LOBsTerr commented Feb 6, 2018

No description provided.

@nvaken
Copy link
Contributor

nvaken commented Feb 8, 2018

Looking good! As far as I'm concerned, this can be merged!

@@ -119,18 +119,19 @@ public function readTarget($target)
$environment = $exploded[1];
}

if (!array_key_exists($site, $this->sites)) {
$sites = $this->getSites();
Copy link
Member

@jmolivas jmolivas Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LOBsTerr By calling the $this->getSites(); method the this->sites array wiill be filled with sites data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmolivas a proposal by nvaken here hechoendrupal/drupal-console#3761 to have a single point of access to sites property.
Theoretically, the $this->site can be empty, if we didn't call $this->getSite() before in https://github.com/hechoendrupal/drupal-console-core/blob/master/src/Command/Debug/SiteCommand.php#L70

Copy link
Member

@jmolivas jmolivas Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LOBsTerr What I mean is to add the $this->getSites(); above this line:

if (!array_key_exists($site, $this->sites)) {

Then $this->sites will contain data since $this->getSites(); call will add that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what you’re saying is call $this->getSites() without assigning it to $sites and just keep getting data from $this->sites directly? I think assigning it to a local variable (like @LOBsTerr did) is best practice performance wise, isn’t it?

Copy link
Member

@jmolivas jmolivas Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvaken exactly I was trying to say that but is true local scope var is faster than the class one, we can keep this PR as it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go ahead and merge it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!👏👏

@jmolivas jmolivas merged commit 4c7962a into hechoendrupal:master Feb 9, 2018
@jmolivas
Copy link
Member

jmolivas commented Feb 9, 2018

@LOBsTerr Thanks for the PR.

@nvaken Thanks for reporting, suggest the fix and follow the conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants