diff --git a/.travis.yml b/.travis.yml index 8132f922..6667111b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ matrix: env: DB=mysqli - php: 7.0 env: DB=mysqli + - php: 7.1 + env: DB=mysqli allow_failures: - php: hhvm fast_finish: true @@ -37,7 +39,7 @@ env: - COVERAGE="1" # Should we send coverage? - EPV="1" # Should we run EPV (Extension Pre Validator) on your code? - SPELLCHECK="1" # Should the php files be checked for obvious spelling errors? - - PHPBB_BRANCH="master" + - PHPBB_BRANCH="3.2.x" branches: except: diff --git a/composer.json b/composer.json index 235778c3..36045899 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }], "require": { "php": ">=5.3.9", - "nickvergessen/phpbb-tool-trimmessage": "1.3.*" + "marc1706/phpbb-text-shortener": "^0.1.0" }, "require-dev": { "phpbb/epv": "dev-master" diff --git a/composer.lock b/composer.lock index 35426b80..23bcc88a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,49 +4,62 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "16fa7b983ba4704c2b4fb11611f8c1d7", + "hash": "f79966a0c35657dc6831652d3a8b0f6e", + "content-hash": "eec8e152b8e3363ee143a27bf2481202", "packages": [ { - "name": "nickvergessen/phpbb-tool-trimmessage", - "version": "1.3.1", + "name": "marc1706/phpbb-text-shortener", + "version": "v0.1.0", "source": { "type": "git", - "url": "https://github.com/nickv-phpbb/phpbb-tool-trimmessage.git", - "reference": "0ed883bc2d473ec2e84cabb9c9395785daeeebcf" + "url": "https://github.com/marc1706/phpbb-text-shortener.git", + "reference": "c698ea6e7527513e8ac98f385e076cdbc405a5d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nickv-phpbb/phpbb-tool-trimmessage/zipball/0ed883bc2d473ec2e84cabb9c9395785daeeebcf", - "reference": "0ed883bc2d473ec2e84cabb9c9395785daeeebcf", + "url": "https://api.github.com/repos/marc1706/phpbb-text-shortener/zipball/c698ea6e7527513e8ac98f385e076cdbc405a5d2", + "reference": "c698ea6e7527513e8ac98f385e076cdbc405a5d2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "4.1.*" + "phpunit/phpunit": "4.*", + "symfony/yaml": "~2.8" }, "type": "library", "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Marc1706\\TextShortener\\": "src", + "Marc1706\\TextShortener\\tests\\": "tests" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-2.0" + "MIT" ], "authors": [ { - "name": "Joas Schilling", - "email": "nickvergessen@gmx.de", - "homepage": "https://github.com/nickvergessen", + "name": "Marc Alexander", + "email": "admin@m-a-styles.de", + "homepage": "https://www.m-a-styles.de", "role": "Developer" } ], - "description": "This tool contains a class, that is able to trim a message from the phpbb message_parser to a maximum length without breaking the bbcodes/smilies and links.", - "homepage": "https://github.com/nickvergessen/phpbb-tool-trimmessage", - "time": "2015-04-17 16:41:50" + "description": "Library for shortening post text in phpBB 3.2.x", + "homepage": "https://www.m-a-styles.de", + "keywords": [ + "bbcode", + "extension", + "extensions", + "minify", + "php", + "phpbb", + "post", + "shortening" + ], + "time": "2016-01-10 11:01:04" } ], "packages-dev": [ @@ -157,7 +170,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbb/epv/zipball/d837a835dfdfdac233854d9e50d58565542764cb", + "url": "https://api.github.com/repos/phpbb/epv/zipball/87c89df9560431910fa9027a8129a9efac362ba4", "reference": "75df9936ffbb8f05a1351cf622cf6f41c7d2d9f2", "shasum": "" }, @@ -246,12 +259,12 @@ "target-dir": "Symfony/Component/Console", "source": { "type": "git", - "url": "https://github.com/symfony/Console.git", + "url": "https://github.com/symfony/console.git", "reference": "53f86497ccd01677e22435cfb7262599450a90d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/53f86497ccd01677e22435cfb7262599450a90d1", + "url": "https://api.github.com/repos/symfony/console/zipball/53f86497ccd01677e22435cfb7262599450a90d1", "reference": "53f86497ccd01677e22435cfb7262599450a90d1", "shasum": "" }, @@ -457,7 +470,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "platform-dev": [] } diff --git a/modules/calendar.php b/modules/calendar.php index ebf0491d..4d134abe 100644 --- a/modules/calendar.php +++ b/modules/calendar.php @@ -281,6 +281,9 @@ class calendar extends module_base foreach ($events as $key => $cur_event) { + $cur_event['start_time'] = (int) $cur_event['start_time']; + $cur_event['end_time'] = (int) $cur_event['end_time']; + if (($cur_event['start_time'] + $this->time->getOffset()) >= $today_timestamp || ($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp || (($cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day'])) diff --git a/modules/welcome.php b/modules/welcome.php index ad86bc98..cb7d8f1a 100644 --- a/modules/welcome.php +++ b/modules/welcome.php @@ -219,7 +219,7 @@ class welcome extends module_base default: if (!isset($welcome_message)) { - $welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], ''); + $welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], 0); } $this->template->assign_vars(array( diff --git a/portal/fetch_posts.php b/portal/fetch_posts.php index 6dc7f46f..53971889 100644 --- a/portal/fetch_posts.php +++ b/portal/fetch_posts.php @@ -134,7 +134,7 @@ class fetch_posts public function get_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0, $invert = false) { $posts = array(); - $post_time = $this->get_setting_based_data($time == 0, '', 'AND t.topic_time > ' . (time() - $time * 86400)); + $post_time = $this->get_setting_based_data($time == 0, '', 'AND t.topic_time > ' . (time() - (int) $time * 86400)); $forum_from = $this->get_setting_based_data(strpos($forum_from, ',') !== false, explode(',', $forum_from), $this->get_setting_based_data($forum_from != '', array($forum_from), array())); $topic_icons = array(0); $have_icons = 0; @@ -298,7 +298,9 @@ class fetch_posts // Format message $message = $this->format_message($row, $text_length, $posts[$i]['striped']); - $row['bbcode_options'] = $this->get_setting_based_data($row['enable_bbcode'], OPTION_FLAG_BBCODE, 0) + $this->get_setting_based_data($row['enable_smilies'], OPTION_FLAG_SMILIES, 0) + $this->get_setting_based_data($row['enable_magic_url'], OPTION_FLAG_LINKS, 0); + $row['bbcode_options'] = (int) $this->get_setting_based_data($row['enable_bbcode'], OPTION_FLAG_BBCODE, 0) + + (int) $this->get_setting_based_data($row['enable_smilies'], OPTION_FLAG_SMILIES, 0) + + (int) $this->get_setting_based_data($row['enable_magic_url'], OPTION_FLAG_LINKS, 0); $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']); if (!empty($attachments)) @@ -649,10 +651,11 @@ class fetch_posts */ public function shorten_message($message, $bbcode_uid, $length) { - if (class_exists('\Nickvergessen\TrimMessage\TrimMessage')) + if (class_exists('\Marc1706\TextShortener\Shortener')) { - $trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length); - $message = $trim->message(); + $trim = new \Marc1706\TextShortener\Shortener(); + $message = $trim->setText($message) + ->shortenText($length); unset($trim); } diff --git a/tests/functional/portal_announcement_test.php b/tests/functional/portal_announcement_test.php index da178cad..0c2b07dc 100644 --- a/tests/functional/portal_announcement_test.php +++ b/tests/functional/portal_announcement_test.php @@ -60,8 +60,6 @@ class phpbb_functional_portal_announcement_test extends \board3\portal\tests\tes public function test_shortened_message() { - $this->markTestIncomplete('Trim message tool no longer works correctly for new posts in 3.2.x'); - // Create topic as announcement $data = $this->create_topic(2, 'Portal-announce-global', str_repeat('This is a global announcement for the portal', 6), array( 'topic_type' => POST_GLOBAL, @@ -71,7 +69,7 @@ class phpbb_functional_portal_announcement_test extends \board3\portal\tests\tes { // no errors should appear on portal $crawler = self::request('GET', 'app.php/portal'); - $this->assertContains('This is a global announc [...]', $crawler->text()); + $this->assertContains('This is a global announc ...', $crawler->text()); } } } diff --git a/tests/unit/event/listener_test.php b/tests/unit/event/listener_test.php index e4ad96e0..a2c2f4ae 100644 --- a/tests/unit/event/listener_test.php +++ b/tests/unit/event/listener_test.php @@ -59,8 +59,7 @@ class listener_test extends \phpbb_template_template_test_case $manager = new \phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $finder = new \phpbb\finder( new \phpbb\filesystem\filesystem(), - dirname(__FILE__) . '/', - new \phpbb_mock_cache() + dirname(__FILE__) . '/' ); $finder->set_extensions(array_keys($manager->all_enabled())); $request = new \phpbb_mock_request(); diff --git a/tests/unit/includes/modules_helper_test.php b/tests/unit/includes/modules_helper_test.php index bd56ac50..61cd31eb 100644 --- a/tests/unit/includes/modules_helper_test.php +++ b/tests/unit/includes/modules_helper_test.php @@ -26,7 +26,7 @@ class board3_includes_modules_helper_test extends \board3\portal\tests\testframe public function setUp() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_dispatcher; parent::setUp(); @@ -37,6 +37,7 @@ class board3_includes_modules_helper_test extends \board3\portal\tests\testframe $controller_helper->add_route('board3_portal_controller', 'portal'); $this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $controller_helper, $request); + $phpbb_dispatcher = new \phpbb_mock_event_dispatcher(); } public function data_get_disallowed_forums() diff --git a/tests/unit/portal/fetch_posts_test.php b/tests/unit/portal/fetch_posts_test.php index 264e0e8d..b29ec76e 100644 --- a/tests/unit/portal/fetch_posts_test.php +++ b/tests/unit/portal/fetch_posts_test.php @@ -10,8 +10,9 @@ require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php'); require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php'); require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php'); -require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/TrimMessage.php'); -require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/PhpbbBbcodes.php'); +require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/Shortener.php'); +require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/Helper.php'); +require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/TextIterator.php'); class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\database_test_case