diff options
-rw-r--r-- | phpBB/config/console.yml | 19 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/cache/purge.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/command.php | 13 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/command.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/cron/cron_list.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/cron/run.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/db/migrate.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/dev/migration_tips.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/extension/command.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/fixup/recalculate_email_hash.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/db/tools.php | 37 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 43 | ||||
-rw-r--r-- | tests/console/cron/cron_list_test.php | 2 | ||||
-rw-r--r-- | tests/console/cron/run_test.php | 2 | ||||
-rw-r--r-- | tests/dbal/db_tools_test.php | 3 |
15 files changed, 126 insertions, 47 deletions
diff --git a/phpBB/config/console.yml b/phpBB/config/console.yml index 06ea0e317f..540908164a 100644 --- a/phpBB/config/console.yml +++ b/phpBB/config/console.yml @@ -9,11 +9,11 @@ services: console.command.cache.purge: class: phpbb\console\command\cache\purge arguments: + - @user - @cache.driver - @dbal.conn - @auth - @log - - @user - @config tags: - { name: console.command } @@ -21,6 +21,7 @@ services: console.command.config.delete: class: phpbb\console\command\config\delete arguments: + - @user - @config tags: - { name: console.command } @@ -28,6 +29,7 @@ services: console.command.config.increment: class: phpbb\console\command\config\increment arguments: + - @user - @config tags: - { name: console.command } @@ -35,6 +37,7 @@ services: console.command.config.get: class: phpbb\console\command\config\get arguments: + - @user - @config tags: - { name: console.command } @@ -42,6 +45,7 @@ services: console.command.config.set: class: phpbb\console\command\config\set arguments: + - @user - @config tags: - { name: console.command } @@ -49,6 +53,7 @@ services: console.command.config.set_atomic: class: phpbb\console\command\config\set_atomic arguments: + - @user - @config tags: - { name: console.command } @@ -56,35 +61,36 @@ services: console.command.cron.list: class: phpbb\console\command\cron\cron_list arguments: - - @cron.manager - @user + - @cron.manager tags: - { name: console.command } console.command.cron.run: class: phpbb\console\command\cron\run arguments: + - @user - @cron.manager - @cron.lock_db - - @user tags: - { name: console.command } console.command.db.migrate: class: phpbb\console\command\db\migrate arguments: + - @user - @migrator - @ext.manager - @config - @cache - @log - - @user tags: - { name: console.command } console.command.dev.migration_tips: class: phpbb\console\command\dev\migration_tips arguments: + - @user - @ext.manager tags: - { name: console.command } @@ -92,6 +98,7 @@ services: console.command.extension.disable: class: phpbb\console\command\extension\disable arguments: + - @user - @ext.manager - @log tags: @@ -100,6 +107,7 @@ services: console.command.extension.enable: class: phpbb\console\command\extension\enable arguments: + - @user - @ext.manager - @log tags: @@ -108,6 +116,7 @@ services: console.command.extension.purge: class: phpbb\console\command\extension\purge arguments: + - @user - @ext.manager - @log tags: @@ -116,6 +125,7 @@ services: console.command.extension.show: class: phpbb\console\command\extension\show arguments: + - @user - @ext.manager - @log tags: @@ -124,6 +134,7 @@ services: console.command.fixup.recalculate_email_hash: class: phpbb\console\command\fixup\recalculate_email_hash arguments: + - @user - @dbal.conn tags: - { name: console.command } diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php index 379d2aa1ca..8c51d1b5a8 100644 --- a/phpBB/phpbb/console/command/cache/purge.php +++ b/phpBB/phpbb/console/command/cache/purge.php @@ -29,31 +29,27 @@ class purge extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $log; - /** @var \phpbb\user */ - protected $user; - /** @var \phpbb\config\config */ protected $config; /** * Constructor * + * @param \phpbb\user $user User instance * @param \phpbb\cache\driver\driver_interface $cache Cache instance * @param \phpbb\db\driver\driver_interface $db Database connection * @param \phpbb\auth\auth $auth Auth instance * @param \phpbb\log\log $log Logger instance - * @param \phpbb\user $user User instance * @param \phpbb\config\config $config Config instance */ - public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\user $user, \phpbb\config\config $config) + public function __construct(\phpbb\user $user, \phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\config\config $config) { $this->cache = $cache; $this->db = $db; $this->auth = $auth; $this->log = $log; - $this->user = $user; $this->config = $config; - parent::__construct(); + parent::__construct($user); } /** diff --git a/phpBB/phpbb/console/command/command.php b/phpBB/phpbb/console/command/command.php index d3449c0c38..638c989da2 100644 --- a/phpBB/phpbb/console/command/command.php +++ b/phpBB/phpbb/console/command/command.php @@ -15,4 +15,17 @@ namespace phpbb\console\command; abstract class command extends \Symfony\Component\Console\Command\Command { + /** @var \phpbb\user */ + protected $user; + + /** + * Constructor + * + * @param \phpbb\user $user User instance (mostly for translation) + */ + public function __construct(\phpbb\user $user) + { + $this->user = $user; + parent::__construct(); + } } diff --git a/phpBB/phpbb/console/command/config/command.php b/phpBB/phpbb/console/command/config/command.php index de3fbd7fa7..f0ad5d4d19 100644 --- a/phpBB/phpbb/console/command/config/command.php +++ b/phpBB/phpbb/console/command/config/command.php @@ -17,10 +17,10 @@ abstract class command extends \phpbb\console\command\command /** @var \phpbb\config\config */ protected $config; - function __construct(\phpbb\config\config $config) + function __construct(\phpbb\user $user, \phpbb\config\config $config) { $this->config = $config; - parent::__construct(); + parent::__construct($user); } } diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index 4f4228d9b3..c515fd9e80 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -20,20 +20,16 @@ class cron_list extends \phpbb\console\command\command /** @var \phpbb\cron\manager */ protected $cron_manager; - /** @var \phpbb\user */ - protected $user; - /** * Constructor * - * @param \phpbb\cron\manager $cron_manager Cron manager * @param \phpbb\user $user User instance + * @param \phpbb\cron\manager $cron_manager Cron manager */ - public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\user $user) + public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager) { $this->cron_manager = $cron_manager; - $this->user = $user; - parent::__construct(); + parent::__construct($user); } /** diff --git a/phpBB/phpbb/console/command/cron/run.php b/phpBB/phpbb/console/command/cron/run.php index 0b365ece67..72ad1205ef 100644 --- a/phpBB/phpbb/console/command/cron/run.php +++ b/phpBB/phpbb/console/command/cron/run.php @@ -25,23 +25,19 @@ class run extends \phpbb\console\command\command /** @var \phpbb\lock\db */ protected $lock_db; - /** @var \phpbb\user */ - protected $user; - /** * Construct method * + * @param \phpbb\user $user The user object (used to get language information) * @param \phpbb\cron\manager $cron_manager The cron manager containing * the cron tasks to be executed. * @param \phpbb\lock\db $lock_db The lock for accessing database. - * @param \phpbb\user $user The user object (used to get language information) */ - public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db, \phpbb\user $user) + public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db) { $this->cron_manager = $cron_manager; $this->lock_db = $lock_db; - $this->user = $user; - parent::__construct(); + parent::__construct($user); } /** diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 2abeaf5268..758b125b13 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,19 +32,15 @@ class migrate extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $log; - /** @var \phpbb\user */ - protected $user; - - function __construct(\phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\user $user) + function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log) { $this->migrator = $migrator; $this->extension_manager = $extension_manager; $this->config = $config; $this->cache = $cache; $this->log = $log; - $this->user = $user; + parent::__construct($user); $this->user->add_lang(array('common', 'install', 'migrator')); - parent::__construct(); } protected function configure() diff --git a/phpBB/phpbb/console/command/dev/migration_tips.php b/phpBB/phpbb/console/command/dev/migration_tips.php index c2f61568ea..e1387b34ae 100644 --- a/phpBB/phpbb/console/command/dev/migration_tips.php +++ b/phpBB/phpbb/console/command/dev/migration_tips.php @@ -20,10 +20,10 @@ class migration_tips extends \phpbb\console\command\command /** @var \phpbb\extension\manager */ protected $extension_manager; - function __construct(\phpbb\extension\manager $extension_manager) + function __construct(\phpbb\user $user, \phpbb\extension\manager $extension_manager) { $this->extension_manager = $extension_manager; - parent::__construct(); + parent::__construct($user); } protected function configure() diff --git a/phpBB/phpbb/console/command/extension/command.php b/phpBB/phpbb/console/command/extension/command.php index 21bb640504..364d954082 100644 --- a/phpBB/phpbb/console/command/extension/command.php +++ b/phpBB/phpbb/console/command/extension/command.php @@ -20,11 +20,11 @@ abstract class command extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $log; - public function __construct(\phpbb\extension\manager $manager, \phpbb\log\log $log) + public function __construct(\phpbb\user $user, \phpbb\extension\manager $manager, \phpbb\log\log $log) { $this->manager = $manager; $this->log = $log; - parent::__construct(); + parent::__construct($user); } } diff --git a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php index ec04da4267..cb821cfe20 100644 --- a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php +++ b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php @@ -20,11 +20,11 @@ class recalculate_email_hash extends \phpbb\console\command\command /** @var \phpbb\db\driver\driver_interface */ protected $db; - function __construct(\phpbb\db\driver\driver_interface $db) + function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db) { $this->db = $db; - parent::__construct(); + parent::__construct($user); } protected function configure() diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 18defc4535..ae0c695aa2 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1487,8 +1487,16 @@ class tools $return_array['textimage'] = $column_type === '[text]'; - $sql .= 'NOT NULL'; - $sql_default .= 'NOT NULL'; + if (!is_null($column_data[1]) || (isset($column_data[2]) && $column_data[2] == 'auto_increment')) + { + $sql .= 'NOT NULL'; + $sql_default .= 'NOT NULL'; + } + else + { + $sql .= 'NULL'; + $sql_default .= 'NULL'; + } $return_array['column_type_sql_default'] = $sql_default; @@ -1503,7 +1511,15 @@ class tools { $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; } - $sql .= 'NOT NULL'; + + if (!is_null($column_data[1])) + { + $sql .= 'NOT NULL'; + } + else + { + $sql .= 'NULL'; + } if (isset($column_data[2])) { @@ -1528,7 +1544,7 @@ class tools // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) if (!preg_match('/number/i', $column_type)) { - $sql .= ($column_data[1] === '') ? '' : 'NOT NULL'; + $sql .= ($column_data[1] === '' || $column_data[1] === null) ? '' : 'NOT NULL'; } $return_array['auto_increment'] = false; @@ -1556,6 +1572,12 @@ class tools $return_array['null'] = 'NOT NULL'; $sql .= 'NOT NULL '; } + else + { + $default_val = "'" . $column_data[1] . "'"; + $return_array['null'] = 'NULL'; + $sql .= 'NULL '; + } $return_array['default'] = $default_val; @@ -1588,8 +1610,11 @@ class tools $sql .= ' ' . $column_type; } - $sql .= ' NOT NULL '; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; + if (!is_null($column_data[1])) + { + $sql .= ' NOT NULL '; + $sql .= "DEFAULT '{$column_data[1]}'"; + } break; } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 23f2fe8e3d..1fdce5a6c3 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1423,6 +1423,46 @@ $template->assign_vars(array( 'S_NUM_POSTS' => sizeof($post_list)) ); +/** +* Event to modify the post, poster and attachment data before assigning the posts +* +* @event core.viewtopic_modify_post_data +* @var int forum_id Forum ID +* @var int topic_id Topic ID +* @var array topic_data Array with topic data +* @var array post_list Array with post_ids we are going to display +* @var array rowset Array with post_id => post data +* @var array user_cache Array with prepared user data +* @var int start Pagination information +* @var int sort_days Display posts of previous x days +* @var string sort_key Key the posts are sorted by +* @var string sort_dir Direction the posts are sorted by +* @var bool display_notice Shall we display a notice instead of attachments +* @var bool has_approved_attachments Does the topic have approved attachments +* @var array attachments List of attachments post_id => array of attachments +* @var array permanently_banned_users List of permanently banned users +* @var array can_receive_pm_list Array with posters that can receive pms +* @since 3.1.0-RC3 +*/ +$vars = array( + 'forum_id', + 'topic_id', + 'topic_data', + 'post_list', + 'rowset', + 'user_cache', + 'sort_days', + 'sort_key', + 'sort_dir', + 'start', + 'permanently_banned_users', + 'can_receive_pm_list', + 'display_notice', + 'has_approved_attachments', + 'attachments', +); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_data', compact($vars))); + // Output the posts $first_unread = $post_unread = false; for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) @@ -1789,6 +1829,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @var int current_row_number Number of the post on this page * @var int end Number of posts on this page * @var int total_posts Total posts count + * @var int poster_id Post author id * @var array row Array with original post and user data * @var array cp_row Custom profile field data of the poster * @var array attachments List of attachments @@ -1798,12 +1839,14 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @since 3.1.0-a1 * @change 3.1.0-a3 Added vars start, current_row_number, end, attachments * @change 3.1.0-b3 Added topic_data array, total_posts + * @change 3.1.0-RC3 Added poster_id */ $vars = array( 'start', 'current_row_number', 'end', 'total_posts', + 'poster_id', 'row', 'cp_row', 'attachments', diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index f04c14e847..1059a3f221 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -75,7 +75,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function get_command_tester() { $application = new Application(); - $application->add(new cron_list($this->cron_manager, $this->user)); + $application->add(new cron_list($this->user, $this->cron_manager)); $command = $application->find('cron:list'); $this->command_name = $command->getName(); diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index ff251cff3c..60bd74e1f0 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -148,7 +148,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function get_command_tester() { $application = new Application(); - $application->add(new run($this->cron_manager, $this->lock, $this->user)); + $application->add(new run($this->user, $this->cron_manager, $this->lock)); $command = $application->find('cron:run'); $this->command_name = $command->getName(); diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index f3c6888c8d..6cc2f8ec0f 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -46,6 +46,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case 'c_bool' => array('BOOL', 1), 'c_vchar' => array('VCHAR', 'foo'), 'c_vchar_size' => array('VCHAR:4', 'foo'), + 'c_vchar_null' => array('VCHAR', null), 'c_char_size' => array('CHAR:4', 'foo'), 'c_xstext' => array('XSTEXT', 'foo'), 'c_stext' => array('STEXT', 'foo'), @@ -111,6 +112,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case 'c_bool' => 0, 'c_vchar' => '', 'c_vchar_size' => '', + 'c_vchar_null' => null, 'c_char_size' => 'abcd', 'c_xstext' => '', 'c_stext' => '', @@ -144,6 +146,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case array('c_bool', 0), array('c_vchar', str_repeat('a', 255)), array('c_vchar_size', str_repeat('a', 4)), + array('c_vchar_null', str_repeat('a', 4)), array('c_char_size', str_repeat('a', 4)), array('c_xstext', str_repeat('a', 1000)), array('c_stext', str_repeat('a', 3000)), |