This is an automated email from the ASF dual-hosted git repository.

mraible pushed a commit to branch roller-6.1.x
in repository https://gitbox.apache.org/repos/asf/roller.git


The following commit(s) were added to refs/heads/roller-6.1.x by this push:
     new 858ae819e Check and clear site.frontpage.weblog.handle on weblog 
delete (#247)
858ae819e is described below

commit 858ae819e45024d8e5deee4e527ecb359be27112
Author: gregh3269 <[email protected]>
AuthorDate: Sun Nov 15 19:32:56 2026 +0000

    Check and clear site.frontpage.weblog.handle on weblog delete (#247)
    
    * clear property site.frontpage.weblog.handle if deleting weblog
    
    * Add changes.md
    
    * Forgot 6.1.7 was released
    
    * Use weblog handle instead of properties/lookup value.
    
    * Clear the front page handle without a separate check, and test it
    
    compareAndSetProperty already changes the handle only when it still names 
the deleted weblog, so the isFrontPageWeblog check (which throws when the 
property is missing) and the unused imports go. The CHANGES.md entry now 
describes what users see.
    
    ---------
    
    Co-authored-by: Greg Huber <[email protected]>
    Co-authored-by: David M. Johnson <[email protected]>
    Co-authored-by: Matt Raible <[email protected]>
---
 CHANGES.md                                         |  4 +++
 .../business/jpa/JPAWeblogManagerImpl.java         |  7 +++++
 .../roller/weblogger/business/WeblogTest.java      | 36 +++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 0fb3e3903..036f9060f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -25,6 +25,10 @@
   result, the same way the rest of the page shows titles. A title saved with
   `&amp;` no longer turns into `&amp;amp;`, and the calendar cuts long titles
   at 20 visible characters.
+- **Deleting the front page weblog brings back the welcome page.** The site
+  kept pointing at the deleted weblog's handle, so the front page broke until
+  an admin chose another weblog. The setting is now cleared when that weblog is
+  deleted.
 - **Meta descriptions are always encoded.** A weblog's "about" text or an
   entry's search description containing a quote no longer cuts the
   `<meta name="description">` tag short, whether or not weblog admins are
diff --git 
a/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
 
b/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
index d4304b458..b7baeab87 100644
--- 
a/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
+++ 
b/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
@@ -39,6 +39,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.roller.weblogger.business.FrontpageSettings;
 import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
@@ -110,6 +111,12 @@ public class JPAWeblogManagerImpl implements WeblogManager 
{
         
         // remove contents first, then remove weblog
         this.removeWeblogContents(weblog);
+
+        // if this was the front page weblog, clear the setting so the site
+        // shows the welcome page instead of a weblog that no longer exists
+        roller.getPropertiesManager().compareAndSetProperty(
+                FrontpageSettings.HANDLE_PROPERTY, weblog.getHandle(), "");
+
         this.strategy.remove(weblog);
         
         // remove entry from cache mapping
diff --git 
a/app/src/test/java/org/apache/roller/weblogger/business/WeblogTest.java 
b/app/src/test/java/org/apache/roller/weblogger/business/WeblogTest.java
index e21ac3d51..1b25bf501 100644
--- a/app/src/test/java/org/apache/roller/weblogger/business/WeblogTest.java
+++ b/app/src/test/java/org/apache/roller/weblogger/business/WeblogTest.java
@@ -20,6 +20,7 @@ package org.apache.roller.weblogger.business;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.junit.jupiter.api.AfterEach;
@@ -229,5 +230,38 @@ public class WeblogTest  {
         log.info("END");
     }
     
-}
+    /**
+     * Deleting the front page weblog clears the front page setting, so the
+     * site shows the welcome page instead of a weblog that no longer exists.
+     */
+    @Test
+    public void removingTheFrontPageWeblogClearsTheSetting() throws Exception {
+        PropertiesManager pmgr = 
WebloggerFactory.getWeblogger().getPropertiesManager();
+        RuntimeConfigProperty prop = 
pmgr.getProperty(FrontpageSettings.HANDLE_PROPERTY);
+        String original = prop.getValue();
+        try {
+            Weblog front = TestUtils.setupWeblog("frontWeblog", testUser);
+            Weblog other = TestUtils.setupWeblog("otherWeblog", testUser);
+            prop = pmgr.getProperty(FrontpageSettings.HANDLE_PROPERTY);
+            prop.setValue(front.getHandle());
+            pmgr.saveProperty(prop);
+            TestUtils.endSession(true);
+
+            // another weblog leaves the setting alone
+            TestUtils.teardownWeblog(other.getId());
+            TestUtils.endSession(true);
+            assertEquals(front.getHandle(),
+                    
pmgr.getProperty(FrontpageSettings.HANDLE_PROPERTY).getValue());
 
+            TestUtils.teardownWeblog(front.getId());
+            TestUtils.endSession(true);
+            assertEquals("", 
pmgr.getProperty(FrontpageSettings.HANDLE_PROPERTY).getValue());
+        } finally {
+            prop = pmgr.getProperty(FrontpageSettings.HANDLE_PROPERTY);
+            prop.setValue(original);
+            pmgr.saveProperty(prop);
+            TestUtils.endSession(true);
+        }
+    }
+    
+}

Reply via email to