We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PhalconPHP Database transactions fail on server

I have developed a website using PhalconPHP. the website works perfectly fine on my local computer with the following specifications:

PHP Version 7.0.22
Apache/2.4.18
PhalconPHP 3.3.1

and also on my previous Server (with DirectAdmin):

PHP Version 5.6.26
Apache 2
PhalconPHP 3.0.1

But recently I have migrated to a new VPS. with cPanel:

CENTOS 7.4 vmware [server]
cPanel v68.0.30
PHP Version 5.6.34 (multiple versions available, this one selected by myself)
PhalconPHP 3.2.2

On the new VPS my website always gives me Error 500.

in my Apache Error log: [cgi:error] End of script output before headers: ea-php70, referer: https://mywebsitedomain.net

What I suspect is the new database System. the new one is not mySql. it is MariaDB 10.1. I tried to downgrade to MySQL 5.6 but the WHM says there is no way I could downgrade to lower versions.

this is my config file:

[database]
adapter  = Mysql
host     = localhost
username = root
password = XXXXXXXXXXXX
dbname   = XXXXXXXXXXXX
charset  = utf8

and my Services.php:

protected function initDb()
{
    $config = $this->get('config')->get('database')->toArray();

    $dbClass = 'Phalcon\Db\Adapter\Pdo\\' . $config['adapter'];
    unset($config['adapter']);

    return new $dbClass($config);
}

And in my controllers... for example this code throws Error 500:

$this->view->files = Patients::query()->orderBy("id ASC")->execute();

but changing id to fname fixes the problem:

$this->view->files = Patients::query()->orderBy("fname ASC")->execute();

or even the following code throws error 500:

$user = Users::findFirst(array(
                         "conditions" => "id = :id:",
                         "bind" => array("id" => $this->session->get("userID"))
                        ));

but again if I search by string fields there is no problem.

is there a problem with the compatibility of PhalconPHP and MariaDB?

The code looks nice. I don't have problems with MariaDB and Phalcon. Look this

I recommend you developt and test in the same enviroment witch use in production to avoid version incompatibilities and try to always choose the latest available version

Good luck

I don't think this is a database issue. I did an in-place replacement from mysql to mariadb for 4 servers and 10+ apps, with no issues.

Searching for that error string, it pops up with Perl too - and "apache" seems to be a keyword in results, so perhaps it's an Apache configuration problem rather than specifically Phalcon?

https://stackoverflow.com/questions/22307610/end-of-script-output-before-headers-error-in-apache https://stackoverflow.com/questions/40064651/whats-this-end-of-script-output-before-headers https://stackoverflow.com/questions/28265735/apache-cgi-in-user-directory-end-of-script-output-before-headers



58.1k

I have same issue now. Did you fix this?