Skip to main content
Topic: No packages after addons installed (Read 6421 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

No packages after addons installed

Clean install of 1.1 RC1. Package Manager is empty (no packages yet) and Installed Packages shows nothing on its list after successful install of addons. Is it a known bug that I missed or forgot?

I only got this in error log but is unlikely related to package manage but more to the install. It happened once only.
QuoteNotice: Undefined index: USER_AGENT
http://forum.sch.my/index.php?
File: /var/www/clients/client2/web15/web/sources/Load.php
Line: 208

Re: No packages after addons installed

Reply #1

I ran across the same issue, but I thought it might be because I was doing some partially failed install/uninstall actions during add-on development.

Edit: hm, I've got 1 at install state one and 3 at install state 2 but none are showing.

Running the query myself I indeed get 4 results.

Code: [Select]
SELECT id_install, package_id, filename, name, version FROM elkarte11_log_packages WHERE install_state != 0 ORDER BY time_installed DESC 

Yet shouldn't those show up in the package manager?

Edit 2: also, even if I did cause it with a partially broken install or uninstall it should probably be more robust against that.

Edit 3: anyway, none of those have a time_installed. Weird.
Last Edit: February 09, 2017, 06:33:10 am by Frenzie

Re: No packages after addons installed

Reply #2

Okay, so everything seems fine. I just installed an add-on. In the DB it says time_installed 1486640301

In installed.list it says 1486640301

But it's not showing. Everything's still fine in loadInstalledPackages, which returns
Code: [Select]
Array
(
    [0] => Array
        (
            [id] => 21
            [name] => Stop Spammer
            [filename] => elk-stop-spammer.zip
            [package_id] => Frenzie:StopSpammer
            [version] => 3.0
        )

)
I'll see if I can track down where it goes wrong.

Re: No packages after addons installed

Reply #3

Okay, I found it. The problem is this commit (by you :P): https://github.com/elkarte/Elkarte/commit/efdb6e7f32730ee4463e60ed32e620ee08ff7dbb

Edit: The problem there is that you changed the logic, which was good. open_basedir probably means you have a permission issue on your own server. Maybe there's a way to prevent that, but this commit should be reverted. :)

Alternatively it could mean that $current is giving out the wrong directory, which perhaps could happen if the DB points to the wrong location.

Edit 2: PR here: https://github.com/elkarte/Elkarte/pull/2865

I'll be glad to help work out where the open_basedir error is coming from. Like I said, my first guess is permissions.
Last Edit: February 09, 2017, 07:19:43 am by Frenzie

Re: No packages after addons installed

Reply #4

Reverting won't open package manager at all and will only shows this error:
Quotefile_exists(): open_basedir restriction in effect. File(/var/www/clients/client2/web15/web/packages/Masa.sahabat.ahrasis.com.v.104.zip/package-info.xml) is not within the allowed path(s): (/var/www/clients/client2/web15/web:/var/www/clients/client2/web15/private:/var/www/clients/client2/web15/tmp:/var/www/forum.sch.my/web:/srv/www/forum.sch.my/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom)

This has been discussed before and at that point of time (1.1 Beta 3), it already fixed the error and package manager is showing properly. Other setup of 1.0.9 is working fine with no issue of open_basedir. This happened only to EA 1.1. Opening it is not safe at all. There is definitely "something" in the code that causes this though I do not know what it is.

Re: No packages after addons installed

Reply #5

Looking a tad better at the error:
Code: [Select]
/var/www/clients/client2/web15/web/packages/Masa.sahabat.ahrasis.com.v.104.zip/package-info.xml
so you have a directory named "Masa.sahabat.ahrasis.com.v.104.zip"?
And just to be sure, it's really a directory or a symlink? (I ask because I frequently do this kind of... mistakes O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: No packages after addons installed

Reply #6

It this a mockery or something because you should have known that better.

That is clearly an addon package name installed which is in the /web/packages folder as /web is the root folder where elkarte 1.1 RC 1 is installed, and definitely is not a symlink or a directory. That is also clearly within the permitted open_basedir of /var/www/clients/client2/web15/web.

EA 1.1 doesn't read the addons in the packages directory correctly but EA 1.0 in the same server does. So the problem lies somewhere in the enhanced code for packages in 1.1 RC 1.

Re: No packages after addons installed

Reply #7

I have resolved this by reverting back to Packages.controller.php and Packages.subs.php from 1.1 Beta 3 of which the fixed has been forwarded before.

All I can say is something are definitely wrong when certain code are ported to the new PackagesFilterIterator.class.php. That from what I believe is from this part of the 1.1 Beta 3 Packages.controller.php:
Code: [Select]
				if ($package->getFilename() == 'temp'
|| (!($package->isDir() && file_exists($package->getPathname() . '/package-info.xml'))
&& substr(strtolower($package->getFilename()), -7) !== '.tar.gz'
&& strtolower($package->getExtension()) !== 'tgz'
&& strtolower($package->getExtension()) !== 'zip'))
continue;

Something went wrong when that code are converted to this in 1.1 RC 1 PackagesFilterIterator.class.php:
Code: [Select]
	public function accept()
{
$current = $this->current();
$filename = $current->getFilename();

// Skip hidden files and directories.
if ($filename[0] === '.')
{
return false;
}

// The temp directory that may or may not be present.
if ($filename === 'temp')
{
return false;
}

// Anything that, once extracted, doesn't contain a package-info.xml.
if (!($current->isDir()) && file_exists($current->getPathname() . '/package-info.xml'))
{
return false;
}

// And finally, accept anything that has a "package-like" extension.
return
substr(strtolower($filename), -7) == '.tar.gz'
|| substr(strtolower($filename), -4) != '.tgz'
|| substr(strtolower($filename), -4) != '.zip';

I cannot read a code written in advanced ways quite well so I couldn't find fault with it. Those who able to read it, can most probably see its fault.

Re: No packages after addons installed

Reply #8

Quote from: ahrasis – It this a mockery or something because you should have known that better.
Not really.
When I test, I do not use packages, I just have a directory with the name of the zip (frequently including the extension) with the files inside, so that I can just edit the files and test "live" the changes without having to re-package everything every time.
And frequently they are just symlink to the repo.

Quote from: ahrasis – That is clearly an addon package name installed
It's not actually that clear.
Unzipped files are not stored in "packages" directly, but in "temp".
In the code without your change, this path passes the test for "isDir"
Code: [Select]
$current->isDir()
so it must be a directory and not a zip file, but you say it is a file.

Do you see where my doubt comes from?

Is the account you passed me a while ago configured the same way?
Bugs creator.
Features destroyer.
Template killer.

Re: No packages after addons installed

Reply #9

Have you tried some debugging to see what happens exactly? Stick something like this where it goes wrong and we'll know more.

Code: [Select]
		if (!($current->isDir()))
{
// what's the pathname?
print_r('getPathname ' . $current->getPathname() . "\n");
// is just the path any different?
print_r('getPath ' . $current->getPath() . "\n");
// what's the type?
print_r('getType ' . $current->getType() . "\n");
return false;
}

PS Normally I'd throw error_log around that and watch the error logs with tail -f, but that only works on a server properly under your control like a VPS or your own computer. Plus you'd need to know what I'm talking about. This way you only need to view source. :)

Anyway, if you do know what I'm talking about use
Code: [Select]
error_log(print_r('getPathname ' . $current->getPathname(), true));

Edit:
@emanuele If I understand correctly you're saying the code should actually be this?
Code: [Select]
if ($current->isDir() && !file_exists($current->getPathname() . '/package-info.xml'))
Actually in light of the comment that would make more senseā€¦
Last Edit: February 10, 2017, 09:01:03 am by Frenzie

Re: No packages after addons installed

Reply #10

No. I don't debug. I read the code and I compare the code. If the differences are small, it is normally easy to understand. If they are too much differences, I'll try to understand its reason why. If I got lucky, I understand them. If not I don't.

I know the code are different. One of them is tgz and zip was previously get by getExtension() but now getFilename(). Also last time they continue, now it return false. And last time they use && (and) now they use || (or).

I no, I don't understand why and I know I am not that learned in programming.

So, rather than blaming my server, what is your output? Is your solution by reverting back is the best you can do being learned in this?

Re: No packages after addons installed

Reply #11

Like I said, it sounds like the code might need to be this instead. It seems like PHP can be blamed for throwing open_basedir errors on files or directories that don't exist but are actually within allowed folders. I didn't know it displayed such strange behavior.

Code: [Select]
if ($current->isDir() && !file_exists($current->getPathname() . '/package-info.xml'))

Incidentally, @emanuele would it make sense to rewrite the whole thing with isDot() and getExtension()?

Re: No packages after addons installed

Reply #12

Ok @emanuele, let's try this shall we.

if (!($current->isDir()) && file_exists($current->getPathname() . '/package-info.xml'))
- If this is not a directory and if there exist a file under pathname/package-info.xml <--- This is wrong to me and previous code confirms it wrong too.

if (!($current->isDir() && file_exists($current->getPathname() . '/package-info.xml')))
- If this is not a directory and if there exist no file under pathname/package-info.xml <--- This right to me and previous code confirms it is right too.

Temp directory is only check while installing not after. I do say the installation went fine. What is needed to be checked is whether packages directory has addon package(s) or not where if it does, list them, if not don't. This is why I asked for support.

So this goes back to getFilename() for tar.gz and getExtension() for tgz and zip, previously.  But in RC 1, getFilename() is used for all. This might be caused of the error. But I do not know because I am tired of testing it while people easily jump into conclusion based on their bad assumption.

I have already said previous 1.0.9 install works fine and this include 1.1 Beta 3. I also confirmed that using previous files from Beta 3 in RC 1 works with no errors. So this is definitely a bug to me. So do check if you want and ignore if you want.

Re: No packages after addons installed

Reply #13

I hardly think it's fair to say that stating a hypothesis ("probably", "first guess") is jumping to conclusions, nor did I say the open_basedir issue is not a bug. I said that by almost always evaluating to true this change is what caused no packages to ever show.

Quoteif (!($current->isDir() && file_exists($current->getPathname() . '/package-info.xml')))
- If this is not a directory and if there exist no file under pathname/package-info.xml <--- This right to me and previous code confirms it is right too.
This almost always evaluates to true, hence why no packages will show. Remove the ! and they will, plus it will solve your open_basedir issue which was caused by this bug in PHP.

Re: No packages after addons installed

Reply #14

I prefer to read and follow the old code which already are proven than a hypothesis that leads no where and I already find its solution which is supposed to return true and not return false for both lines.

Code: [Select]
		// The temp directory that may or may not be present.
if ($filename == 'temp')
{
return true;
}

// Anything that, once extracted, doesn't contain a package-info.xml.
if (!($current->isDir() && file_exists($current->getPathname() . '/package-info.xml')))
{
return true;
}

This based on the previous code says to continue if the same conditions apply, and that is the solution. If this is accepted, I'll PR to the github.