Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guest access of public gallery causes yii\base\ErrorException #2849

Closed
ReliefCrew opened this issue Dec 6, 2017 · 5 comments
Closed

guest access of public gallery causes yii\base\ErrorException #2849

ReliefCrew opened this issue Dec 6, 2017 · 5 comments

Comments

@ReliefCrew
Copy link

What steps will reproduce the problem?

Site has "Allow limited access for non-authenticated users (guests)" checked and the user's gallery is set to public. Live example at: https://www.harleymotor.club/u/buddy/

What is the expected result?

The pictures are accessible via the stream. However, opening the gallery itself causes an exception.... either it should be allowed or a "need to authenticate" message should be presented; but an internal server error message is shown instead.

What do you get instead?

When guest attempts to visit the gallery an exception is created (note again, viewing pictures directly via stream works).

yii\base\ErrorException:8 yii\base\ErrorException: Trying to get property of non-object in /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/Module.php:148 Stack trace: #0 /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/Module.php(148): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/home/i98899/we...', 148, Array) #1 /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/controllers/BaseController.php(42): humhub\modules\gallery\Module::canWrite(Object(humhub\modules\user\models\User)) #2 /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/views/custom-gallery/gallery_view.php(32): humhub\modules\gallery\controllers\BaseController->canWrite(false) #3 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/View.php(330): require('/home/i98899/we...') #4 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('/home/i98899/we...', Array) #5 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/View.php(152): yii\base\View->renderFile('/home/i98899/we...', Array, Object(humhub\modules\gallery\controllers\CustomGalleryController)) #6 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/Controller.php(381): yii\base\View->render('gallery_view', Array, Object(humhub\modules\gallery\controllers\CustomGalleryController)) #7 /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/controllers/CustomGalleryController.php(144): yii\base\Controller->render('gallery_view', Array) #8 /home/i98899/web/i98899.fwiw.co/public_html/protected/modules/gallery/controllers/CustomGalleryController.php(47): humhub\modules\gallery\controllers\CustomGalleryController->renderGallery() #9 [internal function]: humhub\modules\gallery\controllers\CustomGalleryController->actionView() #10 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) #11 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array) #12 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('view', Array) #13 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('gallery/custom-...', Array) #14 /home/i98899/web/i98899.fwiw.co/public_html/protected/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(humhub\components\Request)) #15 /home/i98899/web/i98899.fwiw.co/public_html/index.php(25): yii\base\Application->run() #16 {main}

Additional info

Q A
HumHub version 1.2.3
PHP version 7.1 via fcgid
Operating system Ubuntu Trusty

Note: Please use the community site for any questions on customizing HumHub.
Note: Also provide the full error stacks from Administration --> Information --> Logging and errors from your browser console if possible.

@ReliefCrew
Copy link
Author

Update... I tested against php 5.6 and 7.0 with the same behavior. Also, please review the attached patch file which appears to fix the problem.

humhub-issue-2849-patch.txt

@luke-
Copy link
Contributor

luke- commented Dec 13, 2017

Thanks for the diff, I've applied the Gallery module part:
humhub-contrib/gallery@6791bcd

But the check in the ActiveQueryContent seems correct. The space must be visible for guests AND also the content must public.

@luke- luke- closed this as completed Dec 13, 2017
@ReliefCrew
Copy link
Author

Your point regarding the query is well taken. I now realize the gallery is a space but the media/images themselves aren't; they are just content.

So, in retrospect the query should probably be more like:

$this->andWhere('content.visibility=1 AND space.id IS NULL OR space.visibility=' . Space::VISIBILITY_ALL );

After all, there's no point in showing a public gallery without the images. Maybe a separate issue should be created? Thoughts?

luke- added a commit that referenced this issue Dec 14, 2017
@luke-
Copy link
Contributor

luke- commented Dec 14, 2017

Ok got it, now also public user profile content should be returned.

@ReliefCrew
Copy link
Author

Thanks! Worked great :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants