[MediaWiki-commits] [Gerrit] Clean up 'Flow talk page manager' related code - change (mediawiki...Flow)

2015-08-03 Thread Mattflaschen (Code Review)
Mattflaschen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/228980

Change subject: Clean up 'Flow talk page manager' related code
..

Clean up 'Flow talk page manager' related code

* Always use the hardcoded English version so the username is the same
across all wikis.
* Use accounts even if we didn't create them. If a malicious user takes
the name, they will be locked out due to the UserGetReservedNames
hook.
** Previous detection only checked if the user was a bot, which can
   easily be spoofed.
* If CentralAuth is installed, attach new users to the global account.
* Remove special casing for PHPUnit tests :)

Bug: T101300
Bug: T107329
Change-Id: I3f01fa40fcb364382caddad268d1d90a4d37ad9a
(cherry picked from commit 5c84c341117e956bdc1e9306058e03c43315f7bc)
---
M Hooks.php
M i18n/en.json
M i18n/qqq.json
M includes/TalkpageManager.php
4 files changed, 18 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/80/228980/1

diff --git a/Hooks.php b/Hooks.php
index 35c9038..f4ccf4f 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -674,9 +674,7 @@
}
$names[] = 'msg:flow-system-usertext';
 
-   // Reserve both the localized username and the English fallback 
for the
-   // taking-over revision.
-   $names[] = 'msg:flow-talk-username';
+   // Reserve the bot account we use during content model changes 
 LQT conversion
$names[] = 'Flow talk page manager';
 
