Optimize wpdb query (#34)

pull/36/head v1.4.11
Luffy 2024-03-07 18:41:08 +08:00 committed by GitHub
parent ce9cfa44e1
commit 30e7e6eb17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: OSS Aliyun
Plugin URI: https://github.com/sy-records/aliyun-oss-wordpress
Description: 使用阿里云对象存储 OSS 作为附件存储空间。This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.
Version: 1.4.10
Version: 1.4.11
Author: 沈唁
Author URI: https://qq52o.me
License: Apache2.0
@ -19,7 +19,7 @@ use OSS\Credentials\CredentialsProvider;
use AlibabaCloud\Credentials\Credential;
use OSS\Credentials\StaticCredentialsProvider;
define('OSS_VERSION', '1.4.10');
define('OSS_VERSION', '1.4.11');
define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__)));
if (!function_exists('get_home_path')) {
@ -687,11 +687,11 @@ function oss_setting_page()
global $wpdb;
$posts_name = $wpdb->prefix . 'posts';
// 文章内容
$posts_result = $wpdb->query("UPDATE $posts_name SET post_content = REPLACE(post_content, '$old_url', '$new_url')");
$posts_result = $wpdb->query($wpdb->prepare("UPDATE $posts_name SET post_content = REPLACE(post_content, '%s', '%s')", [$old_url, $new_url]));
// 修改题图之类的
$postmeta_name = $wpdb->prefix . 'postmeta';
$postmeta_result = $wpdb->query("UPDATE $postmeta_name SET meta_value = REPLACE(meta_value, '$old_url', '$new_url')");
$postmeta_result = $wpdb->query($wpdb->prepare("UPDATE $postmeta_name SET meta_value = REPLACE(meta_value, '%s', '%s')", [$old_url, $new_url]));
echo '<div class="updated"><p><strong>替换成功!共替换文章内链'.$posts_result.'条、题图链接'.$postmeta_result.'条!</strong></p></div>';
} else {

View File

@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.2
Tested up to: 6.4
Requires PHP: 7.0
Stable tag: 1.4.10
Stable tag: 1.4.11
License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
@ -73,6 +73,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog ==
= 1.4.11 =
- 优化数据库数据替换语法
= 1.4.10 =
- 修复`不在本地保留备份`时获取不到非图片文件大小