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

events.xml cant have no childrens, others can [Magento 2.2.4] #15931

Closed
bytes-commerce opened this issue Jun 7, 2018 · 12 comments
Closed

events.xml cant have no childrens, others can [Magento 2.2.4] #15931

bytes-commerce opened this issue Jun 7, 2018 · 12 comments
Assignees
Labels
Component: Framework/Event Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@bytes-commerce
Copy link

Preconditions

  1. Using Magento 2.2.4
  2. PHP 7.0.30

Steps to reproduce

  1. Create new module
  2. Create di.xml, events.xml, crontab.xml additionally to needed module.xml
  3. Fill all files correctly with its nessecary headers but dont put any children in it
    Example for di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
</config>

  1. run php bin/magento setup:upgrade && php bin/magento cache:flush && php bin/magento cache:clean

Expected result

  1. Upgrade + Flush + Clean should run fine trough, page is loading afterwards in developer mode

Actual result

  1. Upgrade runs fine, Cache Flush triggers the error (cache:clean does not)
  2. Error Message:
  [Magento\Framework\Exception\LocalizedException]                               
  Invalid XML in file /var/www/html/app/code/Vendor/Modulename/etc/events.xml:  
  Element 'config': Missing child element(s). Expected is ( event ).             
  Line: 2        

This is not logically as it should render fine, process the file even with no config in it, as it process other files.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 7, 2018
@engcom-backlog-nickolas engcom-backlog-nickolas added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Framework/Event Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Jul 20, 2018
@engcom-backlog-nickolas

Hello @NopeNopeNope, thank you for your report.
We've acknowledged the issue and added to our backlog.

Looks like the only thing which should be changed is set minOccurs from "1" to "0":

<xs:element name="event" type="eventDeclaration" minOccurs="1" maxOccurs="unbounded">

If you'd like, you can create pull request to fix this issue.

@arnoudhgz
Copy link
Contributor

@engcom-backlog-nickolas are you sure you need to fix this by setting minOccurs from "1" to "0"? Should the developer just not create the events.xml file since no events are added?

The crontab.xsd also has the minOccurs set to "1" for the group element in the config part. Maybe the di.xml should have a more strict xsd to require at least one preference, type or virtualType.

I think your suggestion will make the code less strict and therefore not a step in the good direction.

Please advice to not add an empty events.xml when you do not need one.

@bytes-commerce
Copy link
Author

@arnoudhgz

Whatever way they choose, it should be unified. Right now there can be empty XMLs, but no empty events.xml.

@bytes-commerce
Copy link
Author

@arnoudhgz if you downvote something, one should have the courage to explain why its a bad idea. Please elaborate if possible.

@arnoudhgz
Copy link
Contributor

arnoudhgz commented Jul 25, 2018

@NopeNopeNope I don't think everything should work the same, a di.xml and a events.xml have a different purpose. It is nice that events.xml can't be added empty, that the xsd blocks this for you.

Don't add empty files if you need them. My opinion is that it should not be unified with 'whatever way they choose'. The can improve other xsds, but they should never downgrade the xsd for the events by making it less strict just to have in a unified way.

@hostep
Copy link
Contributor

hostep commented Jul 25, 2018

I ran into this problem myself sometimes, when putting some xml code in comments in the events.xml or crontab.xml file, just for testing something quickly. It's really annoying then to have to remove the entire file just because the xsd file blocks an empty file. I'd appreciate it if the file can exist but be empty.

I agree that having empty files in a module makes no sense, but for quickly debugging something it would still be nice if this would be allowed.

@arnoudhgz
Copy link
Contributor

Also in that case, quickly testing something should not be more important than having strict code, which in the end is more error proof.
I don't see the hassle with removing (or renaming) a file shortly if you want the events disabled for testing something.

cliff86 pushed a commit to cliff86/magento2 that referenced this issue Sep 9, 2018
@lisovyievhenii lisovyievhenii self-assigned this Nov 10, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 10, 2018

Hi @lisovyievhenii. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@orlangur
Copy link
Contributor

@arnoudhgz,

more important than having strict code, which in the end is more error proof

I don't see how allowing empty events.xml makes code less error proof.

@magento-engcom-team
Copy link
Contributor

Hi @NopeNopeNope. Thank you for your report.
The issue has been fixed in #19146 by @lisovyievhenii in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Nov 29, 2018
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Dec 10, 2018
@magento-engcom-team
Copy link
Contributor

Hi @NopeNopeNope. Thank you for your report.
The issue has been fixed in #19145 by @lisovyievhenii in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@roshanyadav89
Copy link

I am facing this issue anyone knows: Invalid Document
Element 'route': Missing child element(s). Expected is ( resources ).
Line: 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/Event Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

9 participants