@john O
Yeah, right. People tend to make that mistake … dunno why … hihi
Just describe your issue as you did in this topic and then refer to this topic by including its URL.
dwinden
Thread Starter
John O
(@jossoway)
i have submitted a bug report, referencing this forum thread.
I will try your solution on my dev server and let you know how it goes.
Thanks again for all the help.
@john O
Are there any test results from your dev server ?
dwinden
Thread Starter
John O
(@jossoway)
Hi – tried it this morning. Still getting the same errors. π
Thread Starter
John O
(@jossoway)
No hang on – I didn’t create the backup with your new file in place. Sorry, long weekend. Watch this space…
@john O
Exactly … my first thought …
dwinden
Thread Starter
John O
(@jossoway)
It works! Sorry for the false alarm.
Database backup imported with no errors. A cursory look around the site and everything looks ok. Thank you so much. π
Is it worth telling iThemes that you have fixed this bug? I submitted a bug report and pointed them at this thread, so I am assuming they will fix things eventually?
Is there anything I need to know about the edited file? Is it ok to deploy on a live site or would you suggest waiting for iThemes to fix this?
@john O
Great, thanks for the confirmation.
You have linked to this topic in the bug report so I think that will do.
It is safe to deploy the fixed file on a live site.
Allthough I applied the fix to a 5.1.0 copy of the file you can continue using it for the recent 5.1.1 update. Nothing changed in the 5.1.1 copy of this backup file compared to the 5.1.0 file.
dwinden
Thread Starter
John O
(@jossoway)
Great thanks so much for all your help.
Can you explain what you did to make it work?
Is there any way to bring this to the attention of other iThemes users? Some people might be happily storing their db backups without checking they actually work.
@john O
Good point.
I’ve send you a personal message from the contact form on your website.
Currently busy having a cup of tea …;-)
dwinden
@john O
To fix this issue I changed the database backup code to check the datatype of every field in a table.
If the datatype is BINARY the data contained in the field is converted to hex using the bintohex() function and exported as such.
So basically binary data is converted to hex before exporting.
This way the binary data is exported like phpMyAdmin does.
These are the code changes:
-$num_fields = sizeof( $wpdb->get_results( 'DESCRIBE <code>' . $table[0] . '</code>;' ) );
+$tblstr = $wpdb->get_results( 'DESCRIBE <code>' . $table[0] . '</code>;', ARRAY_A );
-for ( $j = 0; $j < $num_fields; $j ++ ) {
+for ( $j = 0; $j < sizeof( $tblstr ); $j ++ ) {
+ if ( substr( $tblstr[$j]['Type'], 0, 6 ) !== 'binary' ) {
$row[$j] = addslashes( $row[$j] );
$row[$j] = preg_replace( '#' . PHP_EOL . '#', "\n", $row[$j] );
+ }
if ( isset( $row[$j] ) ) {
+ if ( substr( $tblstr[$j]['Type'], 0, 6 ) == 'binary' ) {
+ $return .= '0x' . bin2hex( $row[$j] );
+ } else {
$return .= '"' . $row[$j] . '"';
+ }
} else {
$return .= '""';
}
- if ( $j < ( $num_fields - 1 ) ) {
+ if ( $j < ( sizeof( $tblstr ) - 1 ) ) {
6 new lines and 3 modified.
dwinden