Private system and multisite.

Created on 13 July 2024, 4 months ago
Updated 5 August 2024, 4 months ago

Problem/Motivation

Problem with private file system, not have access to the file.

General App Icon is not show.

And not working in multisite system.

I have multisite and not working. This module https://www.drupal.org/project/pwa , work in multisite and with private file system but not have push system and still in developer mode.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.71

Component

Code

Created by

🇪🇸Spain ady1503

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ady1503
  • 🇬🇧United Kingdom gMaximus

    After uploading the icon, can you access it as anonymous?

    If you can't, I know the code to change. This would then save the file in the public files directory.

  • 🇬🇧United Kingdom gMaximus

    Regarding multi sites. Are there any errors you can give me? I see no reason you'd be having a problem with that.

    Are the multi sites sub-folders of the same domain?

  • 🇪🇸Spain ady1503

    "After uploading the icon, can you access it as anonymous?
    If you can't, I know the code to change. This would then save the file in the public files directory.
    "

    no not

    "Are the multi sites sub-folders of the same domain?"

    yes is same domain.

    I have the entire file system in private mode. I had this error and the pwa module, they have added access control and they have to check which file system the drupal installation has. If it is private, you have to check the access permissions to the files in the controller. And serve the icons according to permissions and access.

    Path: /system/files/advanced_pwa/icons/android-chrome-512x512.png. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: in Drupal\system\FileDownloadController->download() (line 82 of /home/***/public_html/***/web/core/modules/system/src/FileDownloadController.php).

  • 🇬🇧United Kingdom gMaximus

    Please send me a link to the issue.

    I'm not sure if this module will work in the case of multi site in folders and push notifications. This is because the push notifications are registered for the domain.

    There is another issue in the queue that is discussing allowing users to register to paths.

    In the case of multi site in folders, I only see sharing tables as a viable option.

    I'm also considering whether to add a rules action to send a push notifications to flagging users of an entity.

    Currently, the extending modules allow this for nodes and users.

    This way a non programmer could create an entity type for "subscriptions" for example. Add some flags to it. Then use rules to send out the notifications.

  • 🇪🇸Spain ady1503

    How I'm explaining it to you.

    The pwa module works in my multidomain, multisite installations. I have the block with the button to install the app.
    The installation of the web app works, the only problem is that they do not have a push system.
    Works on private file system, loads icons. I can create an app using https://www.pwabuilder.com.
    My subdomain format is https://subdomain.domain.com

    I'm just looking to help.

    My opinion on multidomain installations, multisite is possible. My multidomain, multisite drupal system doesn't share anything except the code. The databases are individual for each subdomain, I have common and individual modules.

    The only thing I did was install its advanced_pwa module in an test subdomain and I couldn't use it.

    Your system needs required that you generate keys first. This means that the key is unique for each domain, subdomain.

    An url is individual and instalation folder too. I don't share the same content and configuration in mi system multidomain.

    Report to be able to help get a module with complete PWA functionalities.

    Thank you

    https://web.dev/articles/building-multiple-pwas-on-the-same-domain

  • 🇬🇧United Kingdom gMaximus

    Thank you for your help. It's appreciated and what I love about opensource.

    I have a production website with this module installed. I have 2 staging websites that are an exact copy. One for dev and another for QA. Both are subdomains.

    For me everything is working. So there is hope.

    The first thing I'm going to do is check if my keys are the same. I can't remember if I set things up pre or post launch.

    The video tutorial is also a subdomain.

  • 🇪🇸Spain ady1503

    I have checked my installation.

    When installing your module, the folder is not created: files/advanced_pwa/icons/.

    When private file mode is activated. Here is your problem.

    Because the pwa module has created the pwa folder for me in each subdomain that I have, in private file system.

    You have to review the operation of the pwa module, how it creates the folders and checks the permissions and the file system that is activated in each installation.

    What you tell me is file public system, not a private one.

    Gracias

  • 🇬🇧United Kingdom gMaximus

    Yes, I have no installations using the private files feature of Drupal.

    I will set one up for testing.

    I'm thinking the file system option should be in manifest settings. Like a usual image field.

    The folder for icons should be created though. When things are corrected, you would have icons and setting per subdomain. That is expected.

  • 🇬🇧United Kingdom gMaximus

    I've been working quite a bit on this. I have a couple of questions to help me understand the use case.

    1) Why can't you configure your public directory for this purpose? All other configurations would be unaffected.
    2) Is there a reason that you would want to restrict access to the manifest and push images?

    I've looked at the latest release of the PWA module and it is hard coded to store in the public:// file system. It's not configurable. This leads me to think that you tested the PWA Module on a install with the public directory configured.

  • 🇬🇧United Kingdom gMaximus

    If it's configured, is the default file system on your site set to private?

  • 🇬🇧United Kingdom gMaximus

    Pls retest dev. I've made changes that will hopefully rectify your issues. It would require public:// files system being configured.

  • 🇪🇸Spain ady1503

    Hello.

    I have tried your changes.

    They do not work.

    After investigating and analyzing I detected:

    The pwa module creates the "pwa" folder and saves all the icons there, in the path:

    "../files/pwa"

    /home/***/public_html/main_domain/web/sites/default/files/pwa/android-chrome-512x512.png

    /home/***/public_html/main_domain/web/sites/first_site/files/pwa/android-chrome-512x512.png

    /home/***/public_html/main_domain/web/sites/second_site/files/pwa/android-chrome-512x512.png

    URLs:

    https://main_domain/sites/default/files/pwa/android-chrome-512x512.png

    https://main_domain/sites/first_site/files/pwa/android-chrome-512x512.png

    https://main_domain/sites/second_site/files/pwa/android-chrome-512x512.png

    Your module creates the "advanced_pwa/icons" folder but it creates it in the "private" folder that is in the configuration and path:
    "../files/private/advanced_pwa/icons"

    /home/***/public_html/main_domain/web/sites/default/files/private/advanced_pwa/icons/android-chrome-512x512.png

    /home/***/public_html/main_domain/web/sites/first_site/files/private/advanced_pwa/icons/android-chrome-512x512.png

    /home/***/public_html/main_domain/web/sites/second_site/files/private/advanced_pwa/iconsandroid-chrome-512x512.png

    URLs:

    https://main_domain/system/files/private/advanced_pwa/icons/android-chrome-512x512.png

    https://main_domain/system/files/private/advanced_pwa/icons/android-chrome-512x512.png

    https://main_domain/system/files/private/advanced_pwa/icons/android-chrome-512x512.png

    system is the format control of drupal for hide real private route and url for access control en private file system.

    As you can see, the pwa module uses the free path outside the private folder, because I have access to the icon without being logged in.
    The pwa module controls only which pages and roles the manifest file is loaded or not.

    Not yours.

    I'm just telling you your only biggest problem is: permissions.

    And another thing in php 8.3 the following errors appear:

    Warning: Undefined property: Drupal\advanced_pwa\Controller\AdvancedpwaController::$requestContext in Drupal\advanced_pwa\Controller\AdvancedpwaController->advancedpwaGetManifest() (line 190 of modules/contrib/advanced_pwa/src/Controller/AdvancedpwaController.php).
    Drupal\advanced_pwa\Controller\AdvancedpwaController->advancedpwaGetManifest()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
    
    Warning: foreach() argument must be of type array|object, string given in Drupal\advanced_pwa\Form\ManifestConfigurationForm->submitForm() (line 445 of modules/contrib/advanced_pwa/src/Form/ManifestConfigurationForm.php).
    Drupal\advanced_pwa\Form\ManifestConfigurationForm->submitForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('advanced_pwa_settings_form', Array, Object) (Line: 326)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
    Warning: foreach() argument must be of type array|object, null given in Drupal\advanced_pwa\Controller\AdvancedpwaController->userHasSelectedRoles() (line 319 of modules/contrib/advanced_pwa/src/Controller/AdvancedpwaController.php).
    Drupal\advanced_pwa\Controller\AdvancedpwaController->userHasSelectedRoles() (Line: 290)
    Drupal\advanced_pwa\Controller\AdvancedpwaController->settings()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
    
    Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\advanced_pwa\Controller\AdvancedpwaController->settings() (line 276 of modules/contrib/advanced_pwa/src/Controller/AdvancedpwaController.php).
    Drupal\advanced_pwa\Controller\AdvancedpwaController->settings()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    PS.

    The pwa module works on all my sites with or without a private or public file system, in single domain or multidomain format.

    As I explained above: the icons must be saved in /"../files/advanced_pwa/icons/".

    And now it does it in ../files/private/advanced_pwa/icons/",

    "../files/private/" is my folder configured in settings.php for private file system, and the drupal configuration to serve the files only in private mode.

    Thank you

  • 🇬🇧United Kingdom gMaximus

    I'm really sorry to have wasted your time. I thought I had committed the changes to deal with this and I was mistaken.

    Apologies, the changes that I expect to fix your issue are now in dev. Thanks for being so quick to test.

    I have tested this module lots on sub-domains and am confident that it isn't an issue. I just haven't tried it with different installs in sub-folders. In theory it should be fine.

    I'm convinced your difficulties have stemmed from your default file system being set to private. I hadn't tested that, it is nothing that you done wrong.

    There was a line of code that used that default scheme for the website. That is now hardcoded to public://. So we should be good.

    Let me know if we're good now.

  • 🇬🇧United Kingdom gMaximus

    I've been testing 8.2, I'll test PHP 8.3. For me everything is working on my websites. I'm working on these things for others for my love of opensource.

  • 🇪🇸Spain ady1503

    Thank you for your work.

    Later I will install a new drupal installation and try clean.

    I never do tests in production.

    The only thing I would like you to understand: if in the same test bench the PWA module works perfectly, but the advanced_pwa does not, it does not work and errors appear for a reason.

    I'm not saying that your work is not well done, I'm just informing you, so I can help you improve.

    Thank you

  • 🇪🇸Spain ady1503

    Hello.

    Tiredness is not good when taking tests.

    In the end with your changes the module works.

    You only have an error with these lines:

    AdvancedpwaForm.php

    /**
    * {@inheritdoc}
    */
    public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    if (!empty(file_save_upload('icon_upload'))) {
    $file = file_save_upload('icon_upload');
    $filename = \Drupal::service('file_system')->copy($file[0]->getFileUri(), 'public://images/pwaimages/');
    $form_state->setValue('icon_path', $filename);

    }

    Look at what is in bold that gives an error about the non-existent route.
    That really does not exist, because this folder is not created when installing the module.

    I'm going to test the functionalities, and I'll let you know.
    I will test the push system to make sure it works correctly.

    Thank you

    PS.
    Sorry for wrong evidence, I was tired.

  • 🇬🇧United Kingdom gMaximus

    This patch should conclude these issues with the private file system set as default.

  • 🇬🇧United Kingdom gMaximus

    This issue was all to do with the original developers getting the default file system for the website from configuration. I hadn't picked up on this because I never really use the private file system feature. I do understand it though.

    I've now searched all files for instances of this and hardcoded it to public. The patch above corrects those.

    I really appreciate you helping with testing.

    Let me know if you're satisfied that this is resolved and I'll update dev.

  • Status changed to Needs review 4 months ago
  • 🇬🇧United Kingdom gMaximus

    With the push notifications, after clicking Drupal's confirm button on the prompt, the browser should then prompt you for permission with something like allow/block.

    I've tested chrome, Firefox and edge.

    Edge blocked the request for access. It showed me a little icon in the address bar to indicate this. I clicked that to allow requests and all was fine.

    Conversations about push notifications should be a different issue. There are conversations being had in the queue already. More the merrier.

    After you give this your sign of approval for the above patch, I'll be considering this particular issue resolved. I'll then push it to dev

  • 🇪🇸Spain ady1503

    I have applied all changes:

    https://git.drupalcode.org/project/advanced_pwa/-/commit/5bf36319604f7e3...

    and

    patch number #18

    and the end result is that everything works fine.

    Thanks

  • Status changed to RTBC 4 months ago
  • 🇬🇧United Kingdom gMaximus
    • gMaximus committed b5258641 on 8.x-1.x
      Issue #3461175 by gMaximus, ady1503: Private system error. Originally...
  • Status changed to Fixed 4 months ago
  • 🇬🇧United Kingdom gMaximus
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024