Răsfoiți Sursa

Timeline: the guests' home page outline comes inactive on a new install (#5904)

Enabling Timeline added its public outline (the masonry of recent posts) to
the guests' home page as an active block. A new site has no posts, so the
block showed an empty or test-only feed under the welcome cover. It is now
added inactive; Studio's page builder can turn it on.

Members' home feed (Views timeline) and NEO's API-only home feed blocks are
unchanged, as is the outline on Timeline's own page.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 1 zi în urmă
părinte
comite
dc5c78dccd

+ 2 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -58,10 +58,11 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_post_home', '_bx_timeline_page_block_title_post_home', 11, 0, 2147483644, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:19:"get_block_post_home";}', 0, 1, 0, @iPBOrderHome + 1),
 ('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_views_timeline', '_bx_timeline_page_block_title_views_timeline', 11, 1, 2147483644, 'service', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:24:"get_block_views_timeline";s:6:"params";a:1:{i:0;s:4:"feed";}}', 0, 0, 1, @iPBOrderHome + 2);
 
+-- The public outline on the guests' home page comes inactive: a new site has no posts to show yet. Studio can turn it on.
 SET @iPBCellHome = 5;
 SET @iPBOrderHome = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_pages_blocks` WHERE `object` = 'sys_home' AND `cell_id` = @iPBCellHome ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
-('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_view_home_outline', '_bx_timeline_page_block_title_view_home_outline', 0, 1, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_block_view_home_outline";}', 0, 0, 1, @iPBOrderHome + 1);
+('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_view_home_outline', '_bx_timeline_page_block_title_view_home_outline', 0, 1, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_block_view_home_outline";}', 0, 0, 0, @iPBOrderHome + 1);
 
 -- PAGES: add page block to profiles modules (trigger* page objects are processed separately upon modules enable/disable)
 SET @iPBCellProfile = 2;

+ 34 - 0
tests/units/modules/boonex/timeline/install/TimelineEnableSqlTest.php

@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * Defaults the Timeline module's enable.sql gives a fresh install. Read from the SQL itself, so a site whose admin
+ * changed a block in Studio does not fail the suite.
+ */
+class TimelineEnableSqlTest extends \PHPUnit\Framework\TestCase
+{
+    private static function enableSql(): string
+    {
+        $sSql = file_get_contents(__DIR__ . '/../../../../../../modules/boonex/timeline/install/sql/enable.sql');
+        if ($sSql === false)
+            self::fail('modules/boonex/timeline/install/sql/enable.sql is not readable.');
+
+        return $sSql;
+    }
+
+    public function testHomeOutlineIsInactive(): void
+    {
+        // The guests' home page outline: deletable, copyable, active and order end the row.
+        $bFound = preg_match("/\\('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_view_home_outline', [^\\n]*?get_block_view_home_outline[^']*', (\\d+), (\\d+), (\\d+), @iPBOrderHome \\+ 1\\);/", self::enableSql(), $aMatch);
+
+        $this->assertSame(1, $bFound, 'enable.sql adds the outline block to the home page.');
+        $this->assertSame(0, (int)$aMatch[3], 'It comes inactive: a new site has no posts to show; Studio can turn it on.');
+    }
+
+    public function testMembersHomeFeedStaysActive(): void
+    {
+        $bFound = preg_match("/\\('sys_home', @iPBCellHome, 'bx_timeline', '_bx_timeline_page_block_title_system_views_timeline', [^\\n]*?, (\\d+), @iPBOrderHome \\+ 2\\);/", self::enableSql(), $aMatch);
+
+        $this->assertSame(1, $bFound, 'enable.sql adds the members\' feed to the home page.');
+        $this->assertSame(1, (int)$aMatch[1], 'Members keep their feed on the home page.');
+    }
+}