Changeset 699


Ignore:
Timestamp:
Aug 8, 2019 10:38:24 PM (5 years ago)
Author:
anonymous
Message:

Add support for PHP >=5.6 <=7.3. Add MySQL polyfill.

Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/init_codebase_tables.cli.php

    r601 r699  
    172172            // DBSessionHandler!
    173173
    174             // We need to hack the app to allow sessions to run in a CLI.
    175             $app->stop();
    176             $app->cli = false;
    177             $app->setParam(array('enable_session' => true));
    178             $app->start();
     174            if (version_compare(PHP_VERSION, '7.0.0', '<')) {
     175                // We need to hack the app to allow sessions to run in a CLI.
     176                $app->stop();
     177                $app->cli = false;
     178                $app->setParam(array('enable_session' => true));
     179                $app->start();
     180            }
    179181
    180182            if (!isset($opt['c'])) {
  • trunk/composer.json

    r516 r699  
    1313    ],
    1414    "require": {
    15         "php": "^5.3.7"
     15        "php": ">=5.6 <=7.3"
    1616    },
    1717    "require-dev": {
  • trunk/docs/version.txt

    r686 r699  
    1 2.2.5
     12.3.0
  • trunk/lib/App.inc.php

    r693 r699  
    455455            // Only create a legacy mysql_* DB object if it is explicitly requested.
    456456            if (true === $this->getParam('enable_db')) {
     457                require_once dirname(__FILE__) . '/../polyfill/mysql.inc.php';
    457458                require_once dirname(__FILE__) . '/DB.inc.php';
    458459                $this->db =& DB::getInstance();
     
    648649        $this->running = false;
    649650        $num_queries = 0;
    650         if (is_a($this->db, 'DB') && true === $this->getParam('enable_db')) {
    651             $num_queries = $this->db->numQueries();
     651        if ($this->db instanceof \DB && true === $this->getParam('enable_db')) {
     652            $num_queries += $this->db->numQueries();
     653            if ($num_queries > 0 && true === $this->getParam('enable_db_pdo')) {
     654                // If the app wants to use PDO, warn if any legacy db queries are made.
     655                $this->logMsg(sprintf('%s queries using legacy DB functions', $num_queries), LOG_WARNING, __FILE__, __LINE__);
     656            }
    652657            $this->db->close();
     658        }
     659        if ($this->pdo instanceof \Strangecode\Codebase\PDO && (true === $this->getParam('enable_db') || true === $this->getParam('enable_db_pdo'))) {
     660            $num_queries += $this->pdo->numQueries();
     661            $this->pdo->close();
    653662        }
    654663        $mem_current = memory_get_usage();
Note: See TracChangeset for help on using the changeset viewer.