return true;
diff --git a/i18n/en.json b/i18n/en.json
index 2272f40..d555ea5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,7 +16,6 @@
enableflow: Enable Flow,
flow-desc: Workflow management system,
flow-talk-taken-over: This talk page is using 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Flow_Portal Flow].,
-   flow-talk-username: Flow talk page manager,
log-name-flow: Flow activity log,
logentry-delete-flow-delete-post: $1 {{GENDER:$2|deleted}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
logentry-delete-flow-restore-post: $1 {{GENDER:$2|restored}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 29e3a27..6351465 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -22,7 +22,6 @@
enableflow: {{doc-special|EnableFlow}},
flow-desc: 
{{desc|name=Flow|url=https://www.mediawiki.org/wiki/Extension:Flow}};,
flow-talk-taken-over: Content to replace existing page content by 
for pages that are turned into Flow boards.,
-   flow-talk-username: Username used for the revision added when Flow 
takes over a talk page.  Avoid changing this unnecessarily, as it will cause a 
new user to be used for future actions.,
log-name-flow: {{doc-logpage}}\nName of the Flow log filter on the 
[[Special:Log]] page.,
logentry-delete-flow-delete-post: Text for a deletion log entry when 
a post was deleted. Parameters:\n* $1 - the user: link to the user page\n* $2 - 
the username. Can be used for GENDER.\n* $3 - the page where the post was 
moderated\n* $4 - permalink URL to the moderated post\n* $5 - The topic title 
text\n* $6 - The board page\n{{Related|Flow-logentry}},
logentry-delete-flow-restore-post: Text for a deletion log entry 
when a deleted post was restored. Parameters:\n* $1 - the user: link to the 
user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where 
the post was moderated\n* $4 - permalink URL to the moderated post\n* $5 - The 
topic title text\n* $6 - The board page\n{{Related|Flow-logentry}},
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 7a93e5c..c585592 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -7,6 +7,7 @@
 use Flow\Exception\InvalidInputException;
 use Flow\Model\Workflow;
 use Article;
+use CentralAuthUser;
 use Status;
 use Title;
 use User;
@@ -245,55 +246,34 @@
 * Gives a user object used to manage talk pages
 *
 * @return User User to manage talkpages
-* @throws FlowException If both of the names already exist, but are 
not properly
-*  configured.
 */
public function getTalkpageManager() {
if ( $this-talkPageManagerUser !== null ) {
return $this-talkPageManagerUser;
}
 
-   $userNameCandidates = array(
-   wfMessage( 'flow-talk-username' 
)-inContentLanguage()-text(),
-   'Flow talk page manager',
-   );
 
-   $user = null;
+   $user = User::newFromName( 'Flow talk page manager' );
 
-   foreach ( $userNameCandidates as $name ) {
-   $candidateUser = User::newFromName( $name );
-
-   if ( $candidateUser-getId() === 0 ) 

[MediaWiki-commits] [Gerrit] Clean up 'Flow talk page manager' related code - change (mediawiki...Flow)

2015-08-03 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Clean up 'Flow talk page manager' related code
..


Clean up 'Flow talk page manager' related code

* Always use the hardcoded English version so the username is the same
across all wikis.
* Use accounts even if we didn't create them. If a malicious user takes
the name, they will be locked out due to the UserGetReservedNames
hook.
** Previous detection only checked if the user was a bot, which can
   easily be spoofed.
* If CentralAuth is installed, attach new users to the global account.
* Remove special casing for PHPUnit tests :)

Bug: T101300
Bug: T107329
Change-Id: I3f01fa40fcb364382caddad268d1d90a4d37ad9a
(cherry picked from commit 5c84c341117e956bdc1e9306058e03c43315f7bc)
---
M Hooks.php
M i18n/en.json
M i18n/qqq.json
M includes/TalkpageManager.php
4 files changed, 18 insertions(+), 42 deletions(-)

Approvals:
  Mattflaschen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 35c9038..f4ccf4f 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -674,9 +674,7 @@
}
$names[] = 'msg:flow-system-usertext';
 
-   // Reserve both the localized username and the English fallback 
for the
-   // taking-over revision.
-   $names[] = 'msg:flow-talk-username';
+   // Reserve the bot account we use during content model changes 
 LQT conversion
$names[] = 'Flow talk page manager';
 
return true;
diff --git a/i18n/en.json b/i18n/en.json
index 2272f40..d555ea5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,7 +16,6 @@
enableflow: Enable Flow,
flow-desc: Workflow management system,
flow-talk-taken-over: This talk page is using 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Flow_Portal Flow].,
-   flow-talk-username: Flow talk page manager,
log-name-flow: Flow activity log,
logentry-delete-flow-delete-post: $1 {{GENDER:$2|deleted}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
logentry-delete-flow-restore-post: $1 {{GENDER:$2|restored}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 29e3a27..6351465 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -22,7 +22,6 @@
enableflow: {{doc-special|EnableFlow}},
flow-desc: 
{{desc|name=Flow|url=https://www.mediawiki.org/wiki/Extension:Flow}};,
flow-talk-taken-over: Content to replace existing page content by 
for pages that are turned into Flow boards.,
-   flow-talk-username: Username used for the revision added when Flow 
takes over a talk page.  Avoid changing this unnecessarily, as it will cause a 
new user to be used for future actions.,
log-name-flow: {{doc-logpage}}\nName of the Flow log filter on the 
[[Special:Log]] page.,
logentry-delete-flow-delete-post: Text for a deletion log entry when 
a post was deleted. Parameters:\n* $1 - the user: link to the user page\n* $2 - 
the username. Can be used for GENDER.\n* $3 - the page where the post was 
moderated\n* $4 - permalink URL to the moderated post\n* $5 - The topic title 
text\n* $6 - The board page\n{{Related|Flow-logentry}},
logentry-delete-flow-restore-post: Text for a deletion log entry 
when a deleted post was restored. Parameters:\n* $1 - the user: link to the 
user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where 
the post was moderated\n* $4 - permalink URL to the moderated post\n* $5 - The 
topic title text\n* $6 - The board page\n{{Related|Flow-logentry}},
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 7a93e5c..c585592 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -7,6 +7,7 @@
 use Flow\Exception\InvalidInputException;
 use Flow\Model\Workflow;
 use Article;
+use CentralAuthUser;
 use Status;
 use Title;
 use User;
@@ -245,55 +246,34 @@
 * Gives a user object used to manage talk pages
 *
 * @return User User to manage talkpages
-* @throws FlowException If both of the names already exist, but are 
not properly
-*  configured.
 */
public function getTalkpageManager() {
if ( $this-talkPageManagerUser !== null ) {
return $this-talkPageManagerUser;
}
 
-   $userNameCandidates = array(
-   wfMessage( 'flow-talk-username' 
)-inContentLanguage()-text(),
-   'Flow talk page manager',
-   );
 
-   $user = null;
+   $user = User::newFromName( 'Flow talk page manager' );
 
-   foreach ( $userNameCandidates as $name ) {
-   $candidateUser = User::newFromName( $name );
-
-   if ( $candidateUser-getId() === 0 ) {
-   $user = 

[MediaWiki-commits] [Gerrit] Clean up 'Flow talk page manager' related code - change (mediawiki...Flow)

2015-07-30 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Clean up 'Flow talk page manager' related code
..


Clean up 'Flow talk page manager' related code

* Always use the hardcoded English version so the username is the same
across all wikis.
* Use accounts even if we didn't create them. If a malicious user takes
the name, they will be locked out due to the UserGetReservedNames
hook.
** Previous detection only checked if the user was a bot, which can
   easily be spoofed.
* If CentralAuth is installed, attach new users to the global account.
* Remove special casing for PHPUnit tests :)

Bug: T101300
Bug: T107329
Change-Id: I3f01fa40fcb364382caddad268d1d90a4d37ad9a
---
M Hooks.php
M i18n/en.json
M i18n/qqq.json
M includes/TalkpageManager.php
4 files changed, 18 insertions(+), 42 deletions(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 35c9038..f4ccf4f 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -674,9 +674,7 @@
}
$names[] = 'msg:flow-system-usertext';
 
-   // Reserve both the localized username and the English fallback 
for the
-   // taking-over revision.
-   $names[] = 'msg:flow-talk-username';
+   // Reserve the bot account we use during content model changes 
 LQT conversion
$names[] = 'Flow talk page manager';
 
return true;
diff --git a/i18n/en.json b/i18n/en.json
index 2272f40..d555ea5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,7 +16,6 @@
enableflow: Enable Flow,
flow-desc: Workflow management system,
flow-talk-taken-over: This talk page is using 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Flow_Portal Flow].,
-   flow-talk-username: Flow talk page manager,
log-name-flow: Flow activity log,
logentry-delete-flow-delete-post: $1 {{GENDER:$2|deleted}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
logentry-delete-flow-restore-post: $1 {{GENDER:$2|restored}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 29e3a27..6351465 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -22,7 +22,6 @@
enableflow: {{doc-special|EnableFlow}},
flow-desc: 
{{desc|name=Flow|url=https://www.mediawiki.org/wiki/Extension:Flow}};,
flow-talk-taken-over: Content to replace existing page content by 
for pages that are turned into Flow boards.,
-   flow-talk-username: Username used for the revision added when Flow 
takes over a talk page.  Avoid changing this unnecessarily, as it will cause a 
new user to be used for future actions.,
log-name-flow: {{doc-logpage}}\nName of the Flow log filter on the 
[[Special:Log]] page.,
logentry-delete-flow-delete-post: Text for a deletion log entry when 
a post was deleted. Parameters:\n* $1 - the user: link to the user page\n* $2 - 
the username. Can be used for GENDER.\n* $3 - the page where the post was 
moderated\n* $4 - permalink URL to the moderated post\n* $5 - The topic title 
text\n* $6 - The board page\n{{Related|Flow-logentry}},
logentry-delete-flow-restore-post: Text for a deletion log entry 
when a deleted post was restored. Parameters:\n* $1 - the user: link to the 
user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where 
the post was moderated\n* $4 - permalink URL to the moderated post\n* $5 - The 
topic title text\n* $6 - The board page\n{{Related|Flow-logentry}},
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 7a93e5c..c585592 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -7,6 +7,7 @@
 use Flow\Exception\InvalidInputException;
 use Flow\Model\Workflow;
 use Article;
+use CentralAuthUser;
 use Status;
 use Title;
 use User;
@@ -245,55 +246,34 @@
 * Gives a user object used to manage talk pages
 *
 * @return User User to manage talkpages
-* @throws FlowException If both of the names already exist, but are 
not properly
-*  configured.
 */
public function getTalkpageManager() {
if ( $this-talkPageManagerUser !== null ) {
return $this-talkPageManagerUser;
}
 
-   $userNameCandidates = array(
-   wfMessage( 'flow-talk-username' 
)-inContentLanguage()-text(),
-   'Flow talk page manager',
-   );
 
-   $user = null;
+   $user = User::newFromName( 'Flow talk page manager' );
 
-   foreach ( $userNameCandidates as $name ) {
-   $candidateUser = User::newFromName( $name );
-
-   if ( $candidateUser-getId() === 0 ) {
-   $user = User::createNew( $name );
-   $user-addGroup( 

[MediaWiki-commits] [Gerrit] Clean up 'Flow talk page manager' related code - change (mediawiki...Flow)

2015-07-29 Thread Legoktm (Code Review)
Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227773

Change subject: Clean up 'Flow talk page manager' related code
..

Clean up 'Flow talk page manager' related code

* Always use the hardcoded English version so the username is the same
across all wikis.
* Use accounts even if we didn't create them. If a malicious user takes
the name, they will be locked out due to the UserGetReservedNames
hook.
** Previous detection only checked if the user was a bot, which can
   easily be spoofed.
* If CentralAuth is installed, attach new users to the global account.
* Remove special casing for PHPUnit tests :)

Bug: T101300
Bug: T107329
Change-Id: I3f01fa40fcb364382caddad268d1d90a4d37ad9a
---
M Hooks.php
M i18n/en.json
M i18n/qqq.json
M includes/TalkpageManager.php
4 files changed, 18 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/73/227773/1

diff --git a/Hooks.php b/Hooks.php
index 35c9038..f4ccf4f 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -674,9 +674,7 @@
}
$names[] = 'msg:flow-system-usertext';
 
-   // Reserve both the localized username and the English fallback 
for the
-   // taking-over revision.
-   $names[] = 'msg:flow-talk-username';
+   // Reserve the bot account we use during content model changes 
 LQT conversion
$names[] = 'Flow talk page manager';
 
return true;
diff --git a/i18n/en.json b/i18n/en.json
index 2272f40..d555ea5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,7 +16,6 @@
enableflow: Enable Flow,
flow-desc: Workflow management system,
flow-talk-taken-over: This talk page is using 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Flow_Portal Flow].,
-   flow-talk-username: Flow talk page manager,
log-name-flow: Flow activity log,
logentry-delete-flow-delete-post: $1 {{GENDER:$2|deleted}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
logentry-delete-flow-restore-post: $1 {{GENDER:$2|restored}} a [$4 
post] on \[[$3|$5]]\ on [[$6]],
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 29e3a27..6351465 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -22,7 +22,6 @@
enableflow: {{doc-special|EnableFlow}},
flow-desc: 
{{desc|name=Flow|url=https://www.mediawiki.org/wiki/Extension:Flow}};,
flow-talk-taken-over: Content to replace existing page content by 
for pages that are turned into Flow boards.,
-   flow-talk-username: Username used for the revision added when Flow 
takes over a talk page.  Avoid changing this unnecessarily, as it will cause a 
new user to be used for future actions.,
log-name-flow: {{doc-logpage}}\nName of the Flow log filter on the 
[[Special:Log]] page.,
logentry-delete-flow-delete-post: Text for a deletion log entry when 
a post was deleted. Parameters:\n* $1 - the user: link to the user page\n* $2 - 
the username. Can be used for GENDER.\n* $3 - the page where the post was 
moderated\n* $4 - permalink URL to the moderated post\n* $5 - The topic title 
text\n* $6 - The board page\n{{Related|Flow-logentry}},
logentry-delete-flow-restore-post: Text for a deletion log entry 
when a deleted post was restored. Parameters:\n* $1 - the user: link to the 
user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where 
the post was moderated\n* $4 - permalink URL to the moderated post\n* $5 - The 
topic title text\n* $6 - The board page\n{{Related|Flow-logentry}},
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 7a93e5c..c585592 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -7,6 +7,7 @@
 use Flow\Exception\InvalidInputException;
 use Flow\Model\Workflow;
 use Article;
+use CentralAuthUser;
 use Status;
 use Title;
 use User;
@@ -245,55 +246,34 @@
 * Gives a user object used to manage talk pages
 *
 * @return User User to manage talkpages
-* @throws FlowException If both of the names already exist, but are 
not properly
-*  configured.
 */
public function getTalkpageManager() {
if ( $this-talkPageManagerUser !== null ) {
return $this-talkPageManagerUser;
}
 
-   $userNameCandidates = array(
-   wfMessage( 'flow-talk-username' 
)-inContentLanguage()-text(),
-   'Flow talk page manager',
-   );
 
-   $user = null;
+   $user = User::newFromName( 'Flow talk page manager' );
 
-   foreach ( $userNameCandidates as $name ) {
-   $candidateUser = User::newFromName( $name );
-
-   if ( $candidateUser-getId() === 0 ) {
-   $user = User::createNew( $name );
-