Skip to main content
Topic: Server migration with exception (Read 7191 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Server migration with exception

Hi guys.  Me again.   :D

Working on an unmanaged server migration.  The learning curve is strong.  There is likely stupidity mixed with the monkey business.  Anyway, the site (mostly) loads and is (mostly?) operational.  The things that don't work:  can't upload attachments, can't post, can't see formerly attached images, can't access attachment settings in ACP.  That's what I've noticed so far.  There is an exception that pops up in each case:

Code: [Select]
Exception: safe_unserialize: unknown/malformed type: s

This is most likely a configuration error as this was a perfectly operational forum on the old server.  Anyone have ideas?  Thanks!!

Re: Server migration with exception

Reply #1

Server build? Php version?

Re: Server migration with exception

Reply #2

hmm...
Interesting one.

The safe_unserialize is a "custom" (actually one coming from the internet) version of the php equivalent unserialize, whose only difference is not wake up serialized classes (avoiding possible attacks).

Try one thing, open /sources/ext/serialize.php, search for:
Code: [Select]
			throw new \Exception('safe_unserialize: unknown/malformed type: '.$type);

and replace it with:
Code: [Select]
			throw new \Exception('safe_unserialize: unknown/malformed type: '.$type . '<br>String: <pre>' . Util::htmlspecialchars($str) . '</pre>');
then, if the error doesn't contain anything sensible, feel free to post it here, otherwise send me a PM. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Server migration with exception

Reply #3

The edit produces 500 errors when trying to access attachment settings.  Still no attachments visible on the forum.  Absolutely nothing in the error log.

Re: Server migration with exception

Reply #4

Oh, if I manually change the currentAttachmentUploadDir in the database, I can access the attachment settings in ACP. 

Obviously this causes a problem when trying to rename the attachment directory to the proper path. 

Code: [Select]
Warning: rename(a:1:{i:1;s:36:"/var/www/clients/client0/web1/web/attachments";},/var/www/clients/client0/web1/web/attachments): No such file or directory

Re: Server migration with exception

Reply #5

Ok. My guess - your server is nginx + debian/ubuntu build (may be + ISPConfig too) as var/www/clients/client0/web1/web format is similar.

I think the cause could be the file and/or the directory ownership. Check that, and if my guess is correct may be do the chown web1:client0 -R (recursively) on that /var/www/clients/client0/web1/web folder.

Extra note, as a practice suggestion, do not use client0 to build a website as it is the admin. Create a reseller and then client(s) under him. Later use any client under the reseller to create a website, instead of the admin or the reseller.

Sorry if this post is or sounds nonsense.

Re: Server migration with exception

Reply #6

Quote from: badmonkey – Oh, if I manually change the currentAttachmentUploadDir in the database, I can access the attachment settings in ACP. 
Yes, my guess was the attachments dir serialized string, but I wanted to see what was the string causing the issue. :)

Quote from: badmonkey – Obviously this causes a problem when trying to rename the attachment directory to the proper path. 

Code: [Select]
Warning: rename(a:1:{i:1;s:36:"/var/www/clients/client0/web1/web/attachments";},/var/www/clients/client0/web1/web/attachments): No such file or directory
Did you by chance run a query to update all the paths at once?
Something like:
Code: [Select]
update elkarte_settings set value = replace(value, '/your/old/path/', '/your/new/path');
Bugs creator.
Features destroyer.
Template killer.

Re: Server migration with exception

Reply #7

Quote from: ahrasis – Ok. My guess - your server is nginx + debian/ubuntu build (may be + ISPConfig too) as var/www/clients/client0/web1/web format is similar.

I think the cause could be the file and/or the directory ownership. Check that, and if my guess is correct may be do the chown web1:client0 -R (recursively) on that /var/www/clients/client0/web1/web folder.

Extra note, as a practice suggestion, do not use client0 to build a website as it is the admin. Create a reseller and then client(s) under him. Later use any client under the reseller to create a website, instead of the admin or the reseller.

Sorry if this post is or sounds nonsense.

I went the ispconfig route on your suggestion.  ;)  It's part of the learning curve too.  haha.  Good suggestion on chown/chmod.  That did occur to me but unfortunately that's not the fix.  Definitely worth checking.  :) 

It's Centos 6.8, nginx, php 5.6 fpm, mariadb. 

Your suggestions make sense.  It will take time for me to wrap my head around what I need to do.  May have to pick your brain from time to time.  ;D  Thanks!!



Quote from: emanuele –
Quote from: badmonkey – Oh, if I manually change the currentAttachmentUploadDir in the database, I can access the attachment settings in ACP. 
Yes, my guess was the attachments dir serialized string, but I wanted to see what was the string causing the issue. :)

Quote from: badmonkey – Obviously this causes a problem when trying to rename the attachment directory to the proper path. 

Code: [Select]
Warning: rename(a:1:{i:1;s:36:"/var/www/clients/client0/web1/web/attachments";},/var/www/clients/client0/web1/web/attachments): No such file or directory
Did you by chance run a query to update all the paths at once?
Something like:
Code: [Select]
update elkarte_settings set value = replace(value, '/your/old/path/', '/your/new/path');

No.  I updated the paths in Settings.php, then went in through phpmyadmin and set everything manually in the settings table, one by one.  Is that a bad method?  It's definitely something wrong with the attachments settings. 

The original files and database still exist on the old server.  I replaced all the files a second time in case there was a corrupt transfer, as well as double checked the attachment directory setting in the database.  It's very strange the manual update will not cause the software to "see" the new directory path. 

Re: Server migration with exception

Reply #8

