note 107594 added to function.serialize
| From: | lynch@php.net | Date: | Mon, 20 Feb 2012 16:56:31 +0000 |
| Subject: | note 107594 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186239@lists.php.net to get a copy of this message | ||
This one time, I had a Drupal database where we had changed the URLs/directories/paths out from
under it.
Of course, all images etc went missing.
So we wanted to mysqldump the SQL and hand-edit the paths with global search and replace.
Some of the data is stored serialized...
Subtracting the difference between "before" and "after" for each string was
quite tedious and error-prone, and I ended up bleary-eyed and making many mistakes.
PHP was "smart enough" to forgive when I was a bit "short" in the :a: count, but
going over was Bad News (tm).
Thus, I wrote this quick hack of a shell script in PHP to "fix" any wrong strlen counts in
the serialized data.
NOTE:
This *only* fixes 'string' data. I believe it could be easily extended for
'scalar' data types.
And perhaps even 'complex' data types, though hand-editing those might prove
challenging...
BACKUP YOUR DATA FIRST
NO PROMISE THIS WILL WORK FOR YOU
Preview:
http://6112northwolcott.com/serialized_string_fix.sh.txt
Syntax-highlighted:
http://6112northwolcott.com/serialized_string_fix.sh.phps
Download:
http://6112northwolcott.com/serialized_string_fix.sh
BACKUP YOUR DATA FIRST
NO PROMISE THIS WILL WORK FOR YOU
----
Server IP: 187.73.33.5
Probable Submitter: 67.128.187.35
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- https://master.php.net/note/edit/107594
Del: integrated -- https://master.php.net/note/delete/107594/integrated
Del: useless -- https://master.php.net/note/delete/107594/useless
Del: bad code -- https://master.php.net/note/delete/107594/bad+code
Del: spam -- https://master.php.net/note/delete/107594/spam
Del: non-english -- https://master.php.net/note/delete/107594/non-english
Del: in docs -- https://master.php.net/note/delete/107594/in+docs
Del: other reasons-- https://master.php.net/note/delete/107594
Reject -- https://master.php.net/note/reject/107594
Search -- https://master.php.net/manage/user-notes.php