Skip to content

Commit 5bdea55

Browse files
swissspidyCopilot
andauthored
Update src/Media_Command.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4a20e61 commit 5bdea55

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Media_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,17 @@ private function find_duplicate_attachment( $basename ) {
732732

733733
$slash_basename = '/' . $basename;
734734

735+
if ( function_exists( 'mb_strlen' ) ) {
736+
$slash_basename_length = mb_strlen( $slash_basename, 'UTF-8' );
737+
} else {
738+
$slash_basename_length = strlen( $slash_basename );
739+
}
740+
735741
$result = $wpdb->get_var(
736742
$wpdb->prepare(
737743
"SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND (meta_value = %s OR RIGHT(meta_value, %d) = %s) LIMIT 1",
738744
$basename,
739-
mb_strlen( $slash_basename, 'UTF-8' ),
745+
$slash_basename_length,
740746
$slash_basename
741747
)
742748
);

0 commit comments

Comments
 (0)