Skip to content

Commit 9463cd8

Browse files
boneliferclaude
andauthored
Clean up the event listener and note the CLI cache purge in the README (#3)
The constructor stored the root path in an undeclared $root_path, while the include used $phpbb_root_path; the include also read $this->phpEx instead of $this->php_ext, and was guarded by function_exists('markread') (always defined) instead of the update_post_information() it needs. Also cast the ids in the two UPDATE queries and fix the $db docblock type. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 324ffef commit 9463cd8

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ This extension was renamed from `editedposts_unread` to `editedpostsunread` to m
2424
2. Delete the `/ext/phpbbmodders/editedposts_unread` folder.
2525
3. Upload this version to `/ext/phpbbmodders/editedpostsunread` and enable it. The old install's migration history is moved to the new name automatically.
2626
4. Purge the board cache.
27+
28+
If you disable the old extension from the command line (`bin/phpbbcli.php`) instead of the ACP, run `bin/phpbbcli.php cache:purge` before enabling the new one; the command-line disable doesn't clear the cache.

‎event/listener.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class listener implements EventSubscriberInterface
2020
{
21-
/** @var \phpbb\db\driver\driver */
21+
/** @var \phpbb\db\driver\driver_interface */
2222
protected $db;
2323

2424
/** @var string phpBB root path */
@@ -30,7 +30,7 @@ class listener implements EventSubscriberInterface
3030
public function __construct(\phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext)
3131
{
3232
$this->db = $db;
33-
$this->root_path = $phpbb_root_path;
33+
$this->phpbb_root_path = $phpbb_root_path;
3434
$this->php_ext = $php_ext;
3535
}
3636

@@ -63,18 +63,18 @@ public function submit_post_end($event)
6363
{
6464
$sql_update_posts = 'UPDATE ' . POSTS_TABLE . '
6565
SET post_time = ' . time() . '
66-
WHERE post_id = ' . $event['data']['post_id'] . '
67-
AND topic_id = ' . $event['data']['topic_id'];
66+
WHERE post_id = ' . (int) $event['data']['post_id'] . '
67+
AND topic_id = ' . (int) $event['data']['topic_id'];
6868
$this->db->sql_query($sql_update_posts);
6969

7070
$sql_update_topics = 'UPDATE ' . TOPICS_TABLE . '
7171
SET topic_last_post_time = ' . time() . '
72-
WHERE topic_id = ' . $event['data']['topic_id'];
72+
WHERE topic_id = ' . (int) $event['data']['topic_id'];
7373
$this->db->sql_query($sql_update_topics);
7474

75-
if (!function_exists('markread'))
75+
if (!function_exists('update_post_information'))
7676
{
77-
include ($this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx);
77+
include ($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext);
7878
}
7979

8080
update_post_information('forum', $event['data']['forum_id']);

0 commit comments

Comments
 (0)