Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Sir Osis of Liver on February 07, 2020, 01:10:00 PM

Title: Incorrect package install_state
Post by: Sir Osis of Liver on February 07, 2020, 01:10:00 PM
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?
Title: Re: Incorrect package install_state
Post by: Illori on February 07, 2020, 01:29:49 PM
if the installlist.txt file or similar is removed or modified it will cause this.
Title: Re: Incorrect package install_state
Post by: 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.  What does it do?  What does the number mean?
Title: Re: Incorrect package install_state
Post by: Shambles on February 08, 2020, 04:56:33 AM
The number is a Unix timestamp

https://www.epochconverter.com/
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 08, 2020, 04:41:17 PM
But why does it affect install_state?
Title: Re: Incorrect package install_state
Post by: Shambles on February 08, 2020, 05:17:43 PM
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,
)
);
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 08, 2020, 05:21:29 PM
Yep, that'll do it.  Can't imagine why that's there.
Title: Re: Incorrect package install_state
Post by: Shambles on February 08, 2020, 05:25:25 PM
Someone had a coding aberration when that was written = I can see no reason for that decision either.
Title: Re: Incorrect package install_state
Post by: Shambles on February 08, 2020, 05:38:26 PM
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.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 08, 2020, 06:16:25 PM
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.
Title: Re: Incorrect package install_state
Post by: Illori on February 09, 2020, 05:47:58 AM
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.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 09, 2020, 10:14:05 PM
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.
Title: Re: Incorrect package install_state
Post by: Illori on February 10, 2020, 04:55:52 AM
it does both.

there is a link at the bottom that will swap it to show what is uninstalled to set as installed.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 10, 2020, 11:43:53 AM
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?
Title: Re: Incorrect package install_state
Post by: Illori on February 10, 2020, 11:50:17 AM
I cannot answer that. the devs that made that decision are no longer around to ask.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 10, 2020, 12:02:12 PM
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?
Title: Re: Incorrect package install_state
Post by: Illori on February 10, 2020, 12:10:41 PM
he got pissed off again and left.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 10, 2020, 12:12:28 PM

<sigh>
Title: Re: Incorrect package install_state
Post by: shawnb61 on February 10, 2020, 09:50:29 PM
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.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 10, 2020, 10:19:05 PM
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.
Title: Re: Incorrect package install_state
Post by: shawnb61 on February 10, 2020, 11:23:41 PM
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... 
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on February 10, 2020, 11:32:47 PM
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.
Title: Re: Incorrect package install_state
Post by: Sir Osis of Liver on August 07, 2020, 01:24:18 PM
Just happened again on different forum, installed.list was there but empty, all mods marked uninstalled.  Has anyone determined how installed.list gets damaged?
Title: Re: Incorrect package install_state
Post by: Herman's Mixen on August 07, 2020, 02:28:58 PM
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 !!