Skip to content

Commit

Permalink
Fix #21855 Unable to save content of a Widget with WYSIWYG Code view
Browse files Browse the repository at this point in the history
  • Loading branch information
jcastro-dotcms authored and manuelrojas committed Jul 20, 2023
1 parent 762cefa commit 4354bd6
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dotCMS/src/integration-test/java/com/dotcms/MainSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
import com.dotmarketing.startup.runonce.Task230426AlterVarcharLengthOfLockedByColTest;
import com.dotmarketing.startup.runonce.Task230701AddHashIndicesToWorkflowTablesTest;
import com.dotmarketing.startup.runonce.Task230523CreateVariantFieldInContentletIntegrationTest;
import com.dotmarketing.startup.runonce.Task230713IncreaseDisabledWysiwygColumnSizeTest;
import com.dotmarketing.util.ConfigTest;
import com.dotmarketing.util.HashBuilderTest;
import com.dotmarketing.util.MaintenanceUtilTest;
Expand Down Expand Up @@ -662,7 +663,8 @@
ContentPageIntegrityCheckerTest.class,
AssetPathResolverImplIntegrationTest.class,
WebAssetHelperIntegrationTest.class,
Task230701AddHashIndicesToWorkflowTablesTest.class
Task230701AddHashIndicesToWorkflowTablesTest.class,
Task230713IncreaseDisabledWysiwygColumnSizeTest.class
})

public class MainSuite {
Expand Down
4 changes: 3 additions & 1 deletion dotCMS/src/integration-test/java/com/dotcms/MainSuite2b.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
import com.dotmarketing.startup.runonce.Task230328AddMarkedForDeletionColumnTest;
import com.dotmarketing.startup.runonce.Task230426AlterVarcharLengthOfLockedByColTest;
import com.dotmarketing.startup.runonce.Task230701AddHashIndicesToWorkflowTablesTest;
import com.dotmarketing.startup.runonce.Task230713IncreaseDisabledWysiwygColumnSizeTest;
import com.dotmarketing.util.MaintenanceUtilTest;
import com.dotmarketing.util.ResourceCollectorUtilTest;
import com.dotmarketing.util.UtilMethodsITest;
Expand Down Expand Up @@ -307,7 +308,8 @@
CMSUrlUtilTest.class,
AssetPathResolverImplIntegrationTest.class,
WebAssetHelperIntegrationTest.class,
Task230701AddHashIndicesToWorkflowTablesTest.class
Task230701AddHashIndicesToWorkflowTablesTest.class,
Task230713IncreaseDisabledWysiwygColumnSizeTest.class
})

public class MainSuite2b {
Expand Down
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"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static Optional<Folder> resolveWithFieldVariable(final Field field, fina
? Optional.of(folderByPath) : Optional.empty();
}
} else {
Logger.warn(BrowserUtil.class, () -> "defaultPath variable not exists for field " + field.name());
Logger.debug(BrowserUtil.class, () -> "defaultPath variable not exists for field " + field.name());
return Optional.empty();
}
} catch (DotSecurityException | DotDataException e) {
Expand Down
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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
import com.dotmarketing.startup.runonce.Task230701AddHashIndicesToWorkflowTables;
import com.dotmarketing.startup.runonce.Task230523CreateVariantFieldInContentlet;
import com.dotmarketing.startup.runonce.Task230630CreateRunningIdsExperimentField;
import com.dotmarketing.startup.runonce.Task230713IncreaseDisabledWysiwygColumnSize;
import com.google.common.collect.ImmutableList;

import java.util.ArrayList;
Expand Down Expand Up @@ -546,6 +547,7 @@ public static List<Class<?>> getStartupRunOnceTaskClasses() {
.add(Task230523CreateVariantFieldInContentlet.class)
.add(Task230630CreateRunningIdsExperimentField.class)
.add(Task230701AddHashIndicesToWorkflowTables.class)
.add(Task230713IncreaseDisabledWysiwygColumnSize.class)
.build();
return ret.stream().sorted(classNameComparator).collect(Collectors.toList());
}
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/resources/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ create table contentlet (inode varchar(36) not null,
sort_order int4,
friendly_name varchar(255),
structure_inode varchar(36),
disabled_wysiwyg varchar(255),
disabled_wysiwyg varchar(1000),
identifier varchar(36),
language_id int8,
variant_id varchar(255) default 'DEFAULT',
Expand Down

0 comments on commit 4354bd6

Please sign in to comment.