-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #21855 Unable to save content of a Widget with WYSIWYG Code view
- Loading branch information
1 parent
762cefa
commit 4354bd6
Showing
7 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ava/com/dotmarketing/startup/runonce/Task230713IncreaseDisabledWysiwygColumnSizeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import com.dotcms.util.IntegrationTestInitService; | ||
import com.dotmarketing.common.db.DotDatabaseMetaData; | ||
import com.dotmarketing.exception.DotDataException; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.sql.SQLException; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Verifies that the Upgrade Task {@link Task230713IncreaseDisabledWysiwygColumnSize} is working as expected. | ||
* | ||
* @author Jose Castro | ||
* @since Jul 13th, 2023 | ||
*/ | ||
public class Task230713IncreaseDisabledWysiwygColumnSizeTest { | ||
|
||
@BeforeClass | ||
public static void prepare() throws Exception { | ||
IntegrationTestInitService.getInstance().init(); | ||
} | ||
|
||
/** | ||
* <ul> | ||
* <li><b>Method to test: </b>{@link Task230713IncreaseDisabledWysiwygColumnSize#executeUpgrade()}</li> | ||
* <li><b>Given Scenario: </b>Verifies that the {@code contentlet.disabled_wysiwyg} has a size of 1000 now.</li> | ||
* <li><b>Expected Result: </b>The column size must be the expected one.</li> | ||
* </ul> | ||
*/ | ||
@Test | ||
public void executeTaskUpgrade() throws DotDataException, SQLException { | ||
final Task230713IncreaseDisabledWysiwygColumnSize task = new Task230713IncreaseDisabledWysiwygColumnSize(); | ||
task.executeUpgrade(); | ||
final Map<String, String> columnData = new DotDatabaseMetaData().getModifiedColumnLength("contentlet", | ||
"disabled_wysiwyg"); | ||
assertEquals("Column 'contentlet.disabled_wysiwyg' must have a length of 1000, Column 'contentlet" + | ||
".disabled_wysiwyg' must have a length of 1000", "1000", columnData.get("field_length")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...in/java/com/dotmarketing/startup/runonce/Task230713IncreaseDisabledWysiwygColumnSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import com.dotcms.business.WrapInTransaction; | ||
import com.dotmarketing.common.db.DotConnect; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.exception.DotRuntimeException; | ||
import com.dotmarketing.startup.StartupTask; | ||
|
||
/** | ||
* This Upgrade Task increases the size of the {@code contentlet.disabled_wysiwyg} column to 1000. | ||
* <p>This column stores the velocity variable names -- and their respective separation characters -- of the WYSIWYG and | ||
* Text Area fields whose view mode has been changed. For example: | ||
* <ul> | ||
* <li>View Modes for WYSIWYG: {@code WYSIWYG}, {@code CODE}, and {@code PLAIN}.</li> | ||
* <li>View Modes for Text Area: {@code Toggle Editor} and "normal" editor.</li> | ||
* </ul> | ||
* In case customers have a Content Type with several of those fields, dotCMS will hit a database problem due to the | ||
* column not being able to hold a String longer than the original 255 limit. This upgrade Task fixes such a situation. | ||
* </p> | ||
* | ||
* @author Jose Castro | ||
* @since Jul 13th, 2023 | ||
*/ | ||
public class Task230713IncreaseDisabledWysiwygColumnSize implements StartupTask { | ||
|
||
@Override | ||
public boolean forceRun() { | ||
return true; | ||
} | ||
|
||
@Override | ||
@WrapInTransaction | ||
public void executeUpgrade() throws DotDataException, DotRuntimeException { | ||
new DotConnect().setSQL("ALTER TABLE contentlet ALTER COLUMN disabled_wysiwyg TYPE VARCHAR(1000)").loadResult(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters