Changeset 665 for trunk/lib


Ignore:
Timestamp:
Feb 10, 2019 9:48:46 PM (5 years ago)
Author:
anonymous
Message:

Add $app->isCLI() to replace $app->cli

Location:
trunk/lib
Files:
5 edited

Legend:

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

    r661 r665  
    594594    }
    595595
     596    /*
     597    * @access   public
     598    * @return   bool    True if running in the context of a CLI script.
     599    * @author   Quinn Comendant <quinn@strangecode.com>
     600    * @since    10 Feb 2019 12:31:59
     601    */
     602    public function isCLI()
     603    {
     604        return $this->cli;
     605    }
    596606
    597607    /**
  • trunk/lib/DB.inc.php

    r661 r665  
    261261
    262262        if ($this->getParam('db_die_on_failure')) {
    263             if (!$app->cli) {
     263            if (!$app->isCLI()) {
    264264                // For http requests, send a Service Unavailable header.
    265265                header(' ', true, 503);
     
    357357            $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
    358358            if ($this->getParam('db_debug')) {
    359                 if (!$app->cli) {
     359                if (!$app->isCLI()) {
    360360                    echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
    361361                }
  • trunk/lib/FormValidator.inc.php

    r597 r665  
    364364    * @param  string $form_name the name of the incoming form variable
    365365    * @param  string $msg       the message to display on error
     366    * @param  bool   $negative_ok   Set to true if negative numbers will be allowed.
    366367    * @param  const  $type  A LOG_* constant (see App->logMsg())
    367368    * @param  const  $file  Filename to log (usually __FILE__)
  • trunk/lib/Prefs.inc.php

    r653 r665  
    178178
    179179        // CLI scripts can't use prefs stored in HTTP-based protocols.
    180         if ($app->cli
     180        if ($app->isCLI()
    181181        && isset($params['storagetype'])
    182182        && in_array($params['storagetype'], array('cookie', 'session'))) {
    183             $app->logMsg(sprintf('Storage type %s not available for CLI', $params['storagetype']), LOG_NOTICE, __FILE__, __LINE__);
     183            $app->logMsg(sprintf('Storage type %s not available for CLI', $params['storagetype']), LOG_DEBUG, __FILE__, __LINE__);
    184184        }
    185185
     
    503503        // Skip this method if not using the db.
    504504        if ('database' != $this->getParam('storagetype')) {
    505             $app->logMsg('Prefs->load() does nothing unless using a database storagetype.', LOG_NOTICE, __FILE__, __LINE__);
     505            $app->logMsg('Prefs->load() does nothing unless using a database storagetype.', LOG_DEBUG, __FILE__, __LINE__);
    506506            return true;
    507507        }
     
    559559    {
    560560        if ('database' != $this->getParam('storagetype')) {
    561             $app->logMsg('Prefs->_isLoaded() does nothing unless using a database storagetype.', LOG_NOTICE, __FILE__, __LINE__);
     561            $app->logMsg('Prefs->_isLoaded() does nothing unless using a database storagetype.', LOG_DEBUG, __FILE__, __LINE__);
    562562            return true;
    563563        }
  • trunk/lib/Utilities.inc.php

    r653 r665  
    4242    $app =& App::getInstance();
    4343
    44     if ($app->cli) {
     44    if ($app->isCLI()) {
    4545        echo "DUMP FROM: $file $line\n";
    4646    } else {
     
    7676    }
    7777
    78     if ($app->cli) {
     78    if ($app->isCLI()) {
    7979        echo "\n";
    8080    } else {
Note: See TracChangeset for help on using the changeset viewer.