Skip to content

Commit 67a85f6

Browse files
committed
Merge branch 'release/0.43.0'
2 parents 8dfa299 + b503188 commit 67a85f6

File tree

12 files changed

+141
-780
lines changed

12 files changed

+141
-780
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2019-06-28 [RELEASE] Release of t3events 0.43.0 (Dirk Wenzel)
2+
2019-06-28 3102df5 [TASK] documentation updated, obsolete update skript removed (Dirk Wenzel)
3+
2019-06-28 b8e9986 [TASK] unit tests for Update/MigratePluginRecords removed - unit tests make no longer sense due to switch to symfony query builder (Dirk Wenzel)
4+
2019-06-28 7e880d7 [BUGFIX] requirement for dwenzel/t3extension-tools loosened (Dirk Wenzel)
5+
2019-06-25 b57e6ff [TASK] use dwenzel/extension-tools - allows to toggle caching of plugin (Dirk Wenzel)
6+
2019-06-03 e6fcaba [RELEASE] Release of t3events 0.42.3 (Dirk Wenzel) (Dirk Wenzel)
7+
2019-06-03 9d2e672 [BUGFIX] fixed error where Performance->quickMenuAction was not registered correctly as non-cacheable (Dirk Wenzel)
8+
2019-03-06 45654f6 [RELEASE] Release of t3events 0.42.2 (Dirk Wenzel) (Dirk Wenzel)
9+
2019-03-06 7310b86 [BUGFIX] fixed error in unit tests for CleanUpCommandController caused by insufficient mocking (Dirk Wenzel)
10+
2019-03-06 c21e5d7 [BUGFIX] fixed error in command controller where deletion of records was not persisted (Dirk Wenzel)
11+
112
2019-06-03 [RELEASE] Release of t3events 0.42.3 (Dirk Wenzel)
213
2019-06-03 9d2e672 [BUGFIX] fixed error where Performance->quickMenuAction was not registered correctly as non-cacheable (Dirk Wenzel)
314

Classes/Service/ExtensionService.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

Classes/Update/MigratePluginRecords.php

Lines changed: 91 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,38 @@
33

44
namespace DWenzel\T3events\Update;
55

6+
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
67
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
8+
use TYPO3\CMS\Core\Database\ConnectionPool;
79
use TYPO3\CMS\Core\Messaging\FlashMessage;
810
use TYPO3\CMS\Core\Utility\GeneralUtility;
9-
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
10-
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
1111
use TYPO3\CMS\Install\Updates\AbstractUpdate;
1212

