Currently the code needs a valid session for the user used.

The following sequence should work but does not.

drush @drupal.d8 uli
drush @drupal.d8 dom-get --user=admin admin/modules
drush @drupal.d8 dom-get --user=admin user/logout
drush @drupal.d8 dom-get --user=admin admin/modules

Comments

clemens.tolboom’s picture

It isn't obvious to me how to fix this properly.

Current version grabs the session ID from the sessions table. This means one should login the test user.

clemens.tolboom’s picture

As a side effect we cannot grab other then drupal sites as we are now require drush bootstrap including logged in user.

clemens.tolboom’s picture

I still failed in getting better session handling.

My attempt was to create a new session but that fails.

clemens.tolboom’s picture

I came to the following solution which logout the current users session (which is bad behaviour) then request a ULI to use that session to request the final page.

#!/bin/bash
#
# dom-get-page.sh
#
# examples
#
# Grab the admin/modules page for user 1
#   dom-get-page admin/modules
#
# To mark the output file differently add a 'branch' tag
#   dom-get-page admin/modules branch-x
#
# Use a different user
#   dom-get-page admin/modules branch-x clemens
#
# $1 = path
# $2 = branch
# $3 = user

#set -x
DIR="."

PAGE="admin/modules"
[ -n "$1" ] && PAGE=$1

BRANCH="8.x"
[ -n "$2" ] && BRANCH=$2

USER="admin"
[ -n "$3" ] && USER=$3

PAGE_NAME=`echo $PAGE | sed s#/#_#g`
BRANCH_NAME=`echo $BRANCH | sed s#/#_#g`

FILE="$DIR/$USER.$PAGE_NAME.$BRANCH_NAME.out"

ECHO "Requesting '$PAGE' as '$USER' on branch '$BRANCH' saving to '$FILE'"

DRUSH_CONNECT="drush @drupal.d8 --user=$USER"

# MAKE SURE SESSION IS KILLED
${DRUSH_CONNECT} dom-get user/logout --file=/dev/null

# LOGIN AS USER
ULI=`${DRUSH_CONNECT} uli --browser=0 | sed s_http://drupal.d8/index.php/__`
${DRUSH_CONNECT} dom-get $ULI --file=/dev/null

# GET THE PAGE
${DRUSH_CONNECT} dom-get $PAGE --file="$FILE"

set +x

Please fix this :)

clemens.tolboom’s picture

By using the script above it is possible to compare different branches. But the code is as an example.

#!/bin/bash

function grab {
  declare -a PAGES=(user admin admin/modules)
  BRANCH=$1
  USER=$2
  for PAGE in ${PAGES[@]}
  do
    echo "$PAGE"
    ../dom-get-page.sh $PAGE $BRANCH $USER
  done
}

USER=admin
git checkout 8.x
grab 8.x $USER

git checkout drush-iq-convert-theme_views_mini_pager-1912604-#23
grab drush-iq-convert-theme_views_mini_pager-1912604-#23 $USER
clemens.tolboom’s picture

clemens.tolboom’s picture

Issue summary: View changes

Update summary