Magento2: 'Parse error: syntax error, unexpected end of file' due to open PHP tag

Created on 11 Oct 2019  路  22Comments  路  Source: magento/magento2

Preconditions (*)

This error is happening after updating to 2.2.10.
It seems this commit (https://github.com/magento/magento2/commit/7f346f38a54d0d5f2ff7a3c1a6cbbdf0aa3c338f) introduced loads of open PHP tags. Not sure why this is, it's not been done on the 2.3.x branch ...
Admin/backend loads, just frontend which is broken

Steps to reproduce (*)

Not sure; updated from 2.2.9 to 2.2.10 and just deployed the changes to my Staging env.

Expected result (*)

No errors, site should just load the homepage correctly.

Actual result (*)

When trying to load the homepage I get a single error message;
Parse error: syntax error, unexpected end of file in /...project-path.../http/var/view_preprocessed/pub/static/vendor/magento/module-reports/view/frontend/templates/js/components.phtml on line 1

Format is valid

Most helpful comment

Attached a patch that I tested on a Magento Cloud environment.

https://kayser-roth-public.s3.amazonaws.com/25551.patch

All 22 comments

Hi @yeevy. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

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

@yeevy do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

@magento give me 2.2.10 instance

Hi @yeevy. Thank you for your request.
Unfortunately, I can only deploy instances for 2.3 release line

@magento I am working on it

Hi @Shubham-Webkul. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch
    Details- Add the comment @magento 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_!

Hi @vivekkumar-webkul. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch
    Details- Add the comment @magento 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_!

Two things that strike me about this bug, without knowing the actual solution yet: One, the PHTML file that throws the error is "minified" (so it becomes a single line with 2 opening tags). Two, why is this PHTML template copied to a var/view_preprocessed/pub/static folder anyway, while it should never end up in the folder pub because it is not a web-accessible file?

Did somebody create a deployment trick that minifies any (!) file that resides in any (!) js folder?

This was quite the bug to track down. Running 2.2.10 in developer mode works fine but as soon as you switch to default or production mode, the problems start. Luckily, we caught it before any production merges/deployments.

How long do you figure we will have to wait for a patch?

Hi, same problem here. Quick fix is to override few files from modules view in a theme folder.
Copy the files and remove

I started going that direction @tiacocstoe but found that there were so many. I ended up making a patch that runs as part of our deployment process. Here is a link to the patch if anyone needs it until Magento fixes the issue.

Well @petemcw as far as i can tell You're doing exactly same as i suggested but directlu in a core files. I'd rather do this my way, but suit Yourself :)
Still, it's a nasty bug and should never apear

Here is a simple script that will fix end of line <?php issue in core files
IMPORTANT: do not run it on production server
For Mac OS

subj='<?php'
for file in `grep -rl "$subj" vendor/magento`; do
LINE_END=`tail -n 1 $file | grep -e $subj'$'`

if [[ -n $LINE_END ]]; then
echo $file;
sed -i '' -e '$ d'  $file;
fi

done

for Linux

subj='<?php'
for file in `grep -rl "$subj" vendor/magento`; do
LINE_END=`tail -n 1 $file | grep -e $subj'$'`

if [[ -n $LINE_END ]]; then
echo $file;
sed -i '$ d'  $file;
fi

done

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento 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_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @yeevy

Thank you for contribution and collaboration!

We are not able to reproduce this issue on the latest 2.3-develop branch by provided steps.

We are closing this issue due to branch 2.2-develop was closed and

Magento no longer accepts pull requests and issues to the v2.2 release lines to focus all development efforts on v2.3.

See Accepted pull requests and ported code for more details.

Please refer to the Community Forums or the Magento Stack Exchange, for advice or general discussion about this issue.

If you still faced this issue on 2.3 please create a new Issue with all required details according to Issue reporting guidelines

Thanks for your report!

Hello Guys,

I have absolutely same issue after updating from 2.2.9 to 2.2.10. Is there a solution to that issue?

Sincerely,
Andrei.

Hello @SigmaAndrei
Please refer to the Community Forums or the Magento Stack Exchange, for advice or general discussion about this issue.

@engcom-Charlie I tried to use the patch that @petemcw provided, but it doesn't work for cloud, maybe you guys have another thread I can look at?

Attached a patch that I tested on a Magento Cloud environment.

https://kayser-roth-public.s3.amazonaws.com/25551.patch

Having the same issue on our Magento Cloud 2.2.10, and unable to reproduce on a local machine. We've added @0x15f 's patch, and works great.

When I change my email in local repository, it not change and have error is: line 420: syntax error: unexpected end of file
This is line 419 and line 420 in file what had error
eval "$filter_env" < /dev/null ||
die "env filter failed: $filter_env"
I hope fixing it. Thanks people ^^

When I change my email in local repository, it not change and have error is: line 420: syntax error: unexpected end of file
This is line 419 and line 420 in file what had error
eval "$filter_env" < /dev/null ||
die "env filter failed: $filter_env"
I hope fixing it. Thanks people ^^

What file had this error? @duong-146

git-filter-branch line 420, can you give me this file for comparing ? @0x15f
C:/Program Files/Git/mingw64/libexec/git-coregit-filter-branch: eval: line 420: syntax error: unexpected end of file

Was this page helpful?
0 / 5 - 0 ratings