forked from Blogestudio/Fix-Serialization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
38 lines (23 loc) · 1.21 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Fix Serialization
A PHP script to fix length attributes for serialized strings over database dumps (e.g. Wordpress databases)
This script can be useful if you perform text replacements in database dumps containing serialized data structures,
so that reconstructs the serialized length attribute and prevents the serialized offset error in code execution.
How to use:
- Execute directly this script in the way:
- In place file processing
/usr/bin/php fix-serialization.php my-sql-file.sql
- Stream processing Examples
-- Uncompressed to uncompressed
cat my-sql-file.sql | /usr/bin/php fix-serialization.php --stream > my-sql-fixed-file.sql
-- Compressed to compressed
gunzip < my-sql-file.sql.gz | /usr/bin/php fix-serialization.php --stream | gzip > my-sql-fixed-file.sql.gz
-- Direct import into mysql from compressed
gunzip < my-sql-file.sql.gz | /usr/bin/php fix-serialization.php --stream | mysql -uuname -p "database name"
- Or use the shell script replace.sh that replaces with sed command each sql file in directory and call fix-serialization script
sh replace.sh
Licensed under the GPL version 3 or later:
http://www.gnu.org/licenses/gpl.txt
Regards,
Pau Iglesias
Blogestudio
http://blogestudio.com/