uvdesk / mailbox-component

The Mailbox component provides tools that allows your helpdesk to process tickets from multiple email sources.
MIT License
22 stars 38 forks source link

refresh-mailbox produces Parse Error #56

Closed k605543016 closed 4 years ago

k605543016 commented 4 years ago

I'm calling the following script from the console: php bin/console uvdesk:refresh-mailbox correct_email@domain.com

and receiving:

  1. Processing uvdesk mailbox configuration.
  2. Opening imap stream...
  3. IMAP stream opened.
  4. Fetching Email collection since 15 June 2020.
  5. Total fetched email -> 2
  6. Starting to convert Emails into Tickets ->

    ============================================= Converting email 1 out of 1. Mailbox refreshed successfully !!!

but no ticket is created. So i put: dump($requestUrl.': '.$curlResponse); in RefershMailboxCommand.php script, inside pushMessage method.

now I'm receiving the following:

https://path-to-my-uvdesk/mailbox/listener:
\n Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in {PATH TO PUBLIC}/index.php on line 3
\n

In index.php, line 3, I see only: use App\Kernel;

So what is the problem? Why console reports parse error? How should I fix it?

papnoisanjeev commented 4 years ago

@k605543016 Have you changed your site_url under uvdesk.yaml(config->packages) ?

k605543016 commented 4 years ago

@papnoisanjeev Yes of course, site_url is correct.

As I said, dump($requestUrl) returns the correct url to my UVDesk instance. For example, if site_url is = "path_to_my_uvdesk", dumped $requestUrl is = https://path_to_my_uvdesk/mailbox/listener

Additionally, if I open https://path_to_my_uvdesk/mailbox/listener in browser (without passing any additional POST or GET variables), it prints just "200".

And the last important thing - I'm running under PHP 7.2.

papnoisanjeev commented 4 years ago

@k605543016

Please check if same php version exist for Web and CLI. If both are different means for Web it is php 7.3 is enabled and for CLI it is php 7.2.

If this condition exist then you need to make a default php version for both. i.e php 7.2

And check if php mailparse extension enabled for the php 7.2 before running mailbox refresh command.

k605543016 commented 4 years ago

@papnoisanjeev

I checked that in both cases (web and CLI) php version 7.2.3 is used. And php mailparse extension is also present (phpinfo says: version 2.1.7-dev).

papnoisanjeev commented 4 years ago

@k605543016

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in {PATH TO PUBLIC}/index.php on line 3

Such kind of parsing error only generates when php version is not compatible with code as old version not able to parse new syntax and code.

So please re-verify again your version and check if it is used for this project.

Check here.

k605543016 commented 4 years ago

@papnoisanjeev

I'm afraid I've already double-checked it:

But the most interesting thing is that when my php script called using CLI (under 7.2.3) is calling another php script via CURL, this Apache call is using not php 7.2.3, but 5.2.17... Impossible, but real.

I'm going to make it fixed by our admin and give you feedback. Thank you.

papnoisanjeev commented 4 years ago

@k605543016

But the most interesting thing is that when my php script called using CLI (under 7.2.3) is calling another php script via CURL, this Apache call is using not php 7.2.3, but 5.2.17... Impossible, but real.

Exactly, It is the main problem instead of php version 7.2 is is using php version 5.2 so many things are not supported for older version so you are facing the parsing error.

k605543016 commented 4 years ago

We can switch between different php versions (from 5.2 to 7.2) for web and CLI. But our admin says, that if we call php script using CURL, loadbalancer is not used and server uses the lowest (5.2) php version.

So while we are using CURL, mail parser will not work.

So the question is: is it possible to override this part of script and use mail parser directly, without CURL call?

papnoisanjeev commented 4 years ago

@k605543016

You need to change curl request to normal request.

https://github.com/uvdesk/mailbox-component/blob/master/Controller/MailboxChannelXHR.php#L13

you need to use this Highlighted function in any service so that you can call that service directly from controller and can pass parameter there.

k605543016 commented 4 years ago

Our admin says he fixed server configuration, and CURL call should work under php 7.2 version. Unfortunately console script dies just after printing:

  1. Fetching Email collection since 17 June 2020.

It doesn't use pushMessage method at all. In which file/function should I try to debug what is the problem?

papnoisanjeev commented 4 years ago

@k605543016

locate path in your project: vendor->uvdesk->mailbox-component->Console/RefreshMailboxCommand.php

https://github.com/uvdesk/mailbox-component/blob/master/Console/RefreshMailboxCommand.php copy and paste code from above URL in RefreshMailboxCommand.php

then make a try may be you have used dump and die in this file.