From 04b39646dd632f693c2db7f9ade997a768559969 Mon Sep 17 00:00:00 2001 From: Benjamin Fleming Date: Wed, 29 Jun 2016 15:43:07 +1000 Subject: [PATCH 1/4] Cache no longer shared across domains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixed an issue where Neo blocks were having their caches shared across multiple domains, if they pointed to the same Craft install. This became a problem if resource access was limited to the original requests host name. For example, localhost servers had their caches shared with the local & global IP’s that also pointed to that server. Caches by localhost were serving localhost resources to the outside world, which meant the resources couldn’t load. --- neo/fieldtypes/NeoFieldType.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/neo/fieldtypes/NeoFieldType.php b/neo/fieldtypes/NeoFieldType.php index 142f56b2..32c23531 100644 --- a/neo/fieldtypes/NeoFieldType.php +++ b/neo/fieldtypes/NeoFieldType.php @@ -740,11 +740,13 @@ private function _getBlockHtml(Neo_BlockTypeModel $blockType, Neo_BlockModel $bl $hasErrors = !empty($errors); $fullNamespace = craft()->templates->namespaceInputName($namespace, craft()->templates->getNamespace()); - $cacheKey = implode(':', ['neoblock', + $cacheKey = implode('|', ['neoblock', $blockType->id, $block ? $block->id : '', $fullNamespace, - $static ? 's' : '', + $static ? '1' : '0', + craft()->request->isSecureConnection() ? '1': '0', + craft()->request->getHostName(), ]); $tabsHtml = $hasErrors ? false : craft()->cache->get($cacheKey); From 32394624797c1bf6e74198ed9830a45b1f214d48 Mon Sep 17 00:00:00 2001 From: Benjamin Fleming Date: Fri, 8 Jul 2016 09:51:17 +1000 Subject: [PATCH 2/4] #21 Fixed bug with live preview in Craft 2.6.2793 --- neo/models/Neo_CriteriaModel.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/neo/models/Neo_CriteriaModel.php b/neo/models/Neo_CriteriaModel.php index a64bc1f3..d2f12846 100644 --- a/neo/models/Neo_CriteriaModel.php +++ b/neo/models/Neo_CriteriaModel.php @@ -79,6 +79,23 @@ public function copy() return $copy; } + /** + * Returns the total number of elements matched by this criteria. + * Fixes live preview mode which broke in Craft 2.6.2793 due to this method. If live preview mode is detected, it + * uses the old method which worked in live preview mode. + * + * @return int + */ + public function count() + { + if(craft()->request->isLivePreview()) + { + return count($this->find()); + } + + return parent::count(); + } + /** * Sets a filter value for the criteria model, then reruns Live Preview filtering. * From 1427142bb8e300ffa843dfa3a3b5c31205aa7535 Mon Sep 17 00:00:00 2001 From: Benjamin Fleming Date: Fri, 8 Jul 2016 10:26:52 +1000 Subject: [PATCH 3/4] #35 Fixed bug where drafts were showing old values --- neo/fieldtypes/NeoFieldType.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neo/fieldtypes/NeoFieldType.php b/neo/fieldtypes/NeoFieldType.php index 32c23531..a057e17f 100644 --- a/neo/fieldtypes/NeoFieldType.php +++ b/neo/fieldtypes/NeoFieldType.php @@ -739,10 +739,12 @@ private function _getBlockHtml(Neo_BlockTypeModel $blockType, Neo_BlockModel $bl $errors = $block ? $block->getAllErrors() : []; $hasErrors = !empty($errors); $fullNamespace = craft()->templates->namespaceInputName($namespace, craft()->templates->getNamespace()); + $owner = $block ? $block->getOwner() : null; $cacheKey = implode('|', ['neoblock', $blockType->id, $block ? $block->id : '', + $owner ? $owner->dateUpdated->getTimestamp() : '', $fullNamespace, $static ? '1' : '0', craft()->request->isSecureConnection() ? '1': '0', From 03d50c8ab640edbecdb37b0a2177e2f109f7ca67 Mon Sep 17 00:00:00 2001 From: Benjamin Fleming Date: Fri, 8 Jul 2016 10:34:15 +1000 Subject: [PATCH 4/4] Released v1.3.2 --- CHANGELOG.md | 5 +++++ neo/NeoPlugin.php | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf718eaf..63c92c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Changelog +#### v1.3.2 +- `Fixed` Fixed bug with live preview mode breaking for Neo fields in Craft 2.6.2793 +- `Fixed` Fixed bug with entry drafts not updating their Neo block field values after saving +- `Fixed` Fixed bug where Neo blocks would share caches across differing host names + #### v1.3.1 - `Fixed` Fixed incompatibility with PHP 5.5 and below introduced in `1.3.0` - `Fixed` Fixed bug where leaving editing an element would always show the confirm dialog, regardless if anything changed diff --git a/neo/NeoPlugin.php b/neo/NeoPlugin.php index 0d8cf881..7efd624e 100644 --- a/neo/NeoPlugin.php +++ b/neo/NeoPlugin.php @@ -22,7 +22,7 @@ public function getDescription() public function getVersion() { - return '1.3.1'; + return '1.3.2'; } public function getCraftMinimumVersion() diff --git a/package.json b/package.json index d6ca63e7..09e954eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "craft-neo", - "version": "1.3.1", + "version": "1.3.2", "description": "A Matrix-like field type that uses existing fields", "main": "webpack.config.js", "scripts": {