The is_writable() check in the google_tag.install can cause false detection that the director is NOT writable when in fact it is.
See related Drupal Core issue https://www.drupal.org/project/drupal/issues/944582.

Comments

recrit created an issue. See original summary.

recrit’s picture

Status: Active » Needs review
StatusFileSize
new2.32 KB

Added a helper function _google_tag_file_directory_is_writable() similar to the patch #130 provided in the core issue #944582: Check for execute permissions on directories that require file write permissions.

solotandem’s picture

Title: is_writable() check during install or update phase is incorrect » Add executable check to snippet directory preparation during install or update
Status: Needs review » Needs work

Thanks for referencing the core issue discussion. I agree the executable permission needs to be enabled on the snippet directory, but the proposed patch will not solve this problem on a stream wrapper (nor will the core patch resolve this issue for core and other modules that rely on it).

hkirsman’s picture

Still getting:

Failed to create or make writable the directory public://google_tag, possibly due to a permissions problem. Make the directory writable.                   [error

Not sure if Drupal is stuck and even cache clear doesn't work?

How could I manually fix this?

hkirsman’s picture

Ok, did "chmod -R 777" for that folder.

solotandem’s picture

For those having this problem, how do the directory permissions get changed (assuming they were correct at one point)? Is this on deploy to another server? Is this on module enable? What is the workflow in which they are changed?

  • solotandem committed a4b3c78 on 8.x-1.x
    Issue #2945348 Add executable check to snippet directory preparation....
  • solotandem committed a856932 on 8.x-1.x
    Issue #2945348 Add executable check to snippet directory preparation....
solotandem’s picture

Assigned: Unassigned » solotandem
Status: Needs work » Fixed

First commit in #7 checks executable bit on directory permission using custom function as workaround to PHP bug in is_executable with stream wrappers.

Second commit in #7 makes for a self-contained change and avoids the need for a core patch. This commit can be reverted if core is updated to check the executable bit.

These commits are sufficient for purposes of this module but represents a partial solution to the is_executable() check missing in other parts of core. Hopefully this is the real cause of what has been reported here.

Thanks to those who reported this and commented. Please test commit and report back.

podarok’s picture

Priority: Normal » Critical
Status: Fixed » Needs work

Hi, guys
This commit broking installation via drush on php 7 (I don't know about other PHP versions)
google_tag enabled via profile.info.yml
See https://github.com/ymcatwincities/openy/blob/8.x-1.x/openy.info.yml#L81
This is a not safe practice to make hook_requirements so complicated as well as adding there functions that aren't exist

13:47:34 TASK: [Installing drupal] *****************************************************
13:47:34 failed: [localhost] => {"changed": true, "cmd": "APP_ENV=dev drush -y si openy install_configure_form.enable_update_status_emails=NULL --db-url=mysql://xxx:xxx@127.0.0.1:/drupal371 --account-name=admin --account-pass=xxx --uri=http://xxx/build371", "delta": "0:00:00.637799", "end": "2018-03-02 13:47:34.627640", "rc": 1, "start": "2018-03-02 13:47:33.989841", "warnings": []}
13:47:34 stderr: Starting Drupal installation. This takes a while. Consider using the [ok]
13:47:34 --notify global option.
13:47:34 Error: Call to undefined function __file_prepare_directory() in /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/modules/contrib/google_tag/google_tag.install on line 31 #0 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.inc(967): google_tag_requirements('install')
13:47:34 #1 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.core.inc(1976): drupal_check_profile('openy')
13:47:34 #2 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.core.inc(1028): install_check_requirements(Array)
13:47:34 #3 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.core.inc(671): install_verify_requirements(Array)
13:47:34 #4 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.core.inc(549): install_run_task(Array, Array)
13:47:34 #5 /var/lib/jenkins/jobs/PR_BUILDER_COMPOSER/workspace/build371/openy-project/docroot/core/includes/install.core.inc(117): install_run_tasks(Array)
13:47:34 #6 /usr/local/src/drush/includes/drush.inc(726): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
13:47:34 #7 /usr/local/src/drush/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
13:47:34 #8 /usr/local/src/drush/commands/core/drupal/site_install.inc(82): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
13:47:34 #9 /usr/local/src/drush/commands/core/site_install.drush.inc(255): drush_core_site_install_version('openy', Array)
13:47:34 #10 /usr/local/src/drush/includes/command.inc(422): drush_core_site_install('openy', 'install_configu...')
13:47:34 #11 /usr/local/src/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
13:47:34 #12 /usr/local/src/drush/includes/command.inc(199): drush_command('openy', 'install_configu...')
13:47:34 #13 /usr/local/src/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
13:47:34 #14 /usr/local/src/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
13:47:34 #15 /usr/local/src/drush/drush.php(12): drush_main()
13:47:34 #16 {main}
13:47:34 Drush command terminated abnormally due to an unrecoverable error. [error]

  • solotandem committed 5612d04 on 8.x-1.x
    Issue #2945348 Add executable check to snippet directory preparation....
solotandem’s picture

Status: Needs work » Fixed

Thanks for reporting this.

podarok’s picture

Status: Fixed » Needs work

Same for _google_tag_doesnt_exists in condition

solotandem’s picture

Priority: Critical » Normal
Status: Needs work » Fixed

@podarok Your comment could use a bit explanation as to what you are referring to. Without such there is no basis to change status. If not related to this then create another issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.