Incorrect package install_state

Started by Sir Osis of Liver, February 07, 2020, 01:10:00 PM

Previous topic - Next topic

Sir Osis of Liver

I have yet another forum where package manager is listing installed mods as uninstalled.  All 25 mods are displayed as uninstalled, but most are installed.  install_state in _log_packages is '0' for all packages.  I'm rebuilding the forum on my server (home server is a mess) using an incomplete but useable db dump from home server.  Plan is to reinstall packages on clean install, copy all files back to prod server and connect it to prod database, and import _log_packages from clean install to prod database, so installed packages are displayed correctly.  Exporting/importing full dumps of 1.2 gb db on home server is not an option, I have to work with what's there.  Two questions:

- Will this work?

- What causes install_state to revert to '0' for installed packages?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

if the installlist.txt file or similar is removed or modified it will cause this.

Sir Osis of Liver

installed.list is in /Packages/, contains 10 digit number, as do all installed.list files I checked on several other installs.  What does it do?  What does the number mean?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Shambles


Sir Osis of Liver

But why does it affect install_state?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Shambles

Quote from: Sir Osis of Liverpool
But why does it affect install_state?


Seems like that installed.list file is quite important...

Quote from: Illori on February 07, 2020, 01:29:49 PM
if the installlist.txt file or similar is removed or modified it will cause this.


Code (Subs-Package.php) Select

// Load the installed packages.
function loadInstalledPackages()
{
global $boarddir, $smcFunc;

// First, check that the database is valid, installed.list is still king.
$install_file = implode('', file($boarddir . '/Packages/installed.list'));
=> if (trim($install_file) == '')
{
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_packages
=> SET install_state = {int:not_installed}',
array(
'not_installed' => 0,
)
);

Sir Osis of Liver

Yep, that'll do it.  Can't imagine why that's there.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Shambles

Someone had a coding aberration when that was written = I can see no reason for that decision either.

Shambles

Quote from: Sir Osis of Liver on February 07, 2020, 09:23:25 PM
installed.list is in /Packages/, contains 10 digit number, as do all installed.list files I checked on several other installs.

The real question is... if your installed.list file is intact on the forums you built/tested, why did the quoted code feel the need to get executed? All it's doing is ensuring the content can be extracted.

Sir Osis of Liver

installed.list is there and contains 1578198467 (Jan 4 2020).  25 mods listed, 22 marked uninstalled, 1 installed, 2 with no install/uninstall link (both obsolete).  Most of uninstalled mods are running.  This has been reported here on at least a couple of forums recently.  Go figure.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

that is why we created the fix_packages.php file to fix issues like this.

this has been fixed for good in SMF 2.1.

Sir Osis of Liver

fix_packages can reset packages to uninstalled, but not installed.  Would be difficult on some of these forums to determine which are installed or not.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

it does both.

there is a link at the bottom that will swap it to show what is uninstalled to set as installed.

Sir Osis of Liver

Never saw that.  But still leaves the problem of identifying which mods are actually installed.  It's easy if there are just a few, but if there are a lot, and don't recognize many of them, have to pick through them one at a time on the mod site to determine if they're installed. 

What is the purpose of setting install_state to '0' if installed.list is empty or missing?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

I cannot answer that. the devs that made that decision are no longer around to ask.

Sir Osis of Liver

I know devs are all busy with 2.1, but that's something that should be reviewed and the code removed if it's not absolutely necessary.

And btw, where's Arantor?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori


Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

Just looked at the code in 2.0 & 1.1... 

In 1.x, there was no log_packages table tracking the status of the packages.  installed.list actually contained the installed package info in text form.  Losing that file meant losing all of your package install history. 

In 2.0.x, as near as I can tell, that file isn't used for anything at all.  The DB contains info about the installed packages.  Installed.list only contains a timestamp of the last update, but I don't even see that timestamp used anywhere. 

So...  Yeah...  That logic looks a little dangerous, with no positive utility I can see at all. 

I logged this as #141 in our internal log.  No promises on priority.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Sir Osis of Liver

Odd thing is I don't remember seeing this glitch until fairly recently, maybe something in .16/.17 triggers it?  And the file is there and contains timestamp, so why would it reset install_state?  That should only happen if file is missing or empty.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

There are lots of things that might affect that read.  Permissions, $boarddir, etc.  I'd start looking there. 

I don't think there's anything in .16/.17 that would affect this; there's something else going on.  I do lots of restores & rebuilding environments in my testing (windows & linux) and I've never seen that.

Note there is also a FlushInstall function out there that does the same thing, but I haven't found where that's called from. 


Unrelated side-note...  For your awareness...  Prior to 2.0.16, the SMF error logging function was defined very late.  That's why, in many instances (e.g., mail queue issues, several undefined indexes...) we would not see errors in the smf error log, but would see them in the apache log.  We fixed that in 2.0.16.  Which is a good thing in that errors are more visible now.  But...  Old errors that were previously hidden are now visible in the log... 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Sir Osis of Liver

Quote from: shawnb61 on February 10, 2020, 11:23:41 PM
Old errors that were previously hidden are now visible in the log... 

That'll be a big help dealing with damaged forums.  Some of them go titsup and there's nothing in forum or server logs.   I've got one now that's throwing random 403s, host support keeps blaming forum but nothing's changed and it's running clean.  They're at 2.0.15, didn't want to upgrade til this gets resolved, but maybe I'll bump him up and see if any errors are logged at .17.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Just happened again on different forum, installed.list was there but empty, all mods marked uninstalled.  Has anyone determined how installed.list gets damaged?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Herman's Mixen

It happend sometimes, but its not important.. its how SMF was designed back in the days... When Unknown .W Brackets... started this coz we needed to move on from YABBSE ;)

There are several fixes for this, but haven't seen recent stuff like you do !!
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

Advertisement: