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

[2.2-dev] Move functions.php into Framework #16800

Merged
merged 1 commit into from
Sep 6, 2018

Conversation

fooman
Copy link
Contributor

@fooman fooman commented Jul 14, 2018

See discussion and comments in #16705 - this is a pull request for 2.2

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @fooman. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@fooman fooman mentioned this pull request Jul 14, 2018
4 tasks
@orlangur orlangur self-assigned this Jul 15, 2018
@fooman
Copy link
Contributor Author

fooman commented Jul 18, 2018

Updated the PR to fix the noted short name violation of __.php (squashed into 1 commit)

*
* @return \Magento\Framework\Phrase
*/
function __()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't idea to put this function in Magento/Framework/Phrase/ - \Magento\Framework\Phrase namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that was proposed so far. Wouldn't namespacing the function mean all existing templates would need to be adjusted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wait @orlangur for review

@fooman
Copy link
Contributor Author

fooman commented Jul 23, 2018

@orlangur any thing else to do here before it can be merged?

@fooman
Copy link
Contributor Author

fooman commented Aug 6, 2018

@orlangur or @ihor-sviziev anything else needed here?

@orlangur
Copy link
Contributor

orlangur commented Aug 6, 2018

@fooman sorry for delay, started review almost immediately but didn't finish it. Will do now.

@@ -0,0 +1,22 @@
<?php
Copy link
Contributor

Choose a reason for hiding this comment

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

Which rule was violated by __.php name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was actually the function name itself __() which triggered the violation. As this was previously not occurring I assumed it was related to the file name. It turned out that wasn't the case and that __() was always in violation but making the changes brought this up.

If you have a strong preference I can change the filename __function.php back to __.php.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please do so.

@@ -0,0 +1,4 @@
<?php
if (!function_exists('__')) {
require '__function.php';
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use for such registration file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main idea of splitting this out is the following:

The standard way of installing Magento 2 should be through Composer. In this case you will get the __function.php included directly through the Composer autoloader - no further requires needed. Also this registration file would not be loaded.

Only if you clone from Github app/etc/NonComposerComponentRegistration.php will kick in and find this registration file which in turn will require __function.php.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur we could mark this file deprecated as well as it should get removed at the same time as app/functions.php

Copy link
Contributor

Choose a reason for hiding this comment

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

Such file is a bit confusing, please just include __.php in registration.php of Magento Framework.

@@ -45,7 +45,8 @@
"Magento\\Framework\\": ""
},
"files": [
"registration.php"
"registration.php",
"Phrase/__function.php"
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant to just require __.php in registration of framework.

Copy link
Contributor Author

@fooman fooman Aug 13, 2018

Choose a reason for hiding this comment

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

To me the final goal should be to use Composer to supply autoloaded files. Using registration.php is an intermediate step which we could do without. It also keeps the purpose of the registration file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using registration.php is an intermediate

There is no need to do something differently until we get rid of them.

So, instead of including __.php separately just do it within registration.php.

if (!empty($argc) && is_array($argc[0])) {
$argc = $argc[0];
$vendorDir = require VENDOR_PATH;
if (!function_exists('__')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply move such logic into __.php? It's better to mark app/functions.php as deprecated without any changes.

@fooman
Copy link
Contributor Author

fooman commented Aug 16, 2018

@orlangur okay changed this to how you suggested so that we can get this merged

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

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

@fooman great! Even simpler than I thought it will be 👍

@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-2915 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @fooman. Thank you for your contribution.
We will aim to release these changes as part of 2.2.7.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

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

Successfully merging this pull request may close these issues.

4 participants