Go Live Update URLS - Version 5.0.4

Version Description

Fixes bug with database not updating properly

Download this release

Release Info

Developer Mat Lipe
Plugin Icon 128x128 Go Live Update URLS
Version 5.0.4
Comparing to
See all releases

Code changes from version 5.0.3 to 5.0.4

Files changed (5) hide show
  1. go-live-update-urls.php +3 -2
  2. readme.txt +5 -2
  3. src/Admin_Page.php +1 -6
  4. src/Core.php +37 -0
  5. src/Database.php +4 -10
go-live-update-urls.php CHANGED
@@ -5,11 +5,11 @@ Plugin URI: https://matlipe.com/go-live-update-urls/
5
Description: Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
6
Author: Mat Lipe
7
Author URI: https://matlipe.com/
8
- Version: 5.0.3
9
Text Domain: go-live-update-urls
10
*/
11
12
- define( 'GO_LIVE_UPDATE_URLS_VERSION', '5.0.3' );
13
14
/** Deprecated to be removed 6/1/18 */
15
require plugin_dir_path( __FILE__ ) . '/src/GoLiveUpdateUrls.php';
@@ -18,6 +18,7 @@ function go_live_update_urls_load() {
18
load_plugin_textdomain( 'go-live-update-urls', false, 'go-live-update-urls/languages' );
19
20
Go_Live_Update_Urls_Admin_Page::init();
21
}
22
23
/**
5
Description: Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
6
Author: Mat Lipe
7
Author URI: https://matlipe.com/
8
+ Version: 5.0.4
9
Text Domain: go-live-update-urls
10
*/
11
12
+ define( 'GO_LIVE_UPDATE_URLS_VERSION', '5.0.4' );
13
14
/** Deprecated to be removed 6/1/18 */
15
require plugin_dir_path( __FILE__ ) . '/src/GoLiveUpdateUrls.php';
18
load_plugin_textdomain( 'go-live-update-urls', false, 'go-live-update-urls/languages' );
19
20
Go_Live_Update_Urls_Admin_Page::init();
21
+ Go_Live_Update_Urls_Core::init();
22
}
23
24
/**
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: Go Live, Urls, Domain Changes
5
Requires at least: 4.5.0
6
Tested up to: 4.9.4
7
Requires PHP: 5.2.4
8
- Stable tag: 5.0.3
9
10
== Description ==
11
@@ -113,7 +113,10 @@ If you wish to try to update tables mentioned as not safe anyway, you may make a
113
114
115
== Upgrade Notice ==
116
- = 5.1.1 =
117
For full functionality of PRO version 2.2.0
118
119
= 3.1 =
5
Requires at least: 4.5.0
6
Tested up to: 4.9.4
7
Requires PHP: 5.2.4
8
+ Stable tag: 5.0.4
9
10
== Description ==
11
113
114
115
== Upgrade Notice ==
116
+ = 5.0.4 =
117
+ Fixes bug with database not updating properly
118
+
119
+ = 5.0.1 =
120
For full functionality of PRO version 2.2.0
121
122
= 3.1 =
src/Admin_Page.php CHANGED
@@ -135,13 +135,8 @@ class Go_Live_Update_Urls_Admin_Page {
135
foreach ( $tables as $_table ) {
136
?>
137
<li>
138
- <input
139
- name="<?php echo esc_attr( self::TABLE_INPUT_NAME ); ?>[<?php echo esc_attr( $_table ); ?>]"
140
- type="checkbox"
141
- value="1"
142
- class="go-live-update-urls/checkboxes/checkbox" <?php checked( $checked ); ?>/>
143
<?php
144
- echo esc_html( $_table );
145
if ( isset( $serialized_tables[ $_table ] ) ) {
146
?>
147
- <strong>
135
foreach ( $tables as $_table ) {
136
?>
137
<li>
138
<?php
139
+ printf( '<input name="%s[]" type="checkbox" value="%s" checked /> %s', esc_attr( self::TABLE_INPUT_NAME ), esc_attr( $_table ), esc_html( $_table ) );
140
if ( isset( $serialized_tables[ $_table ] ) ) {
141
?>
142
- <strong>
src/Core.php CHANGED
@@ -8,10 +8,46 @@
8
*
9
*/
10
class Go_Live_Update_Urls_Core {
11
12
13
protected function hook() {
14
15
}
16
17
@@ -36,6 +72,7 @@ class Go_Live_Update_Urls_Core {
36
return $db->update_the_database( $old_url, $new_url, $tables );
37
}
38
39
/**
40
* Get a view file from the theme first then this plugin
41
*
8
*
9
*/
10
class Go_Live_Update_Urls_Core {
11
+ const MEMORY_LIMIT = '256M';
12
13
14
protected function hook() {
15
+ add_action( 'go-live-update-urls/database/before-update', array( $this, 'raise_resource_limits' ), 0, 0 );
16
+ add_filter( 'go-live-update-urls/database/memory-limit_memory_limit', array(
17
+ $this,
18
+ 'raise_memory_limit',
19
+ ), 0, 0 );
20
+ }
21
+
22
23
+ /**
24
+ * 1. Set time limit to unlimited
25
+ * 2. Set input time to unlimited
26
+ * 3. Set memory limit to context which will use our filter
27
+ *
28
+ * @see Go_Live_Update_Urls_Core::raise_memory_limit();
29
+ *
30
+ * @return void
31
+ */
32
+ public function raise_resource_limits() {
33
+ @set_time_limit( 0 );
34
+ @ini_set( 'max_input_time', '-1' );
35
+ wp_raise_memory_limit( 'go-live-update-urls/database/memory-limit' );
36
+ }
37
+
38
+
39
+ /**
40
+ * Raise the memory limit while the Database runs.
41
+ * If the memory limit is higher than self::MEMORY_LIMIT
42
+ * this will do nothing.
43
+ *
44
+ * @uses wp_raise_memory_limit();
45
+ *
46
+ *
47
+ * @return string
48
+ */
49
+ public function raise_memory_limit() {
50
+ return self::MEMORY_LIMIT;
51
}
52
53
72
return $db->update_the_database( $old_url, $new_url, $tables );
73
}
74
75
+
76
/**
77
* Get a view file from the theme first then this plugin
78
*
src/Database.php CHANGED
@@ -177,12 +177,6 @@ class Go_Live_Update_Urls_Database {
177
178
do_action( 'go-live-update-urls/database/before-update', $old_url, $new_url, $tables, $this );
179
180
- if ( ! defined( 'WP_MEMORY_LIMIT' ) || preg_replace( '/[^0-9,.]/', '', WP_MEMORY_LIMIT ) < 256 ) {
181
- @ini_set( 'memory_limit', '256M' );
182
- }
183
- @set_time_limit( 0 );
184
- @ini_set( 'max_input_time', '-1' );
185
-
186
$updaters = (array) Go_Live_Update_Urls__Updaters__Repo::instance()->get_updaters();
187
188
// If the new domain is the old one with a new sub-domain like www
@@ -194,8 +188,8 @@ class Go_Live_Update_Urls_Database {
194
$serialized_tables = $this->get_serialized_tables();
195
$tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
196
197
- //backward compatibility for PRO 2.2.1-
198
- if ( ! array_values( $tables ) === $tables ) {
199
$tables = (array) array_flip( $tables );
200
}
201
@@ -211,8 +205,8 @@ class Go_Live_Update_Urls_Database {
211
}
212
}
213
214
- $column_query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME='" . $table . "'";
215
- $columns = $wpdb->get_col( $column_query );
216
217
foreach ( $columns as $_column ) {
218
$update_query = 'UPDATE ' . $table . ' SET ' . $_column . ' = replace(' . $_column . ', %s, %s)';
177
178
do_action( 'go-live-update-urls/database/before-update', $old_url, $new_url, $tables, $this );
179
180
$updaters = (array) Go_Live_Update_Urls__Updaters__Repo::instance()->get_updaters();
181
182
// If the new domain is the old one with a new sub-domain like www
188
$serialized_tables = $this->get_serialized_tables();
189
$tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
190
191
+ // Backward compatibility
192
+ if ( array_values( $tables ) !== $tables ) {
193
$tables = (array) array_flip( $tables );
194
}
195
205
}
206
}
207
208
+ $column_query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='{$wpdb->dbname}' AND TABLE_NAME=%s";
209
+ $columns = $wpdb->get_col( $wpdb->prepare( $column_query, $table ) );
210
211
foreach ( $columns as $_column ) {
212
$update_query = 'UPDATE ' . $table . ' SET ' . $_column . ' = replace(' . $_column . ', %s, %s)';