Skip to content

Commit 004cef7

Browse files
committed
Plugin Directory: Remove user dispaly_name UTF8 workarounds.
These calls have not been required in some time, and are now causing problems with valid UTF-8 data when it's detected as JIS in newer PHP versions. This was a workaround for a database charset issues. Props dd32, TobiasBg. Fixes #8254. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14915 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent de8444f commit 004cef7

6 files changed

Lines changed: 8 additions & 38 deletions

File tree

‎wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -912,20 +912,6 @@ public static function get_blueprints( $post = null ) {
912912
return $out;
913913
}
914914

915-
/**
916-
* Properly encodes a string to UTF-8.
917-
*
918-
* @static
919-
*
920-
* @param string $string
921-
* @return string
922-
*/
923-
public static function encode( $string ) {
924-
$string = mb_convert_encoding( $string, 'UTF-8', 'ASCII, JIS, UTF-8, Windows-1252, ISO-8859-1' );
925-
926-
return ent2ncr( htmlspecialchars_decode( htmlentities( $string, ENT_NOQUOTES, 'UTF-8' ), ENT_NOQUOTES ) );
927-
}
928-
929915
/**
930916
* Generates a link to toggle a plugin favorites state.
931917
*

‎wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-committers.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace WordPressdotorg\Plugin_Directory\Widgets;
33

4-
use WordPressdotorg\Plugin_Directory\Template;
54
use WordPressdotorg\Plugin_Directory\Tools;
65

76
/**
@@ -56,7 +55,7 @@ public function widget( $args, $instance ) {
5655
<li data-user="<?php echo esc_attr( $committer->user_nicename ); ?>">
5756
<?php echo get_avatar( $committer->ID, 32 ); ?>
5857
<a href="<?php echo esc_url( "https://profiles.wordpress.org/{$committer->user_nicename}/" ); ?>">
59-
<?php echo Template::encode( $committer->display_name ?: $committer->user_nicename ); ?>
58+
<?php echo $committer->display_name ?: $committer->user_nicename; ?>
6059
</a><br>
6160

6261
<?php if ( current_user_can( 'plugin_remove_committer', $post ) ) : ?>

‎wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-contributors.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace WordPressdotorg\Plugin_Directory\Widgets;
33

4-
use WordPressdotorg\Plugin_Directory\Template;
5-
64
/**
75
* A Widget to display contributor information about a plugin.
86
*
@@ -73,7 +71,7 @@ function( $user_nicename ) {
7371
<li>
7472
<?php echo get_avatar( $contributor->ID, 32 ); ?>
7573
<a href="<?php echo esc_url( "https://profiles.wordpress.org/{$contributor->user_nicename}/" ); ?>">
76-
<?php echo Template::encode( $contributor->display_name ?: $contributor->user_nicename ); ?>
74+
<?php echo $contributor->display_name ?: $contributor->user_nicename; ?>
7775
</a>
7876
</li>
7977
<?php endforeach; ?>

‎wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace WordPressdotorg\Plugin_Directory\Widgets;
33

4-
use WordPressdotorg\Plugin_Directory\Template;
54
use WordPressdotorg\Plugin_Directory\Tools;
65

76
/**
@@ -60,7 +59,7 @@ public function widget( $args, $instance ) {
6059
<li data-user="<?php echo esc_attr( $support_rep->user_nicename ); ?>">
6160
<?php echo get_avatar( $support_rep->ID, 32 ); ?>
6261
<a href="<?php echo esc_url( "https://profiles.wordpress.org/{$support_rep->user_nicename}/" ); ?>">
63-
<?php echo Template::encode( $support_rep->display_name ?: $support_rep->user_nicename ); ?>
62+
<?php echo $support_rep->display_name ?: $support_rep->user_nicename; ?>
6463
</a><br>
6564

6665
<?php if ( current_user_can( 'plugin_remove_support_rep', $post ) ) : ?>

‎wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private function get_locale_contributors( $project, $locale_slug, $set_slug ) {
434434

435435
$locale_contributors['editors'][ $editor_source ][ $editor_id ] = (object) array(
436436
'nicename' => $user->user_nicename,
437-
'display_name' => $this->_encode( $user->display_name ),
437+
'display_name' => $user->display_name ?: $user->user_nicename,
438438
'email' => $user->user_email,
439439
);
440440

@@ -524,7 +524,7 @@ private function get_locale_contributors( $project, $locale_slug, $set_slug ) {
524524
$locale_contributors['contributors'][ $contributor->user_id ] = (object) array(
525525
'login' => $user->user_login,
526526
'nicename' => $user->user_nicename,
527-
'display_name' => $this->_encode( $user->display_name ),
527+
'display_name' => $user->display_name ?: $user->user_nicename,
528528
'email' => $user->user_email,
529529
'last_update' => $contributor->last_update,
530530
'total_count' => $contributor->total_count,
@@ -1019,11 +1019,4 @@ public function get_active_top_level_projects() {
10191019
ORDER BY FIELD( slug, 'waiting', 'wp', 'wp-themes', 'wp-plugins', 'patterns', 'meta', 'apps' )
10201020
" );
10211021
}
1022-
1023-
private function _encode( $raw ) {
1024-
if ( 'UTF-8' !== mb_detect_encoding( $raw, 'UTF-8', true ) ) {
1025-
$raw = mb_convert_encoding( $raw, 'UTF-8', 'ASCII, JIS, Windows-1252, ISO-8859-1' );
1026-
}
1027-
return ent2ncr( htmlspecialchars_decode( htmlentities( $raw, ENT_NOQUOTES, 'UTF-8' ), ENT_NOQUOTES ) );
1028-
}
10291022
}

‎wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-wp-directory.php‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function get_contributors( $project ) {
4444

4545
$contributors_by_locale[ $translation_editor->locale ]['editors'][ $translation_editor->user_id ] = (object) array(
4646
'nicename' => $user->user_nicename,
47-
'display_name' => $this->_encode( $user->display_name ),
47+
'display_name' => $user->display_name ?: $user->user_nicename,
4848
);
4949

5050
$contributors_by_locale[ $translation_editor->locale ]['count']++;
@@ -72,7 +72,7 @@ public function get_contributors( $project ) {
7272

7373
$contributors_by_locale[ $row->locale ]['contributors'][ $row->user_id ] = (object) array(
7474
'nicename' => $user->user_nicename,
75-
'display_name' => $this->_encode( $user->display_name ),
75+
'display_name' => $user->display_name ?: $user->user_nicename,
7676
);
7777

7878
$contributors_by_locale[ $row->locale ]['count']++;
@@ -105,7 +105,7 @@ public function get_contributors( $project ) {
105105

106106
$contributors_by_locale[ $row->locale ]['contributors'][ $row->user_id ] = (object) array(
107107
'nicename' => $user->user_nicename,
108-
'display_name' => $this->_encode( $user->display_name ),
108+
'display_name' => $user->display_name ?: $user->user_nicename,
109109
);
110110

111111
$contributors_by_locale[ $row->locale ]['count']++;
@@ -240,9 +240,4 @@ private function get_translation_contributors_by_locale( $project_id ) {
240240

241241
return $wpdb->get_results( $sql );
242242
}
243-
244-
private function _encode( $raw ) {
245-
$raw = mb_convert_encoding( $raw, 'UTF-8', 'ASCII, JIS, UTF-8, Windows-1252, ISO-8859-1' );
246-
return ent2ncr( htmlspecialchars_decode( htmlentities( $raw, ENT_NOQUOTES, 'UTF-8' ), ENT_NOQUOTES ) );
247-
}
248243
}

0 commit comments

Comments
 (0)