Warning in logs: "No theme found for specified theme id" after uninstalling a theme
Written By
Daniel Martinez Cisneros
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Resolution
- Use a Groovy script to update the theme for the affected personal sites. When a theme is uninstalled, the theme for the pages or page sets using it is not automatically updated and must be modified manually or with a Groovy script.
import com.liferay.portal.kernel.service.LayoutLocalServiceUtil
import com.liferay.portal.kernel.service.LayoutSetLocalServiceUtil
// Define the theme IDs
def oldThemeId = "yourOld_WAR_theme"
def newThemeId = "yourNew_WAR_theme"
def dryRun = true
def layouts = LayoutLocalServiceUtil.getLayouts(-1, -1)
layouts.each { layout -
def themeId = layout.getThemeId()
if (themeId == oldThemeId) {
println "Found layout using oldThemeId - Layout ID: ${layout.getPlid()}; friendlyURL: ${layout.getFriendlyURL()}; Theme ID: ${themeId}"
if (!dryRun) {
// Switch to the new theme
layout.setThemeId(newThemeId)
// Update the layout to save changes
LayoutLocalServiceUtil.updateLayout(layout)
}
}
}
def layoutSets = LayoutSetLocalServiceUtil.getLayoutSets(-1, -1)
layoutSets.each { layoutSet -
def themeId = layoutSet.getThemeId()
if (themeId == oldThemeId) {
println "Found layoutSet using oldThemeId - LayoutSet ID: ${layoutSet.getLayoutSetId()}; Theme ID: ${themeId}"
if (!dryRun) {
layoutSet.setThemeId(newThemeId)
LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet)
}
}
}
Did this article resolve your issue ?