• Welcome to Simple Machines Community Forum. Please login or sign up.

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?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Shambles


Sir Osis of Liver

But why does it affect install_state?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Illori


Sir Osis of Liver

"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

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.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Advertisement: