News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

repair_settings appears to work, database doesn't update

Started by nc3man, March 21, 2023, 09:47:11 PM

Previous topic - Next topic

nc3man

I just migrated to a new server. Our staging domain changes both the site url and all the file paths. When I run repair_setting.php from the browser (https://{our_domain}/smf) it looks perfect. It takes all the urls and paths in our Settings.php and displays them as expected. When I hit the Save button, I do not get changes to either urls or paths in smf_log_packages, smf_settings, smf_themes. At least I can readily edit the database directly, so I'm not lost but would like to save the manual step every time I update our staging domain from our live domain. I also set permissions on repair_settings.php to 777 for grins. No dice. There are no errors whatsoever in the error logs. This appears to be a good tool ... perhaps I'm misunderstanding proper use?

Arantor

repair_settings.php fixes the most important settings: the things in Settings.php and the paths to at least the default theme - other URLs will need changing by hand, especially in the case of smf_settings because there's a fair chance it won't know which ones need changing. It's mostly a 'fix the most important things when they're really broken so you can get back in to admin to fix the rest' kind of tool.

It definitely doesn't touch paths in smf_log_packages last I checked.

nc3man

Good to understand the intent of the tool - the log_packages table is just a reference. It is easy to just do quick repairs to smf_settings and smf_themes. I'll just write a little script with about a dozen SQL updates to those tables. At least for those tables, it would have been nice to update the db since it certainly knows what to do based on the display. Thanks.

Kindred

repair_settings WILL correct paths for themes, smilies, avatars, attachments....

however, you may have to SAVE twice.
The first time to correct the settings to the database and main files.
then the second correction to save the updates which are stored in the database that you just corrected.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

nc3man

That's interesting @Kindred. I pressed Save 2,3,4, ... times and the database values in smf_settings and smf_themes do not update. This is what I do for cloning to a test domain:
Live set up is at url = https://domain/smf, file path is /home/user/domain/smf.
Test set up is at url = https://test.domain/smf, file path is /home/user/test.domain/smf

I drop all tables in our test_smf database and then import all tables from our working smf database.

In /home/user/test.domain/smf, I edit Settings.php to ensure boardurl points to https://test.domain/smf, we're connecting to the test_smf database, and that other urls and file paths point correctly to test.domain/smf as well.

I then run https://test.domain/smf/repair_settings.php, examine all the settings and they properly show test.domain/smf. The settings display in the repair_settings confirmation page look perfect, all now point to test.domain/smf. I set Connection type to Standard, Cache System: FileBase, and press Save. Examining tables smf_settings, smf_themes the relevant fields STILL point to our live domain/smf ... no matter how many times I press Save. There are no errors in our error log. Our host is Dreamhost, so we don't use localhost for MySQL - their model is a separate server which is tuned to only do the MySQL work, but there is no issue connecting and functioning once I manually adjust the needed test_smf tables.

Any idea what is wrong here? I've been doing this since ~2007, btw (not the repair_settings.php piece, but taking care of the files and db manually whenever we have a domain name or server migration).

nc3man

Here is another piece which could affect things. We started out with SMF 1.1 many years ago and have kept all our posts in perpetuity since 2007 - only ~3100 topics, small compared to this community forum. Anyway, I have always run through your upgrade process, originally quite manual, and eventually pretty slick with the package manager, although some of the upgrade process for major updates require some manual stuff. I'm wondering if there is some lingering record in our arguably old database because I fat-fingered something along the way that is getting in the way. We certainly haven't lost our posts and SMF always works great for us. Is there a database integrity tool that can check something like that and even make repairs or suggest action?

Kindred

are you using the newest repair_settings.php version?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Steve

DO NOT pm me for support!

nc3man

Quote from: Steve on March 22, 2023, 08:23:05 AMWhich is as far as I know: https://wiki.simplemachines.org/smf/Repair_settings.php/en
That is EXACTLY where I picked it up. I just downloaded again and diffed: binary same. It looks like the tool is meant for someone who made ZERO edits to Settings.php. In my case, I edited it pretty thoroughly. If I hadn't, since our live site uses the same filesystem and MySQL server, I was assuming that just firing up repair_settings.php in the first place would do something bad on our live site. It's as if something in the code just doesn't even open up a MySQL connection to shove the correct settings to the database, possibly because I had every single setting in Settings.php already correct before invoking repair_settings? I want to force the update somehow - it's only a few SQL update queries.

Aleksi "Lex" Kilpinen

Well, yes - It's a tool to avoid having to edit Settings.php, so it's really only to be expected that it might not like if you have edited it "thoroughly".

But, if repair_settings shows you theme related settings, then it has already looked them up from the DB currently defined in Settings.php (and also shown in repair_settings). Now if you change any settings, they will be made in that DB, unless you first change the DB settings, save, reload and start over.
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

nc3man

Quote from: Aleksi "Lex" Kilpinen on March 22, 2023, 12:47:34 PMWell, yes - It's a tool to avoid having to edit Settings.php, so it's really only to be expected that it might not like if you have edited it "thoroughly".

But, if repair_settings shows you theme related settings, then it has already looked them up from the DB currently defined in Settings.php (and also shown in repair_settings). Now if you change any settings, they will be made in that DB, unless you first change the DB settings, save, reload and start over.

Are you really saying that if I changed Settings.php correctly that no action will be taken? It thinks there is NO work to do just because that file is correct, but the database still has all references to the previous installation? There must be other admins who know how to carefully edit their Settings.php. It would be dangerous to bring up this tool pointing to a completely different database for another domain. I guess I would never fire up repair_settings.php with an old Settings.php for a completely different environment, which we may still need to leave in place.

Aleksi "Lex" Kilpinen

No, I'm saying that if you are seeing theme related settings in repair_settings, then you do have a working DB connection, and are already seeing values from the database. Also, simply running repair_settings does nothing to your install, it only looks up values and presents them.
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Sir Osis of Liver

Don't know if this is relevant, but older versions of repair_settings had a button to "Update all Paths & URLs" to recommended value, and a "Save Settings" button.  Current version does not have the update button, you have to manually click recommended value to update path before saving or setting does not change.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

The "restore all settings" link at the bottom applies all the recommendations.

That's all I ever do - once the db settings are correct, and all the paths are displayed, I just hit the restore link, do a quick scan for sanity, & hit save. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

nc3man

Quote from: Sir Osis of Liver on March 22, 2023, 01:26:20 PMDon't know if this is relevant, but older versions of repair_settings had a button to "Update all Paths & URLs" to recommended value, and a "Save Settings" button.  Current version does not have the update button, you have to manually click recommended value to update path before saving or setting does not change.
Oh my ... this was a UI issue on my part. Since the recommended values were all correct because of the Settings.php thorough edits, I just looked at them as they were bolded and assumed when I pressed Save, they would be taken. I just need to click each one. Yes, a button to update to all recommended URLs and Paths would be handy, avoiding a bunch of clicks. Problem solved, Mr. Liver 8)

nc3man

Quote from: shawnb61 on March 22, 2023, 01:53:10 PMThe "restore all settings" link at the bottom applies all the recommendations.

That's all I ever do - once the db settings are correct, and all the paths are displayed, I just hit the restore link, do a quick scan for sanity, & hit save. 
Thanks for that tip, too @shawnb61. A couple of the recommended settings aren't correct (localhost needs to be a real server url for us), but that's quicker than clicking on all those recommendations. It wasn't clear what "restore all settings" would do - I thought it might go back to an initial set of defaults when installing.

shawnb61

All it can do is make a guess & offer a suggestion.

It's up to you to ensure the paths are proper before hitting save.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

nc3man

Quote from: nc3man on March 22, 2023, 02:04:45 PM... It wasn't clear what "restore all settings" would do - I thought it might go back to an initial set of defaults when installing.
I realize this is a nit for all of you replying who obviously use repair_settings all the time, but changing the label on the "Restore all settings" button to "Apply all recommendations" would certainly be helpful for a first time user of repair_settings in addition to more accurately describing what pressing that button does.

Aleksi "Lex" Kilpinen

That's actually perfectly good and valid feedback, and I think I agree with your suggestion.

https://github.com/SimpleMachines/tools/issues/65
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

nc3man

Quote from: Aleksi on March 22, 2023, 02:48:51 PMThat's actually perfectly good and valid feedback, and I think I agree with your suggestion.
Thanks. I already changed mine. A simple edit to line 30 in repair_settings.php  8)
$txt['restore_all_settings'] = 'Apply all recommendations';

Advertisement: