Skip to content

Commit

Permalink
[TASK] Backport EM Update script and TS Cache to legacy branch (#1296)
Browse files Browse the repository at this point in the history
* [FEATURE] Fix records references in EM update script

Enable the update script, which may be run in the
extension manager, to fix records with wrong
references (wrongly assigned »flux parent«) automatically.

Refs #1176

* [BUGFIX] Always cache TypoScript config in FluxService

Previously, #getAllTypoScript did not cache the configuration when
called from the frontend. This resulted in a rather large performance
overhead, since #removeDotsFromTS was called repeatedly. This commit
modifies the behaviour such that the configuration is always cached.

Backport of commit:f876ffdcdf8e4e76eda1b62409138f6361e32bd1 for legacy branch

Refs #1140

* [TASK] Add note about legacy branch

* Add a hint how PRs for the legacy branch are handled.
* Show in EM that this is a legacy branch version
  • Loading branch information
pixelbrackets authored and NamelessCoder committed Jan 20, 2017
1 parent 1736bc8 commit d2517ea
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
13 changes: 12 additions & 1 deletion Classes/Service/FluxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,25 @@ public function getTypoScriptByPath($path) {
* @return array
*/
public function getAllTypoScript() {
$pageId = $this->configurationManager->getCurrentPageId();
$pageId = $this->getCurrentPageId();
if (FALSE === isset(self::$typoScript[$pageId])) {
self::$typoScript[$pageId] = (array) $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
self::$typoScript[$pageId] = GeneralUtility::removeDotsFromTS(self::$typoScript[$pageId]);
}
return (array) self::$typoScript[$pageId];
}

/**
* @return integer
*/
protected function getCurrentPageId() {
if ($this->configurationManager instanceof BackendConfigurationManager) {
return (integer) $this->configurationManager->getCurrentPageId();
} else {
return (integer) $GLOBALS['TSFE']->id;
}
}

/**
* ResolveUtility the top-priority ConfigurationPrivider which can provide
* a working FlexForm configuration baed on the given parameters.
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Flux: Fluid FlexForms

[![Build Status](https://img.shields.io/travis/FluidTYPO3/flux.svg?style=flat-square&label=package)](https://travis-ci.org/FluidTYPO3/flux/) [![Coverage Status](https://img.shields.io/coveralls/FluidTYPO3/flux/development.svg?style=flat-square)](https://coveralls.io/r/FluidTYPO3/flux) [![Documentation](http://img.shields.io/badge/documentation-online-blue.svg?style=flat-square)](https://fluidtypo3.org/documentation/templating-manual/introduction.html) [![Build Status](https://img.shields.io/travis/FluidTYPO3/fluidtypo3-testing.svg?style=flat-square&label=framework)](https://travis-ci.org/FluidTYPO3/fluidtypo3-testing/) [![Coverage Status](https://img.shields.io/coveralls/FluidTYPO3/fluidtypo3-testing/master.svg?style=flat-square)](https://coveralls.io/r/FluidTYPO3/fluidtypo3-testing)

---

:bangbang: **Legacy branch** :hand:

*Please note that this is a legacy branch for flux in TYPO3 6.2. This version is no longer supported by the Flux team, but we are happy to keep [merging pull requests into the legacy branch](https://github.com/FluidTYPO3/flux/issues/1149#issuecomment-223269520) as long as users keep making them.*

---

> Flux is a replacement API for TYPO3 FlexForms - with interfaces for Fluid, PHP and TypoScript
Flux lets you build and modify forms in Fluid:
Expand Down
14 changes: 14 additions & 0 deletions Tests/Unit/Service/FluxServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,18 @@ public function getConvertFlexFormContentToArrayTestValues() {
);
}

/**
* @test
*/
public function testGetAllTypoScriptCache() {
$fluxService = $this->createFluxServiceInstance(array('getCurrentPageId'));

$configurationManager = $this->getMock('FluidTYPO3\Flux\Configuration\ConfigurationManager', array('getConfiguration'));
$fluxService->injectConfigurationManager($configurationManager);
$configurationManager->expects($this->once())->method('getConfiguration');

$this->assertNotNull($fluxService->getAllTypoScript());
$this->assertNotNull($fluxService->getAllTypoScript());
}

}
21 changes: 17 additions & 4 deletions class.ext_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,37 @@
* Performs update tasks for extension flux
*/
// @codingStandardsIgnoreStart
class ext_update {
class ext_update
{

/**
* @return boolean
*/
public function access() {
return TRUE;
return true;
}

/**
* @return string
*/
public function main() {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'colPos = -42', array('colPos' => 18181));
$content = '';

$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'colPos = -42', ['colPos' => 18181]);
$content .= 'Switch to positive colPos (see #477): ' .
$GLOBALS['TYPO3_DB']->sql_affected_rows() . ' rows affected' . PHP_EOL;

// Fix records with wrong references (see #1176)
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'tx_flux_parent > 0 AND tx_flux_column = \'\'', ['tx_flux_parent' => 0]);
$content .= 'Fix records with wrong references (see #1176): ' .
$GLOBALS['TYPO3_DB']->sql_affected_rows() . ' rows affected' . PHP_EOL;

$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cf_extbase_reflection');
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cf_extbase_reflection_tags');
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cf_extbase_object');
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cf_extbase_object_tags');
return $GLOBALS['TYPO3_DB']->sql_affected_rows() . ' rows have been updated. System object caches cleared.';
$content .= 'System object caches cleared.' . PHP_EOL;

return nl2br($content);
}
}
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
***************************************************************/

$EM_CONF[$_EXTKEY] = array(
'title' => 'Flux: Fluid FlexForms',
'title' => 'Flux: Fluid FlexForms (Legacy Branch)',
'description' => 'Backend form and frontend content rendering assistance API with focus on productivity.',
'category' => 'misc',
'shy' => 0,
Expand Down

0 comments on commit d2517ea

Please sign in to comment.