Skip to content

Commit ddd681f

Browse files
committed
Remove the old clean message event listener
1 parent d613e73 commit ddd681f

2 files changed

Lines changed: 1 addition & 66 deletions

File tree

event/listener.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function getSubscribedEvents()
8282
{
8383
return array(
8484
'core.viewforum_get_topic_data' => 'ideas_forum_redirect',
85-
'core.viewtopic_modify_post_row' => array(array('clean_message'), array('show_post_buttons')),
85+
'core.viewtopic_modify_post_row' => 'show_post_buttons',
8686
'core.viewtopic_modify_page_title' => 'show_idea',
8787
'core.viewtopic_add_quickmod_option_before' => 'adjust_quickmod_tools',
8888
'core.viewonline_overwrite_location' => 'viewonline_ideas',
@@ -107,31 +107,6 @@ public function ideas_forum_redirect($event)
107107
}
108108
}
109109

110-
/**
111-
* Clean obsolete link-backs from idea topics posted prior to Sep. 2017
112-
*
113-
* @param \phpbb\event\data $event The event object
114-
* @return void
115-
* @access public
116-
*/
117-
public function clean_message($event)
118-
{
119-
if (!$this->is_ideas_forum($event['row']['forum_id']))
120-
{
121-
return;
122-
}
123-
124-
if ($this->is_first_post($event['topic_data']['topic_first_post_id'], $event['row']['post_id']) && $event['topic_data']['topic_time'] < strtotime('September 1, 2017'))
125-
{
126-
// This freakish looking regex pattern should remove the old ideas link-backs from the message.
127-
$event->update_subarray(
128-
'post_row',
129-
'MESSAGE',
130-
preg_replace('/(<br[^>]*>\\n?)?\\1?-{10}\\1?\\1?(?:(?!<\/[rt]>).)*/s', '', $event['post_row']['MESSAGE'])
131-
);
132-
}
133-
}
134-
135110
/**
136111
* Show post buttons (hide delete, quote or warn user buttons)
137112
*

tests/event/listener_test.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -118,46 +118,6 @@ public function test_getSubscribedEvents()
118118
), array_keys(\phpbb\ideas\event\listener::getSubscribedEvents()));
119119
}
120120

121-
/**
122-
* Data set for test_clean_message
123-
*
124-
* @return array Array of test data
125-
*/
126-
public function clean_message_data()
127-
{
128-
return array(
129-
array(1, 1, 1, 'Foo Bar', 'Foo Bar'), // Invalid forum, nothing cleaned
130-
array(2, 1, 2, 'Foo Bar', 'Foo Bar'), // Invalid post, nothing clean
131-
array(2, 1, 1, 'Foo Bar', 'Foo Bar'), // Valid post, nothing to clean
132-
array(2, 1, 1, 'Foo Bar<br />----------<br>BarFoo<br>', 'Foo Bar'), // Valid post, requires cleaning
133-
array(2, 1, 1, 'Foo Bar<br />\n\n----------<br>\nBarFoo<br>', 'Foo Bar'), // Valid post, requires cleaning
134-
array(2, 1, 1, 'Foo Bar<br />--------<br>BarFoo<br>', 'Foo Bar<br />--------<br>BarFoo<br>'), // Valid post, nothing to clean
135-
);
136-
}
137-
138-
/**
139-
* Test the clean_message event
140-
*
141-
* @dataProvider clean_message_data
142-
*/
143-
public function test_clean_message($forum_id, $post_id, $first_post_id, $message, $expected)
144-
{
145-
$listener = $this->get_listener();
146-
147-
$event = new \phpbb\event\data(array(
148-
'row' => array(
149-
'forum_id' => $forum_id,
150-
'post_id' => $post_id,
151-
),
152-
'post_row' => array('MESSAGE' => $message),
153-
'topic_data' => array('topic_first_post_id' => $first_post_id),
154-
));
155-
156-
$listener->clean_message($event);
157-
158-
$this->assertContains($expected, $event['post_row']['MESSAGE']);
159-
}
160-
161121
/**
162122
* Data set for show_post_buttons
163123
*

0 commit comments

Comments
 (0)