From 264cec1239ee8d75e67c5402970a91cf58e50539 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Mon, 9 Oct 2017 10:13:39 +0100 Subject: [PATCH 1/7] FIX Dont use var_export for cache key generation as it fails on circular references --- model/DataObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/DataObject.php b/model/DataObject.php index bec04bb5b..5fff3f39a 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -3224,7 +3224,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $SNG = singleton($callerClass); $cacheComponents = array($filter, $orderby, $SNG->extend('cacheKeyComponent')); - $cacheKey = md5(var_export($cacheComponents, true)); + $cacheKey = md5(serialize($cacheComponents)); // Flush destroyed items out of the cache if($cache && isset(DataObject::$_cache_get_one[$callerClass][$cacheKey]) From 2f579b64cb9cb8986489e312b253dba5061e304b Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Sun, 13 Aug 2017 21:46:47 +1200 Subject: [PATCH 2/7] FIX Files without extensions (folders) do not have a trailing period added --- filesystem/File.php | 7 +++++-- tests/filesystem/FileTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/filesystem/File.php b/filesystem/File.php index 6b66319ac..ff6d71b6b 100644 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -634,7 +634,7 @@ class File extends DataObject { * * Does not change the filesystem itself, please use {@link write()} for this. * - * @param String $name + * @param string $name */ public function setName($name) { $oldName = $this->Name; @@ -663,7 +663,10 @@ class File extends DataObject { ))->first() ) { $suffix++; - $name = "$base-$suffix.$ext"; + $name = "$base-$suffix"; + if (!empty($ext)) { + $name .= ".$ext"; + } } } diff --git a/tests/filesystem/FileTest.php b/tests/filesystem/FileTest.php index b2ecf5e83..8e9fd0730 100644 --- a/tests/filesystem/FileTest.php +++ b/tests/filesystem/FileTest.php @@ -187,6 +187,30 @@ class FileTest extends SapphireTest { } } + /** + * Uses fixtures Folder.folder1 and File.setfromname + * @dataProvider setNameFileProvider + */ + public function testSetNameAddsUniqueSuffixWhenFilenameAlreadyExists($name, $expected) + { + $duplicate = new Folder; + $duplicate->setName($name); + $duplicate->write(); + + $this->assertSame($expected, $duplicate->Name); + } + + /** + * @return array[] + */ + public function setNameFileProvider() + { + return array( + array('FileTest-folder1', 'FileTest-folder1-2'), + array('FileTest.png', 'FileTest-2.png'), + ); + } + public function testLinkAndRelativeLink() { $file = $this->objFromFixture('File', 'asdf'); $this->assertEquals(ASSETS_DIR . '/FileTest.txt', $file->RelativeLink()); From c4a50a3d10bd52b982e6f4f0d0267c394f3351e6 Mon Sep 17 00:00:00 2001 From: Andrew Aitken-Fincham Date: Fri, 20 Oct 2017 12:00:35 +0100 Subject: [PATCH 3/7] Spelling in DataQueryTest --- tests/model/DataQueryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/model/DataQueryTest.php b/tests/model/DataQueryTest.php index 181132e8e..ac8a3ef69 100644 --- a/tests/model/DataQueryTest.php +++ b/tests/model/DataQueryTest.php @@ -63,7 +63,7 @@ class DataQueryTest extends SapphireTest { $this->assertContains('"DataQueryTest_C"."ID" = "DataQueryTest_B"."TestCTwoID"', $dq->sql()); } - public function testApplyReplationDeepInheretence() { + public function testApplyRelationDeepInheritance() { //test has_one relation $newDQ = new DataQuery('DataQueryTest_E'); //apply a relation to a relation from an ancestor class From 8aad080516c4cf848fe4d8f6111f5304ed945e91 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 25 Oct 2017 17:04:44 +0100 Subject: [PATCH 4/7] Add composer autoloading support to 3.x --- composer.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bdbd63c6c..0c3105f1e 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,16 @@ } }, "autoload": { - "classmap": ["tests/behat/features/bootstrap"] + "psr-0": { + "SilverStripe\\": "src/", + "Zend_": "thirdparty/Zend/" + }, + "classmap": [ + "tests/behat/features/bootstrap", + "admin/code", "api", "cache", "cli", "control", "core", "dev", "email", "filesystem", + "forms", "i18n", "model", "oembed", "parsers", "search", "security", "tasks", "view", + "thirdparty/php-peg", "thirdparty/simpletest", "thirdparty/zend_translate_railsyaml" + ], + "exclude-from-classmap": ["view/SSTemplateParser.php.inc", "dev/phpunit/PhpUnitWrapper.php"] } } From 32cef975ef6c816d8b5bc953cffbd18492686281 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 25 Oct 2017 17:45:14 +0100 Subject: [PATCH 5/7] FIX Use self::inst() for Injector/Config nest methods --- control/injector/Injector.php | 2 +- core/Config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/control/injector/Injector.php b/control/injector/Injector.php index c96ddb6f4..1c247b35e 100644 --- a/control/injector/Injector.php +++ b/control/injector/Injector.php @@ -260,7 +260,7 @@ class Injector { * @return Injector Reference to new active Injector instance */ public static function nest() { - $current = self::$instance; + $current = self::inst(); $new = clone $current; $new->nestedFrom = $current; diff --git a/core/Config.php b/core/Config.php index 414350995..9232f1ce8 100644 --- a/core/Config.php +++ b/core/Config.php @@ -223,7 +223,7 @@ class Config { * @return Config Reference to new active Config instance */ public static function nest() { - $current = self::$instance; + $current = self::inst(); $new = clone $current; $new->nestedFrom = $current; From cbac3755909bc5d72d923b07747fd6a98e2215dc Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 25 Oct 2017 17:45:38 +0100 Subject: [PATCH 6/7] FIX Helpful warning when phpunit bootstrap appears misconfigured --- dev/SapphireTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 21df46c13..951d619f1 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -171,6 +171,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { public function setUp() { + if (!defined('FRAMEWORK_PATH')) { + trigger_error( + 'Missing constants, did you remember to include the test bootstrap in your phpunit.xml file?', + E_USER_WARNING + ); + } + //nest config and injector for each test so they are effectively sandboxed per test Config::nest(); Injector::nest(); From 00f1ad5d692f0a44b58bb216e5378e51dc96243d Mon Sep 17 00:00:00 2001 From: Russell Michell Date: Tue, 4 Jul 2017 14:03:36 +1200 Subject: [PATCH 7/7] FIX: Fixes #7116 Improves server requirements docs viz: OpCaches. --- docs/en/00_Getting_Started/00_Server_Requirements.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/00_Getting_Started/00_Server_Requirements.md b/docs/en/00_Getting_Started/00_Server_Requirements.md index 24d162b22..cf0f85600 100644 --- a/docs/en/00_Getting_Started/00_Server_Requirements.md +++ b/docs/en/00_Getting_Started/00_Server_Requirements.md @@ -10,6 +10,7 @@ Our web-based [PHP installer](installation/) can check if you meet the requireme * PHP 5.3.3+, <7 * We recommend using a PHP accelerator or opcode cache, such as [xcache](http://xcache.lighttpd.net/) or [WinCache](http://www.iis.net/download/wincacheforphp). + * Note: Some PHP 5.5+ packages already have [Zend OpCache](http://php.net/manual/en/book.opcache.php) installed by default. If this is the case on your system, do not try and run additional opcaches alongside Zend OpCache without first disabling it, as it will likely have unexpected consequences. * Allocate at least 48MB of memory to each PHP process. (SilverStripe can be resource hungry for some intensive operations.) * Required modules: dom, gd2, fileinfo, hash, iconv, mbstring, mysqli (or other database driver), session, simplexml, tokenizer, xml. * Recommended configuration