Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into weirdgloop/main
Browse files Browse the repository at this point in the history
  • Loading branch information
TehKittyCat committed Feb 8, 2024
2 parents b74baa8 + 1d332c8 commit 1fcfe39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions grabNewText.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function processRecentChanges() {
$result = $this->bot->query( $params );
if ( empty( $result['query']['recentchanges'] ) ) {
$this->output( 'No changes found...' );
break;
}
foreach ( $result['query']['recentchanges'] as $entry ) {
# new pages, new uploads, edited pages
Expand Down
24 changes: 17 additions & 7 deletions includes/ExternalWikiGrabber.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Jack Phoenix <jack@shoutwiki.com>
* @author Calimonious the Estrange
* @author Jesús Martínez <martineznovo@gmail.com>
* @date 5 November 2023
* @date 21 January 2024
* @version 1.1
*/

Expand Down Expand Up @@ -154,11 +154,21 @@ function getUserIdentity( $id, $name ) {
return $this->actorStore->getUnknownActor();
}

# Old imported revisions might be assigned to anon users.
# We also need to prefix system users if they really have no user ID
# on the remote site, so we are not using ::isUsable() as ActorStore do.
if ( !$id && $this->userNameUtils->isValid( $name ) ) {
$name = 'imported>' . $name;
if ( !$id and !$this->userNameUtils->isIP( $name ) and !ExternalUserNames::isExternal( $name ) ) {
# Everything that's not an IP or external, must be converted to external
# Old imported revisions might be assigned to anon users.
# We also need to prefix system users if they really have no user ID
$name = "imported>$name";
} elseif ( $id and !$this->userNameUtils->isValid( $name ) ) {
# T353766: There's an edge case of apparently valid but not canonicalized usernames.
# For example, usernames which start with lowercase characters.
# Those users cause problems when this script detects a user name change,
# because ActorStore does a normalization when inserting, but the external wiki
# may have old users that don't follow current canonicalization rules.
# Users with non-canonicalized names will be reported as invalid, and despite having
# user id on the external wiki, they'll be inserted as imported to avoid further errors
$name = "imported>$name";
$id = 0;
} elseif ( $id ) {
$name = $this->userMappings[$id] ?? $name;
$userIdentity = $this->actorStore->getUserIdentityByUserId( $id );
Expand All @@ -167,7 +177,7 @@ function getUserIdentity( $id, $name ) {
# Cache the new user name for uncompleted user rename.
$this->userMappings[$id] = $name = $this->getAndUpdateUserName( $userIdentity );
if ( $oldname !== $name ) {
$this->output( "Notice: We encountered an user rename on ID $id, $oldname => $name\n" );
$this->output( "Notice: We encountered a user rename on ID $id, $oldname => $name\n" );
}
} elseif ( $userIdentity ) {
return $userIdentity;
Expand Down

0 comments on commit 1fcfe39

Please sign in to comment.