I think won't work since it looks like it stored in a serialized array
Code: [Select]
a:1:{i:1;s:36:"/var/www/clients/client0/web1/web/attachments";},
Should be
Code: [Select]
a:1:{i:1;s:45:"/var/www/clients/client0/web1/web/attachments";},
36 is the length of the string correct size should be 45

Re: Server migration with exception

Reply #9

Quote from: badmonkey – No.  I updated the paths in Settings.php, then went in through phpmyadmin and set everything manually in the settings table, one by one.  Is that a bad method?
Yep, bad method...
As vbgamer explained the serialized strings break that way.
The "correct" way was to open up the admin panel and fix the paths there. The ACP was not accessible because of the error in the serialized string, but if the string was "fine" (in terms of serialization) and the paths were wrong, you would have been able to access it and fix one by one from there. :)
Bugs creator.
Features destroyer.
Template killer.

Re: Server migration with exception

Reply #10

Quote from: badmonkey – I went the ispconfig route on your suggestion.  ;)  It's part of the learning curve too.  haha.  Good suggestion on chown/chmod.  That did occur to me but unfortunately that's not the fix.  Definitely worth checking.  :) 

It's Centos 6.8, nginx, php 5.6 fpm, mariadb. 

Your suggestions make sense.  It will take time for me to wrap my head around what I need to do.  May have to pick your brain from time to time.  ;D  Thanks!!

Good to hear that. Centos is indeed a good choice.

I am personally running 16.04 ubuntu server now with nginx + php 7.0 + ispc 3.1.2 to keep closer to ispc developer settings i.e. based on original debian.

I am currently stuck in restoring 1.1 b 3 site and I think my nginx and optional php5.6.30 config may be the cause for being not properly configured. At first, I feel I want to just rebuild them but other sites are working just fine. So, I choose to rebuild elkarte 1.1 instead.

By the way, how do you edit all the files? Do you have your own ftp like net2ftp installed or you are using other client?

Sorry, if this post is a little bit out of topic. I hope you fix your serialize problem though it shouldn't have occurred since it was running fine in your previous server.

 

Re: Server migration with exception

Reply #11

Told you guys I knew enough to be dangerous or cause trouble.  ;D 

OK, the database edit fixed the ability view attachments and their ACP settings.  Yay!!  Thanks guys!


Now, there is still an issue with the Attachment Image Resize mod.  Posting is still impossible unless the mod is uninstalled or attachment upload is disabled.  Here's the error from the site error log:

Code: [Select]

FastCGI sent in stderr: "PHP message: PHP Fatal error:  Class 'Attachment_Error_Context' not found in /var/www/clients/client0/web1/web/sources/subs/Air_Resize.subs.php on line 126" while reading response header from upstream,


Re: Server migration with exception

Reply #12

Quote from: ahrasis –
Quote from: badmonkey – I went the ispconfig route on your suggestion.  ;)  It's part of the learning curve too.  haha.  Good suggestion on chown/chmod.  That did occur to me but unfortunately that's not the fix.  Definitely worth checking.  :) 

It's Centos 6.8, nginx, php 5.6 fpm, mariadb. 

Your suggestions make sense.  It will take time for me to wrap my head around what I need to do.  May have to pick your brain from time to time.  ;D  Thanks!!

Good to hear that. Centos is indeed a good choice.

I am personally running 16.04 ubuntu server now with nginx + php 7.0 + ispc 3.1.2 to keep closer to ispc developer settings i.e. based on original debian.

I am currently stuck in restoring 1.1 b 3 site and I think my nginx and optional php5.6.30 config may be the cause for being not properly configured. At first, I feel I want to just rebuild them but other sites are working just fine. So, I choose to rebuild elkarte 1.1 instead.

By the way, how do you edit all the files? Do you have your own ftp like net2ftp installed or you are using other client?

Sorry, if this post is a little bit out of topic. I hope you fix your serialize problem though it shouldn't have occurred since it was running fine in your previous server.

Good luck with restoration.  Basically sums up migration too lol!

For file editing I use WinSCP as the client with Notepad++ chained in as the actual editor.  There are some quirks but it works nicely overall.  WinSCP works well enough for single file transfers.  Or for maybe a handful.  For large batch transfers, it's back to Filezilla since it can perform 10 simultaneous file transfers.  Suggestions are welcome!!  ;)

Re: Server migration with exception

Reply #13

Hey guys!  I moved another site to the new server.  Still have the two larger sites to move as well.  Also still trying to learn how to make it a smooth transition. 

On eman's suggestion, the first move was to try to correct the attachment settings in the ACP.  The problem is when the folder structure is completely different, an error is encountered and that part of the ACP is unreachable.  So ACP correction is impossible unless I did it wrong again.  Either way, this makes migration at best difficult.  It may be something you guys want to address?  The workaround is to set the attachment directory in the settings table to:

Code: [Select]
a:1:{i:1;s:0:"";}

Then you can set the correct path in the ACP.

Another noted behavior is the inability to post from the full Reply page if the attachment settings are incorrect.  It produces an error message stating attachments cannot be uploaded even if there are none to be uploaded.  Not sure that's a good behavior as something as simple as incorrect folder permissions or a typo can make the forum useless as well as impossible to correct within the site itself.  The workaround is to manually disable attachments in the settings table. 
Last Edit: February 03, 2017, 10:11:43 am by badmonkey

Re: Server migration with exception

Reply #14

Yep, I guess there is something to take care of.
In theory, to make the transition smooth, there is repair settings, but TBH, I don't remember if I pushed the fix for the multiple attachments directories... :-[
Bugs creator.
Features destroyer.
Template killer.