1313
/**
1414
* Class MigratePluginRecords
1515
* Updates flex form settings in events plugins
16+
* @codeCoverageIgnore
1617
*/
1718
class MigratePluginRecords extends AbstractUpdate
1819
{
1920
const CONTENT_TABLE = 'tt_content';
2021
const FLEX_FORM_FIELD = 'pi_flexform';
21-
const DEPRECATED_PLUGIN_WHERE_CLAUSE = "list_type='t3events_events' AND pi_flexform REGEXP 'settings.sortBy|Event->calendar'";
22-
const MESSAGE_UPDATE_REQUIRED = 'Found %s Plugin records which need to be updated';
23-
const TITLE_UPDATE_REQUIRED = 'Update required';
22+
const LIST_TYPE_FIELD = 'list_type';
23+
const PLUGIN_TYPE_EVENTS = 't3events_events';
24+
const ID_FIELD = 'uid';
25+
const DEPRECATED_FLEX_KEY = 'settings.cache.makeNonCacheable';
26+
const REPLACEMENT_FLEX_KEY = 'settings.cache.notCacheable';
27+
const MESSAGE_UPDATE_REQUIRED = 'Found %s plugin records which need to be updated (t3events)';
28+
const WIZARD_TITLE = 'Migrate Event Plugin Records';
29+
const TITLE_UPDATE_REQUIRED = 'Migrate Event Plugin Records';
30+
const IDENTIFIER = 'T3eventsMigratePluginRecords';
2431
const MESSAGE_UPDATED = '%s Plugin records updated.';
2532
const TITLE_UPDATED = 'Update success';
2633

34+
protected $identifier = '';
35+
protected $title = self::WIZARD_TITLE;
36+
37+
2738
/**
2839
* @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools
2940
*/
@@ -36,17 +47,14 @@ class MigratePluginRecords extends AbstractUpdate
3647
*/
3748
public function checkForUpdate(&$description)
3849
{
39-
$versionNumber = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
40-
if ($versionNumber >= 8000000) {
41-
return false;
42-
}
50+
$count = $this->countPluginRecordsWithDeprecatedSettings();
4351

44-
$updateRequired = false;
45-
if ($this->countPluginRecordsWithDeprecatedSettings()) {
46-
$updateRequired = true;
52+
if ($count) {
53+
$description = sprintf(self::MESSAGE_UPDATE_REQUIRED, $count);
54+
return true;
4755
}
4856

49-
return $updateRequired;
57+
return false;
5058
}
5159

5260
/**
@@ -55,7 +63,7 @@ public function checkForUpdate(&$description)
5563
*/
5664
protected function getFlexFormTools()
5765
{
58-
if (!$this->flexFormTools instanceof FlexFormTools) {
66+
if (!$this->flexFormTools instanceof FlexFormTools) {
5967
/** @var FlexFormTools flexFormTools */
6068
$this->flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
6169
}
@@ -72,90 +80,109 @@ protected function getFlexFormTools()
7280
*/
7381
public function performUpdate(array &$dbQueries, &$customMessages)
7482
{
75-
$success = false;
7683
$pluginRecords = $this->getPluginRecordsWithDeprecatedSettings();
7784
$pluginCount = count($pluginRecords);
7885

7986
if ($pluginCount) {
87+
if (!is_array($customMessages)) {
88+
$customMessages = [$customMessages];
89+
}
8090
$customMessages[] = [
8191
FlashMessage::INFO,
8292
self::TITLE_UPDATE_REQUIRED,
8393
sprintf(self::MESSAGE_UPDATE_REQUIRED, $pluginCount)
8494
];
8595
$updatedCount = 0;
96+
$builder = $this->getQueryBuilder();
8697

8798
foreach ($pluginRecords as $record) {
88-
$sortDirectionSettings = 'asc';
89-
$flexFormSettings = $this->getFlexFormSettings($record);
90-
$switchableControllerActionChanged = false;
91-
92-
if ($flexFormSettings['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'] == 'Event->calendar') {
93-
$flexFormSettings['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'] = 'Performance->calendar';
94-
$switchableControllerActionChanged = true;
95-
}
96-
if (isset($flexFormSettings['data']['sDEF']['lDEF']['settings.sortBy']['vDEF'])) {
97-
$sortBySettings = $flexFormSettings['data']['sDEF']['lDEF']['settings.sortBy']['vDEF'];
98-
}
99-
if (isset($flexFormSettings['data']['sDEF']['lDEF']['settings.sortDirection']['vDEF'])) {
100-
$sortDirectionSettings = $flexFormSettings['data']['sDEF']['lDEF']['settings.sortDirection']['vDEF'];
101-
}
102-
if (!empty($sortBySettings || $switchableControllerActionChanged)) {
103-
$flexFormSettings['data']['sDEF']['lDEF']['settings.order']['vDEF'] = $sortBySettings . '|'. $sortDirectionSettings . ',performances.begin|asc';
104-
unset($flexFormSettings['data']['sDEF']['lDEF']['settings.sortBy']);
105-
unset($flexFormSettings['data']['sDEF']['lDEF']['settings.sortDirection']);
106-
99+
$changed = 0;
100+
101+
$updatedFlexXml = str_replace(
102+
self::DEPRECATED_FLEX_KEY,
103+
self::REPLACEMENT_FLEX_KEY,
104+
$record[self::FLEX_FORM_FIELD],
105+
$changed
106+
);
107+
108+
if ($changed) {
109+
$builder->update(self::CONTENT_TABLE)
110+
->where(
111+
$builder->expr()->eq(
112+
self::ID_FIELD,
113+
$builder->createNamedParameter(
114+
$record[self::ID_FIELD], \PDO::PARAM_INT)
115+
)
116+
)
117+
->set(self::FLEX_FORM_FIELD, $updatedFlexXml)
118+
->execute();
107119
$updatedCount++;
108-
$updatedXml = $this->getFlexFormTools()->flexArray2Xml($flexFormSettings, true);
109-
110-
$this->getDatabaseConnection()->exec_UPDATEquery(
111-
self::CONTENT_TABLE,
112-
'uid=' . $record['uid'],
113-
[
114-
self::FLEX_FORM_FIELD => $updatedXml,
115-
]
116-
);
117120
}
118121
}
119122

120-
if ($updatedCount > 0) {
123+
if (0 !== $updatedCount) {
121124
$customMessages[] = [
122125
FlashMessage::INFO,
123126
self::TITLE_UPDATED,
124127
sprintf(self::MESSAGE_UPDATED, $updatedCount)
125128
];
126129
}
127130
}
128-
return $success;
131+
return true;
129132
}
130133

131134
/**
132135
* Counts plugin records with deprecated settings
133136
*
134137
* @return mixed
138+
* @codeCoverageIgnore
135139
*/
136140
public function countPluginRecordsWithDeprecatedSettings()
137141
{
138-
return $this->getDatabaseConnection()
139-
->exec_SELECTcountRows(
140-
'*',
141-
self::CONTENT_TABLE,
142-
self::DEPRECATED_PLUGIN_WHERE_CLAUSE
143-
);
142+
$builder = $this->getQueryBuilder();
143+
144+
145+
return $builder
146+
->count(self::ID_FIELD)
147+
->from(self::CONTENT_TABLE)
148+
->where(
149+
$builder->expr()->eq(
150+
self::LIST_TYPE_FIELD,
151+
$builder->createNamedParameter(self::PLUGIN_TYPE_EVENTS)
152+
))
153+
->andWhere(
154+
$builder->expr()->like(
155+
self::FLEX_FORM_FIELD,
156+
$builder->createNamedParameter('%' . self::DEPRECATED_FLEX_KEY . '%'))
157+
)
158+
->execute()->fetchColumn(0);
144159
}
145160

146161
/**
147162
* Gets plugin records with deprecated settings
148163
*
149-
* @return array | null
164+
* @return array
165+
* @codeCoverageIgnore
150166
*/
151167
public function getPluginRecordsWithDeprecatedSettings()
152168
{
153-
return $this->getDatabaseConnection()
154-
->exec_SELECTgetRows(
155-
'uid,' . self::FLEX_FORM_FIELD,
156-
self::CONTENT_TABLE,
157-
self::DEPRECATED_PLUGIN_WHERE_CLAUSE
158-
);
169+
$builder = $this->getQueryBuilder();
170+
171+
172+
return $builder
173+
->select(self::ID_FIELD, self::FLEX_FORM_FIELD)
174+
->from(self::CONTENT_TABLE)
175+
->where(
176+
$builder->expr()->eq(
177+
self::LIST_TYPE_FIELD,
178+
$builder->createNamedParameter(self::PLUGIN_TYPE_EVENTS)
179+
))
180+
->andWhere(
181+
$builder->expr()->like(
182+
self::FLEX_FORM_FIELD,
183+
$builder->createNamedParameter('%' . self::DEPRECATED_FLEX_KEY . '%'))
184+
)
185+
->execute()->fetchAll();
159186
}
160187

161188
/**
@@ -172,4 +199,10 @@ protected function getFlexFormSettings($record)
172199

173200
return $settings;
174201
}
202+
203+
public function getQueryBuilder(): QueryBuilder
204+
{
205+
return GeneralUtility::makeInstance(ConnectionPool::class)
206+
->getQueryBuilderForTable(self::CONTENT_TABLE);
207+
}
175208
}

Configuration/FlexForms/flexform_events.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@
229229
</view.pluginNamespace>
230230

231231
<!-- caching -->
232-
<settings.cache.makeNonCacheable>
232+
<settings.cache.notCacheable>
233233
<TCEforms>
234234
<label>LLL:EXT:t3events/Resources/Private/Language/locallang_be.xml:flexforms_general.cache.makeNonCacheable</label>
235235
<config>
236236
<type>check</type>
237237
</config>
238238
</TCEforms>
239-
</settings.cache.makeNonCacheable>
239+
</settings.cache.notCacheable>
240240
</el>
241241
</ROOT>
242242
</sDEF>

Configuration/TypoScript/setup.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ plugin.tx_t3events {
160160
# this setting is part of a workaround for the limits of <f:widget.paginate /> view helper - specially the missing option to localize its output
161161
#config.tx_extbase.view.widget.Tx_Fluid_ViewHelpers_Widget_PaginateViewHelper.templateRootPath = {$plugin.tx_t3events.view.templateRootPath}
162162

163-
config.tx_extbase.objects {
164-
# overwrite class to allow USER_INT from flexform
165-
TYPO3\CMS\Extbase\Service\ExtensionService {
166-
className = DWenzel\T3events\Service\ExtensionService
167-
}
168-
}
169-
170163
####################
171164
# include default CSS
172165

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,14 @@
11
Updating from previous versions
22
===============================
3-
4-
_Events_ provides an update script which performs the following tasks:
5-
* migrate _Task_ records
6-
* migrate _Plugin_ records
3+
### Migrate Event Plugin Records
4+
This script updates all _Event_ plugins by updating the flex-form XML stored in the field _pi_flexform_ of tt_content.
5+
It replaces the deprecated value `settings.cache.makeNonCacheable` with `settings.cache.notCacheable`.
76

87

98
## Usage
109
* **Important**: make sure to backup your database before executing the script.
11-
* Go to the Install Tool and perform the _Compare current database with specification_ task.
12-
* Open the Extension Manager - If the update button is shown, updates are necessary.
13-
* Hit the update button
14-
* clear all caches
15-
16-
17-
### Migrate Tasks
18-
This script updates the table _tx_t3events_domain_model_task_.
19-
It moves the content of the deprecated field _period_ to the field _period_duration_
20-
21-
22-
### Migrate Plugins
23-
This script updates all _Event_ plugins by updating the flex-form XML stored in the field _pi_flexform_ of tt_content.
24-
It replaces the deprecated values `settings.sortBy` and `settings.sortDirection` by a new field `settings.order` and the
25-
deprecated value `Event->calendar` by `Performance->calendar`.
26-
27-
**Note**: The correspondent TypoScript option are not evaluated any more. The default has been changed from:
28-
29-
```
30-
plugin.tx_t3events.settings.performance.list {
31-
sortBy = date
32-
sortDirection = asc
33-
}
34-
```
35-
to:
10+
* open the Install Tool
11+
* select "Upgrade Wizard"
12+
* execute the Wizard "Migrate Event Plugin Records" (if displayed)
3613

37-
```
38-
plugin.tx_t3events.settings.performance.list {
39-
order = date|asc,begin|asc
40-
}
41-
```
42-
Thus the time of begin is respected too.
14+
If the wizard is not displayed, no matching _Event_ plugins where found.

0 commit comments

Comments
 (0)