Skip to content

Commit

Permalink
#25891 include in 23.10.24
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Mar 5, 2024
1 parent e5d8821 commit bc88893
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ This maintenance release includes the following code fixes:
61. https://github.com/dotCMS/core/issues/25296 : Limited users cannot create content types on System Host #25296
62. https://github.com/dotCMS/core/issues/26542 : Hide the download button for bundles pushed to static environments #26542
63. https://github.com/dotCMS/core/issues/26415 : Template Builder: System Template should create layout always #26415
64. https://github.com/dotCMS/core/issues/22385 : Custom templates should push with their page no matter the filter that is selected #22385
64. https://github.com/dotCMS/core/issues/22385 : Custom templates should push with their page no matter the filter that is selected #22385
65. https://github.com/dotCMS/core/issues/25891 : [Empty Starter] : The Language Variable Content Type is not visible from the Content portlet #25891
3 changes: 2 additions & 1 deletion dotCMS/src/integration-test/java/com/dotcms/MainSuite2a.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@
IdentityProviderConfigurationFactoryTest.class,
EMAWebInterceptorTest.class,
GoogleTranslationServiceIntegrationTest.class,
Task240102AlterVarcharLengthOfRelationTypeTest.class
Task240102AlterVarcharLengthOfRelationTypeTest.class,
Task240131UpdateLanguageVariableContentTypeTest.class
})

public class MainSuite2a {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.dotmarketing.startup.runonce;

import com.dotcms.contenttype.exception.NotFoundInDbException;
import com.dotcms.languagevariable.business.LanguageVariableAPI;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.CacheLocator;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import org.junit.BeforeClass;
import org.junit.Test;

import java.sql.SQLException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class Task240131UpdateLanguageVariableContentTypeTest {
@BeforeClass
public static void prepare() throws Exception {
// Setting web app environment
IntegrationTestInitService.getInstance().init();
}

@Test
public void testExecuteUpgrade() throws DotDataException, SQLException, DotSecurityException {
try {
APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE);
}catch (NotFoundInDbException e){
//Create LanguageVariable Content Type in case doesn't exist
Task04210CreateDefaultLanguageVariable upgradeTaskCreateLanguageVariable = new Task04210CreateDefaultLanguageVariable();
upgradeTaskCreateLanguageVariable.executeUpgrade();
}
//Update system to true in case it's false
final DotConnect dc = new DotConnect();
dc.setSQL("update structure set system = true where velocity_var_name = ?");
dc.addParam(LanguageVariableAPI.LANGUAGEVARIABLE);
dc.loadResult();
//Flush cache to get latest changes
CacheLocator.getContentTypeCache2().clearCache();
//System must be true
assertTrue(APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE).system());
//Run UT
Task240131UpdateLanguageVariableContentType upgradeTask = new Task240131UpdateLanguageVariableContentType();
upgradeTask.executeUpgrade();
//Flush cache to get latest changes
CacheLocator.getContentTypeCache2().clearCache();
//System must be false
assertFalse(APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE).system());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.dotmarketing.startup.runonce;

import com.dotcms.languagevariable.business.LanguageVariableAPI;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.startup.StartupTask;

/**
* This UT is to update the column system for the Language Variable Content Type. This value needs to be false
* since system content types are being hidden from the Content Search Portlet.
*/
public class Task240131UpdateLanguageVariableContentType implements StartupTask {
@Override
public boolean forceRun() {
return true;
}

@Override
public void executeUpgrade() throws DotDataException, DotRuntimeException {
final DotConnect dc = new DotConnect();
dc.setSQL("update structure set system = false where velocity_var_name = ?");
dc.addParam(LanguageVariableAPI.LANGUAGEVARIABLE);
dc.loadResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ public static List<Class<?>> getBackportedUpgradeTaskClasses() {
ret.add(Task231207AddInodeAndIdentifierLeftIndexes.class);
ret.add(Task231109AddPublishDateToContentletVersionInfo.class);
ret.add(Task240102AlterVarcharLengthOfRelationType.class);
ret.add(Task240131UpdateLanguageVariableContentType.class);
return ret.stream().sorted(classNameComparator).collect(Collectors.toList());
}

Expand Down

0 comments on commit bc88893

Please sign in to comment.