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

Getting "Content-Type: application/json; charset=UTF-8" output #7

Open
Deele opened this issue Sep 8, 2015 · 0 comments
Open

Getting "Content-Type: application/json; charset=UTF-8" output #7

Deele opened this issue Sep 8, 2015 · 0 comments

Comments

@Deele
Copy link

Deele commented Sep 8, 2015

I could not get this module to reply something useful. All I get is Content-Type: application/json; charset=UTF-8 response.

At first, I was not providing correct yiiScript value, but afterwards I changed it to correct one (tested it via ssh), but still, I'm getting strange result and I don't know what is the cause.

To debug this issue, I did a little rewrite of DefaultController::runConsole() command (using code from AssetConverter::runCommand()) and made it into:

    protected function runConsole($command)
    {
        $command = Yii::getAlias($this->module->yiiScript) . ' ' . $command;
        $descriptor = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $pipes = [];
        $proc = proc_open($command, $descriptor, $pipes, $basePath);
        $stdout = stream_get_contents($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        foreach ($pipes as $pipe) {
            fclose($pipe);
        }
        $status = proc_close($proc);

        $command_d = \yii\helpers\VarDumper::dumpAsString($command);
        $stdout_d = \yii\helpers\VarDumper::dumpAsString($stdout);
        $stderr_d = \yii\helpers\VarDumper::dumpAsString($stderr);
        if ($status === 0) {
            Yii::trace("Command $command_d ran successfully:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d", __METHOD__);
        } elseif (YII_DEBUG) {
            throw new \yii\base\Exception("Command '$command_d' failed with exit code $status:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d");
        } else {
            Yii::error("Command '$command_d' failed with exit code $status:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d", __METHOD__);
        }

        return [$status, $stdout];
    }

And I got this output in debug console:

Command 'php -c php.ini -f ../yii ' ran successfully:
STDOUT:
'Content-Type: application/json; charset=UTF-8

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

No branches or pull requests

1 participant