diff options
-rw-r--r-- | composer.json | 2 | ||||
-rw-r--r-- | composer.lock | 2 | ||||
-rw-r--r-- | core/CliMulti.php | 2 | ||||
-rw-r--r-- | core/Config.php | 1 | ||||
-rw-r--r-- | core/CronArchive.php | 6 | ||||
-rw-r--r-- | libs/upgradephp/upgrade.php | 4 | ||||
-rw-r--r-- | tests/PHPUnit/Core/ConfigTest.php | 44 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/ArchiveWebTest.php | 5 | ||||
-rw-r--r-- | tests/PHPUnit/phpunit.xml.dist | 5 | ||||
-rw-r--r-- | tests/resources/Config/common.config.ini.php | 3 |
10 files changed, 43 insertions, 31 deletions
diff --git a/composer.json b/composer.json index 4347967b19..61397de411 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,6 @@ "piwik/device-detector": "2.*" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "~4.1" } } diff --git a/composer.lock b/composer.lock index aa25e6356e..d8f75e7be3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "016b7b6646d1d3ec6d8b574b5a6c5561", + "hash": "a369c506837f7af17cd3258c889e3b57", "packages": [ { "name": "leafo/lessphp", diff --git a/core/CliMulti.php b/core/CliMulti.php index f5b0d552bd..6248a89789 100644 --- a/core/CliMulti.php +++ b/core/CliMulti.php @@ -234,7 +234,7 @@ class CliMulti { } catch (\Exception $e) { $message = "Got invalid response from API request: $url. "; - if (empty($response)) { + if (isset($response) && empty($response)) { $message .= "The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details."; } else { $message .= "Response was '" . $e->getMessage() . "'"; diff --git a/core/Config.php b/core/Config.php index 80c1d71c94..0c56f95b0c 100644 --- a/core/Config.php +++ b/core/Config.php @@ -384,6 +384,7 @@ class Config extends Singleton } } else { $values = htmlentities($values, ENT_COMPAT, 'UTF-8'); + $values = str_replace('$', '$', $values); } return $values; } diff --git a/core/CronArchive.php b/core/CronArchive.php index e12fcc85f6..7ca9389f85 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -1320,6 +1320,10 @@ class CronArchive */ private function getConcurrentRequestsPerWebsite() { - return $this->getParameterFromCli('--concurrent-requests-per-website', true); + $cliParam = $this->getParameterFromCli('--concurrent-requests-per-website', true); + if ($cliParam !== false) { + return $cliParam; + } + return self::MAX_CONCURRENT_API_REQUESTS; } } diff --git a/libs/upgradephp/upgrade.php b/libs/upgradephp/upgrade.php index 0108f72d7a..ffc6a1d87f 100644 --- a/libs/upgradephp/upgrade.php +++ b/libs/upgradephp/upgrade.php @@ -130,8 +130,8 @@ if(function_exists('parse_ini_file')) { if(!file_exists($filename)) { return false; } - // Note: INI_SCANNER_RAW is important here! - return parse_ini_file($filename, $process_sections, INI_SCANNER_RAW); + + return parse_ini_file($filename, $process_sections); } } else { // we can't redefine parse_ini_file() if it has been disabled diff --git a/tests/PHPUnit/Core/ConfigTest.php b/tests/PHPUnit/Core/ConfigTest.php index 60245868d0..006c550944 100644 --- a/tests/PHPUnit/Core/ConfigTest.php +++ b/tests/PHPUnit/Core/ConfigTest.php @@ -6,12 +6,11 @@ use Piwik\Config; * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @group Core */ class ConfigTest extends PHPUnit_Framework_TestCase { - /** - * @group Core - */ public function testUserConfigOverwritesSectionGlobalConfigValue() { $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.ini.php'; @@ -41,9 +40,6 @@ class ConfigTest extends PHPUnit_Framework_TestCase } - /** - * @group Core - */ public function test_CommonConfig_Overrides() { $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.ini.php'; @@ -60,9 +56,6 @@ class ConfigTest extends PHPUnit_Framework_TestCase } - /** - * @group Core - */ public function testWritingConfigWithSpecialCharacters() { $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.written.ini.php'; @@ -92,9 +85,6 @@ class ConfigTest extends PHPUnit_Framework_TestCase $this->assertEquals($stringWritten, $config->Category['test2']); } - /** - * @group Core - */ public function testUserConfigOverwritesGlobalConfig() { $userFile = PIWIK_PATH_TEST_TO_ROOT . '/tests/resources/Config/config.ini.php'; @@ -154,8 +144,6 @@ class ConfigTest extends PHPUnit_Framework_TestCase } /** - * @group Core - * * @dataProvider getCompareElementsData */ public function testCompareElements($description, $test) @@ -213,8 +201,6 @@ class ConfigTest extends PHPUnit_Framework_TestCase } /** - * @group Core - * * @dataProvider getArrayUnmergeData */ public function testArrayUnmerge($description, $test) @@ -418,13 +404,22 @@ class ConfigTest extends PHPUnit_Framework_TestCase 'newSetting' => 'newValue')), $header . "[General]\nkey = \"value\"\n\n[CommonCategory]\nnewSetting = \"newValue\"\n\n", )), + + array('Converts Dollar Sign To Dollar Entity', array( + array('General' => array('key' => '$value', 'key2' => '${value}')), // local + array('General' => array('key' => '$global'), // global + 'CommonCategory' => array('settingGlobal' => 'valueGlobal')), + array('CommonCategory' => array('settingCommon' => 'common', // common + 'settingCommon2' => 'common2')), + array('CommonCategory' => array('settingCommon2' => 'common2', + 'newSetting' => 'newValue')), + $header . "[General]\nkey = \"$value\"\nkey2 = \"${value}\"\n\n[CommonCategory]\nnewSetting = \"newValue\"\n\n", + )), ); } /** - * @group Core - * * @dataProvider getDumpConfigData */ public function testDumpConfig($description, $test) @@ -436,5 +431,18 @@ class ConfigTest extends PHPUnit_Framework_TestCase $output = $config->dumpConfig($configLocal, $configGlobal, $configCommon, $configCache); $this->assertEquals($expected, $output, $description); } + + public function testDollarEntityGetsConvertedToDollarSign() + { + $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.ini.php'; + $globalFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/global.ini.php'; + $commonFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/common.config.ini.php'; + + $config = Config::getInstance(); + $config->setTestEnvironment($userFile, $globalFile, $commonFile); + $config->init(); + + $this->assertEquals('${@piwik(crash))}', $config->Category['key3']); + } } diff --git a/tests/PHPUnit/Integration/ArchiveWebTest.php b/tests/PHPUnit/Integration/ArchiveWebTest.php index c284a1ab12..570b3b6290 100644 --- a/tests/PHPUnit/Integration/ArchiveWebTest.php +++ b/tests/PHPUnit/Integration/ArchiveWebTest.php @@ -7,6 +7,7 @@ */ use Piwik\Option; +use Piwik\Http; /** * Tests to call the archive.php script via web and check there is no error, @@ -31,10 +32,8 @@ class Test_Piwik_Integration_ArchiveWebTest extends IntegrationTestCase $urlTmp = Option::get('piwikUrl'); Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php'); - $streamContext = stream_context_create(array('http' => array('timeout' => 600))); - $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token . '&forcelogtoscreen=1'; - $output = file_get_contents($url, 0, $streamContext); + $output = Http::sendHttpRequest($url, 600); // ignore random build issues if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) { diff --git a/tests/PHPUnit/phpunit.xml.dist b/tests/PHPUnit/phpunit.xml.dist index 6b13b5dcae..d344206dd2 100644 --- a/tests/PHPUnit/phpunit.xml.dist +++ b/tests/PHPUnit/phpunit.xml.dist @@ -1,6 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="true" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="true" backupStaticAttributes="false" bootstrap="bootstrap.php" colors="false" @@ -14,7 +16,6 @@ stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" - syntaxCheck="false" strict="false" verbose="true"> diff --git a/tests/resources/Config/common.config.ini.php b/tests/resources/Config/common.config.ini.php index db8cb53d41..15852485dc 100644 --- a/tests/resources/Config/common.config.ini.php +++ b/tests/resources/Config/common.config.ini.php @@ -1,8 +1,7 @@ [Category] key2 = valueCommon -; This should not trigger an error if INI_SCANNER_RAW is used -key3 = "${@piwik(crash))}" +key3 = "${@piwik(crash))}" [GeneralSection] password = passwordCommonShouldNotBeOverriden |