mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.2.x'
This commit is contained in:
commit
c0fb367d0a
4 changed files with 48 additions and 8 deletions
|
@ -136,4 +136,17 @@ class utils implements \phpbb\textformatter\utils_interface
|
||||||
{
|
{
|
||||||
return \s9e\TextFormatter\Unparser::unparse($xml);
|
return \s9e\TextFormatter\Unparser::unparse($xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function is_empty($text)
|
||||||
|
{
|
||||||
|
if ($text === null || $text === '')
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($this->unparse($text)) === '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,12 @@ interface utils_interface
|
||||||
* @return string Original plain text
|
* @return string Original plain text
|
||||||
*/
|
*/
|
||||||
public function unparse($text);
|
public function unparse($text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether or not a parsed text represent an empty text.
|
||||||
|
*
|
||||||
|
* @param string $text Parsed text
|
||||||
|
* @return bool Tue if the original text is empty
|
||||||
|
*/
|
||||||
|
public function is_empty($text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -816,6 +816,7 @@ if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_
|
||||||
load_drafts($topic_id, $forum_id);
|
load_drafts($topic_id, $forum_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bbcode_utils = $phpbb_container->get('text_formatter.utils');
|
||||||
|
|
||||||
if ($submit || $preview || $refresh)
|
if ($submit || $preview || $refresh)
|
||||||
{
|
{
|
||||||
|
@ -1178,7 +1179,7 @@ if ($submit || $preview || $refresh)
|
||||||
$post_data['poll_title'] = '';
|
$post_data['poll_title'] = '';
|
||||||
$post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0;
|
$post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0;
|
||||||
}
|
}
|
||||||
else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && ($original_poll_data['poll_title'] != ''))
|
else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && !$bbcode_utils->is_empty($original_poll_data['poll_title']))
|
||||||
{
|
{
|
||||||
// We have a poll but the editing user is not permitted to create/edit it.
|
// We have a poll but the editing user is not permitted to create/edit it.
|
||||||
// So we just keep the original poll-data.
|
// So we just keep the original poll-data.
|
||||||
|
@ -1601,7 +1602,7 @@ if ($generate_quote)
|
||||||
|
|
||||||
if ($config['allow_bbcode'])
|
if ($config['allow_bbcode'])
|
||||||
{
|
{
|
||||||
$message_parser->message = $phpbb_container->get('text_formatter.utils')->generate_quote(
|
$message_parser->message = $bbcode_utils->generate_quote(
|
||||||
censor_text($message_parser->message),
|
censor_text($message_parser->message),
|
||||||
array(
|
array(
|
||||||
'author' => $post_data['quote_username'],
|
'author' => $post_data['quote_username'],
|
||||||
|
@ -1639,7 +1640,7 @@ $attachment_data = $message_parser->attachment_data;
|
||||||
$filename_data = $message_parser->filename_data;
|
$filename_data = $message_parser->filename_data;
|
||||||
$post_data['post_text'] = $message_parser->message;
|
$post_data['post_text'] = $message_parser->message;
|
||||||
|
|
||||||
if (sizeof($post_data['poll_options']) || !empty($post_data['poll_title']))
|
if (sizeof($post_data['poll_options']) || (isset($post_data['poll_title']) && !$bbcode_utils->is_empty($post_data['poll_title'])))
|
||||||
{
|
{
|
||||||
$message_parser->message = $post_data['poll_title'];
|
$message_parser->message = $post_data['poll_title'];
|
||||||
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
||||||
|
|
|
@ -86,6 +86,24 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||||
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://tracker.phpbb.com/browse/PHPBB3-14962
|
||||||
|
*/
|
||||||
|
public function test_edit()
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
$this->create_topic(2, 'Test Topic post', 'Test topic post');
|
||||||
|
|
||||||
|
$url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri();
|
||||||
|
$post_id = $this->get_parameter_from_link($url, 'p');
|
||||||
|
$crawler = self::request('GET', "posting.php?mode=edit&f=2&p={$post_id}&sid={$this->sid}");
|
||||||
|
$form = $crawler->selectButton('Submit')->form();
|
||||||
|
$form->setValues(array('message' => 'Edited post'));
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
|
||||||
|
$this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox max_quote_depth is applied to the text populating the posting form
|
* @testdox max_quote_depth is applied to the text populating the posting form
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue