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

Make it possible to exclude classes (directories) for compilation #986

Merged
merged 4 commits into from
Feb 27, 2015

Conversation

Flyingmana
Copy link
Member

Reason is:
A single module which is working for Magento 1.x and 2.x
the 2.x specific files are not problem for 1.x, but the 1.x specific files will get parsed from the compiler causing two errors.

  1. they are not part of the autoloading, which causes a first error
  2. they extend from classes not existent in 2.x anymore

To prevent this errors this patch allows to specify an ignore pattern with /m1/ as default, so everything a module places in a m1 directory, is not parsed from the compiler anymore.

I will provide documentation after this get merged, not sure about tests yet, but will see later how to add some for it

@vpelipenko
Copy link
Contributor

@Flyingmana, thank you for this contribution. We are going to validate it and make a decision about supporting such cases.

@Flyingmana
Copy link
Member Author

please consider such a case is not avoidable if you want to have modules which are able to run in Magento1 and Magento2

]
);
$opt->parse();

$generationDir = $opt->getOption('generation') ? $opt->getOption('generation') : $rootDir . '/var/generation';
$diDir = $opt->getOption('di') ? $opt->getOption('di') : $rootDir . '/var/di';
$fileExcludePatterns = $opt->getOption('exclude-pattern') ? [$opt->getOption('exclude-pattern')] : ['/\/m1\//'];
Copy link
Contributor

Choose a reason for hiding this comment

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

@Flyingmana
Is "m1" as default exclude pattern Ok?
Does it make sense event specify default? Maybe better to keep it empty?
Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think a default is important, so other module vendors can use this as standard and know their module works without the need of manual action from the users. "/m1/" for this is a simple one, and should not conflict with any other path
I thought about it, but I dont find another solution which would work automatic without bigger changes or a per module config in the compiler.

@vpelipenko
Copy link
Contributor

Builds: green
Ticket: MAGETWO-33598

@vpelipenko
Copy link
Contributor

@Flyingmana, one question about changes as a result of code review. Do you think we really need to process excluded pattern as array? When we run compiler.php we'll get it as string.

@Flyingmana
Copy link
Member Author

@vpelipenko I dont think its important to be an array, but as I did not know how you maybe want to change or extend the behavior, I decided to make it as extensible as possible.
One possible case I thought could happen was, you decide to exclude /m1/ (or what you decide to be the standard) in general, and the cli parameter only adds new exclude patterns, not replacing the default one.

But if it is an array or not doesn't matter for me

@Flyingmana
Copy link
Member Author

Is there anything else I can help with now?

@vpelipenko
Copy link
Contributor

This PR has some conflicts with our internal code, due to last improvements in code compilation tools, and can be accepted as is. Let's wait for the next public update where these changes will become live. Definitely you will need to do some changes in this PR after that.

@Flyingmana
Copy link
Member Author

have rebased the PR, tested locally and Travis is still green.
If there is something else to do, or you have another questions, Iam here :)

@vpelipenko
Copy link
Contributor

@Flyingmana, our internal improvements in code compilation tools are already available in public GitHub. As it was expected before, this PR has conflicts with code in develop branch: you can see, for example, that dev/tools/Magento/Tools/Di/Compiler/Directory.php was removed. But we still see valuable the possibility to exclude directories for compilation. Sorry for that, but could you update this PR again? Also it will good to support additionally pattern \m1\ (with back slashes) and make it case insensible.

@Flyingmana
Copy link
Member Author

No problem :)
I see, you moved the code into the ClassesScanner, as it is a one purpose class, I add the exclude patterns as property there instead of an argument.

You are right, back slashes are important because of windows environments, that makes the pattern a bit more ugly. I kept it as single pattern, but we could split it into two patterns in theory.
The case insensitive I did directly on the pattern.

Have it already working locally, will push it in a few minutes

@vpelipenko
Copy link
Contributor

CR: passed
Builds: green
Resolution: OK to merge

vpelipenko added a commit that referenced this pull request Feb 27, 2015
Make it possible to exclude classes (directories) for compilation
@vpelipenko vpelipenko merged commit 33545e6 into magento:develop Feb 27, 2015
vpelipenko added a commit that referenced this pull request Feb 27, 2015
magento-team pushed a commit that referenced this pull request Apr 1, 2017
Story
- MAGETWO-66799 Remove legacy implementation of static content deployment
magento-team pushed a commit that referenced this pull request Dec 11, 2017
…roduct visibility. #986

 - Merge Pull Request magento-engcom/magento2ce#986 from nmalevanec/magento2:8176
 - Merged commits:
   1. 8bde633
magento-team pushed a commit that referenced this pull request Dec 11, 2017
magento-team pushed a commit that referenced this pull request Dec 11, 2017
[EngCom] Public Pull Requests - 2.2-develop
 - MAGETWO-85311: Added namespace to product videos fotorama events #12469 #991
 - MAGETWO-85300: 8437: Silent error when an email template is not found #970
 - MAGETWO-85293: 12613: Verbiage Update Required: Product Image Watermark size Validation Message. #985
 - MAGETWO-85286: 8176: LinkManagement::getChildren() does not include product visibility. #986
 - MAGETWO-85285: 12482: Sitemap image links in MultiStore #935
 - MAGETWO-84955: Set Current Store from Store Code if isUseStoreInUrl #12529
 - MAGETWO-84764: NewRelic: Disables Module Deployments, Creates new Deploy Marker Command #12477
 - MAGETWO-84439: 12180 Remove unnecessary use operator for Context, causes 503 error i… #12220
VitaliyBoyko pushed a commit to VitaliyBoyko/magento2 that referenced this pull request Jun 22, 2018
MSI-874: Api-Functional Tests For MSI are Failed.
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.

3 participants