Changeset 546 for trunk/lib/App.inc.php


Ignore:
Timestamp:
Aug 27, 2015 2:35:55 AM (9 years ago)
Author:
anonymous
Message:

Detecting CLI also using php_sapi_name()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r536 r546  
    351351            // DB credentials for CLI scripts stored in a JSON file with read rights given only to the user who will be executing the scripts: -r--------
    352352            // But not if all DB credentials have been defined already by other means.
    353             if (defined('_CLI') && (!$this->getParam('db_server') || !$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass'))) {
     353            if (('cli' === php_sapi_name() || defined('_CLI')) && (!$this->getParam('db_server') || !$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass'))) {
    354354                if (false !== $db_auth_file = stream_resolve_include_path($this->getParam('db_auth_file'))) {
    355355                    if (is_readable($db_auth_file)) {
     
    386386
    387387        // Skip sessions if disabled or automatically skip if run in a CLI script.
    388         if (true === $this->getParam('enable_session') && !defined('_CLI')) {
     388        if (true === $this->getParam('enable_session') && !defined('_CLI') && 'cli' !== php_sapi_name()) {
    389389
    390390            // Session parameters.
     
    450450
    451451        // Character set. This should also be printed in the html header template.
    452         if (!defined('_CLI')) {
     452        if (!defined('_CLI') && 'cli' !== php_sapi_name()) {
    453453            if (!headers_sent($h_file, $h_line)) {
    454454                header('Content-type: text/html; charset=' . $this->getParam('character_set'));
     
    464464            $codebase_version = trim(file_get_contents($codebase_version_file));
    465465            $this->setParam(array('codebase_version' => $codebase_version));
    466             if (!defined('_CLI')) {
     466            if (!defined('_CLI') && 'cli' !== php_sapi_name()) {
    467467                if (!headers_sent($h_file, $h_line)) {
    468468                    header('X-Codebase-Version: ' . $codebase_version);
     
    487487            $this->setParam(array('site_version' => $site_version));
    488488        }
    489         if (!defined('_CLI') && $this->getParam('site_version')) {
     489        if (!defined('_CLI') && 'cli' !== php_sapi_name() && $this->getParam('site_version')) {
    490490            if (!headers_sent($h_file, $h_line)) {
    491491                header('X-Site-Version: ' . $site_version);
Note: See TracChangeset for help on using the changeset viewer.