aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáté Bartus <mate.bartus@gmail.com>2015-11-05 21:43:00 +0100
committerMáté Bartus <mate.bartus@gmail.com>2015-11-05 21:43:00 +0100
commit402f36e42daf2ab09934ccf266deeb6d8a7d5b23 (patch)
treeff4506fe565aaa9aa48bc1bad148745d635e4454
parentc783c37c73beb2756d900f18dd24430c1b9f41ff (diff)
parented02365868e832b7bb891386e07cb4a3c7644072 (diff)
downloadforums-402f36e42daf2ab09934ccf266deeb6d8a7d5b23.tar
forums-402f36e42daf2ab09934ccf266deeb6d8a7d5b23.tar.gz
forums-402f36e42daf2ab09934ccf266deeb6d8a7d5b23.tar.bz2
forums-402f36e42daf2ab09934ccf266deeb6d8a7d5b23.tar.xz
forums-402f36e42daf2ab09934ccf266deeb6d8a7d5b23.zip
Merge pull request #4010 from Elsensee/ticket/14264
[ticket/14264] Don't use constants as return values
-rw-r--r--phpBB/config/default/container/services_text_reparser.yml7
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_description.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_rules.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/group_description.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/pm_text.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_title.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/post_text.php8
-rw-r--r--phpBB/phpbb/textreparser/plugins/user_signature.php8
-rw-r--r--phpBB/phpbb/textreparser/row_based_plugin.php22
-rw-r--r--tests/text_reparser/plugins/forum_description_test.php2
-rw-r--r--tests/text_reparser/plugins/forum_rules_test.php2
-rw-r--r--tests/text_reparser/plugins/group_description_test.php2
-rw-r--r--tests/text_reparser/plugins/pm_text_test.php2
-rw-r--r--tests/text_reparser/plugins/poll_title_test.php2
-rw-r--r--tests/text_reparser/plugins/post_text_test.php2
-rw-r--r--tests/text_reparser/plugins/test_row_based_plugin.php7
-rw-r--r--tests/text_reparser/plugins/user_signature_test.php2
17 files changed, 31 insertions, 75 deletions
diff --git a/phpBB/config/default/container/services_text_reparser.yml b/phpBB/config/default/container/services_text_reparser.yml
index 5d54e8dc82..dd15b9f09a 100644
--- a/phpBB/config/default/container/services_text_reparser.yml
+++ b/phpBB/config/default/container/services_text_reparser.yml
@@ -17,6 +17,7 @@ services:
class: phpbb\textreparser\plugins\forum_description
arguments:
- @dbal.conn
+ - %tables.forums%
tags:
- { name: text_reparser.plugin }
@@ -24,6 +25,7 @@ services:
class: phpbb\textreparser\plugins\forum_rules
arguments:
- @dbal.conn
+ - %tables.forums%
tags:
- { name: text_reparser.plugin }
@@ -31,6 +33,7 @@ services:
class: phpbb\textreparser\plugins\group_description
arguments:
- @dbal.conn
+ - %tables.groups%
tags:
- { name: text_reparser.plugin }
@@ -38,6 +41,7 @@ services:
class: phpbb\textreparser\plugins\pm_text
arguments:
- @dbal.conn
+ - %tables.privmsgs%
tags:
- { name: text_reparser.plugin }
@@ -52,6 +56,7 @@ services:
class: phpbb\textreparser\plugins\poll_title
arguments:
- @dbal.conn
+ - %tables.topics%
tags:
- { name: text_reparser.plugin }
@@ -59,6 +64,7 @@ services:
class: phpbb\textreparser\plugins\post_text
arguments:
- @dbal.conn
+ - %tables.posts%
tags:
- { name: text_reparser.plugin }
@@ -66,5 +72,6 @@ services:
class: phpbb\textreparser\plugins\user_signature
arguments:
- @dbal.conn
+ - %tables.users%
tags:
- { name: text_reparser.plugin }
diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php
index 0302dc3082..b0f5a42452 100644
--- a/phpBB/phpbb/textreparser/plugins/forum_description.php
+++ b/phpBB/phpbb/textreparser/plugins/forum_description.php
@@ -27,12 +27,4 @@ class forum_description extends \phpbb\textreparser\row_based_plugin
'options' => 'forum_desc_options',
);
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return FORUMS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php
index ce550225f2..d131d00707 100644
--- a/phpBB/phpbb/textreparser/plugins/forum_rules.php
+++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php
@@ -27,12 +27,4 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin
'options' => 'forum_rules_options',
);
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return FORUMS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php
index 3346ccf25e..2c45c00474 100644
--- a/phpBB/phpbb/textreparser/plugins/group_description.php
+++ b/phpBB/phpbb/textreparser/plugins/group_description.php
@@ -27,12 +27,4 @@ class group_description extends \phpbb\textreparser\row_based_plugin
'options' => 'group_desc_options',
);
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return GROUPS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/pm_text.php b/phpBB/phpbb/textreparser/plugins/pm_text.php
index 4d06a2878b..867da624ee 100644
--- a/phpBB/phpbb/textreparser/plugins/pm_text.php
+++ b/phpBB/phpbb/textreparser/plugins/pm_text.php
@@ -29,12 +29,4 @@ class pm_text extends \phpbb\textreparser\row_based_plugin
'bbcode_uid' => 'bbcode_uid',
);
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return PRIVMSGS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php
index 038ae0c366..76d30655c9 100644
--- a/phpBB/phpbb/textreparser/plugins/poll_title.php
+++ b/phpBB/phpbb/textreparser/plugins/poll_title.php
@@ -39,12 +39,4 @@ class poll_title extends \phpbb\textreparser\row_based_plugin
return $sql;
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return TOPICS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/post_text.php b/phpBB/phpbb/textreparser/plugins/post_text.php
index 4a07c98cea..1c98e86067 100644
--- a/phpBB/phpbb/textreparser/plugins/post_text.php
+++ b/phpBB/phpbb/textreparser/plugins/post_text.php
@@ -29,12 +29,4 @@ class post_text extends \phpbb\textreparser\row_based_plugin
'bbcode_uid' => 'bbcode_uid',
);
}
-
- /**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return POSTS_TABLE;
- }
}
diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php
index f657a45d38..647d3a7b14 100644
--- a/phpBB/phpbb/textreparser/plugins/user_signature.php
+++ b/phpBB/phpbb/textreparser/plugins/user_signature.php
@@ -55,14 +55,6 @@ class user_signature extends \phpbb\textreparser\row_based_plugin
}
/**
- * {@inheritdoc}
- */
- public function get_table_name()
- {
- return USERS_TABLE;
- }
-
- /**
* Save the keyoptions var from \phpbb\user
*/
protected function save_keyoptions()
diff --git a/phpBB/phpbb/textreparser/row_based_plugin.php b/phpBB/phpbb/textreparser/row_based_plugin.php
index d3ca334591..2d32104493 100644
--- a/phpBB/phpbb/textreparser/row_based_plugin.php
+++ b/phpBB/phpbb/textreparser/row_based_plugin.php
@@ -21,13 +21,20 @@ abstract class row_based_plugin extends base
protected $db;
/**
+ * @var string
+ */
+ protected $table;
+
+ /**
* Constructor
*
* @param \phpbb\db\driver\driver_interface $db Database connection
+ * @param string $table
*/
- public function __construct(\phpbb\db\driver\driver_interface $db)
+ public function __construct(\phpbb\db\driver\driver_interface $db, $table)
{
$this->db = $db;
+ $this->table = $table;
}
/**
@@ -38,20 +45,13 @@ abstract class row_based_plugin extends base
abstract public function get_columns();
/**
- * Return the name of the table used by this plugin
- *
- * @return string
- */
- abstract public function get_table_name();
-
- /**
* {@inheritdoc}
*/
public function get_max_id()
{
$columns = $this->get_columns();
- $sql = 'SELECT MAX(' . $columns['id'] . ') AS max_id FROM ' . $this->get_table_name();
+ $sql = 'SELECT MAX(' . $columns['id'] . ') AS max_id FROM ' . $this->table;
$result = $this->db->sql_query($sql);
$max_id = (int) $this->db->sql_fetchfield('max_id');
$this->db->sql_freeresult($result);
@@ -96,7 +96,7 @@ abstract class row_based_plugin extends base
}
$sql = 'SELECT ' . implode(', ', $fields) . '
- FROM ' . $this->get_table_name() . '
+ FROM ' . $this->table . '
WHERE ' . $columns['id'] . ' BETWEEN ' . $min_id . ' AND ' . $max_id;
return $sql;
@@ -109,7 +109,7 @@ abstract class row_based_plugin extends base
{
$columns = $this->get_columns();
- $sql = 'UPDATE ' . $this->get_table_name() . '
+ $sql = 'UPDATE ' . $this->table . '
SET ' . $columns['text'] . " = '" . $this->db->sql_escape($record['text']) . "'
WHERE " . $columns['id'] . ' = ' . $record['id'];
$this->db->sql_query($sql);
diff --git a/tests/text_reparser/plugins/forum_description_test.php b/tests/text_reparser/plugins/forum_description_test.php
index 3b739353cd..57166e6a3c 100644
--- a/tests/text_reparser/plugins/forum_description_test.php
+++ b/tests/text_reparser/plugins/forum_description_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\forum_description($this->db);
+ return new \phpbb\textreparser\plugins\forum_description($this->db, FORUMS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/forum_rules_test.php b/tests/text_reparser/plugins/forum_rules_test.php
index 4c267c9014..72e4e98876 100644
--- a/tests/text_reparser/plugins/forum_rules_test.php
+++ b/tests/text_reparser/plugins/forum_rules_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_ba
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\forum_rules($this->db);
+ return new \phpbb\textreparser\plugins\forum_rules($this->db, FORUMS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/group_description_test.php b/tests/text_reparser/plugins/group_description_test.php
index 51035903e1..babfc7e02f 100644
--- a/tests/text_reparser/plugins/group_description_test.php
+++ b/tests/text_reparser/plugins/group_description_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\group_description($this->db);
+ return new \phpbb\textreparser\plugins\group_description($this->db, GROUPS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/pm_text_test.php b/tests/text_reparser/plugins/pm_text_test.php
index 3896a57e98..6dc1a9cb4c 100644
--- a/tests/text_reparser/plugins/pm_text_test.php
+++ b/tests/text_reparser/plugins/pm_text_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\pm_text($this->db);
+ return new \phpbb\textreparser\plugins\pm_text($this->db, PRIVMSGS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/poll_title_test.php b/tests/text_reparser/plugins/poll_title_test.php
index 76ca2ee228..046b6019c8 100644
--- a/tests/text_reparser/plugins/poll_title_test.php
+++ b/tests/text_reparser/plugins/poll_title_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_bas
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\poll_title($this->db);
+ return new \phpbb\textreparser\plugins\poll_title($this->db, TOPICS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/post_text_test.php b/tests/text_reparser/plugins/post_text_test.php
index 0f934a06ee..8ea71e65f5 100644
--- a/tests/text_reparser/plugins/post_text_test.php
+++ b/tests/text_reparser/plugins/post_text_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\post_text($this->db);
+ return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE);
}
}
diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php
index bbae44c8e0..e8218dfdd6 100644
--- a/tests/text_reparser/plugins/test_row_based_plugin.php
+++ b/tests/text_reparser/plugins/test_row_based_plugin.php
@@ -24,8 +24,13 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t
{
$reparser = $this->get_reparser();
$columns = $reparser->get_columns();
+
+ $reflection_reparser = new ReflectionClass(get_class($reparser));
+ $table_property = $reflection_reparser->getProperty('table');
+ $table_property->setAccessible(true);
+
$sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text
- FROM ' . $reparser->get_table_name() . '
+ FROM ' . $table_property->getValue($reparser) . '
WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . '
ORDER BY id';
$result = $this->db->sql_query($sql);
diff --git a/tests/text_reparser/plugins/user_signature_test.php b/tests/text_reparser/plugins/user_signature_test.php
index ab830a303d..5b66f2788a 100644
--- a/tests/text_reparser/plugins/user_signature_test.php
+++ b/tests/text_reparser/plugins/user_signature_test.php
@@ -21,6 +21,6 @@ class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row
protected function get_reparser()
{
- return new \phpbb\textreparser\plugins\user_signature($this->db);
+ return new \phpbb\textreparser\plugins\user_signature($this->db, USERS_TABLE);
}
}