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

drush runserver won't generate images for image styles with Clean URLs enabled #1189

Closed
dsnopek opened this issue Feb 17, 2015 · 17 comments
Closed
Assignees

Comments

@dsnopek
Copy link

dsnopek commented Feb 17, 2015

When running a Drupal site with drush runserver and Clean URLs enabled, attempting to access an image for an image style (which hasn't yet been generated) will give 404, rather than cause Drupal to generate the image.

Disabling Clean URLs will allow the image to be correctly generated, but obviously affects lots of other things on the Drupal site.

We (the Panopoly project) are using drush runserver in our automated Behat tests, and so anything that uses an image style is getting a broken image and messing up the tests. But disabling Clean URLs also breaks a number of our tests which deal with paths, aliases and redirects. And, of course, no one runs with Clean URLs disabled in real life, so it would make our tests more artificial...

This issue was reported on D.o at one time, but got no response before the migration to GitHub: https://www.drupal.org/node/1961656

@kevin-coyle
Copy link

Just a little more detail. I'm getting this too running it on Ubuntu 14.04. PHP Version 5.5. GD is installed and working.

@nvaken
Copy link
Contributor

nvaken commented Jun 3, 2015

Same problem here, any suggestions?

Edit: What's even stranger is that the airballoon test images in image styles admin panel seems to work fine. When adding images through image fields, these images seem to only be uploaded in their original size. Images and even their parenting folders do not seem to be generated. Disabling clean URLs fixes this issue, which is not an acceptable solution, of course.

@kevin-coyle
Copy link

Just noticed something. If you run the clean urls test it states for me that it fails... Could that be part of the issue?

@richardbporter
Copy link
Contributor

I've got this issue as well. Did anyone find a solution/workaround?

@badrange
Copy link

badrange commented Oct 1, 2015

On my computer it worked after downgrading Drush from 7.0.0 to 6.6.0.

@dsnopek
Copy link
Author

dsnopek commented Oct 5, 2015

Hm. When I created this issue originally I was testing with the latest drush 6 release available at the time which appears to be 6.5.0. Is it really possible that this got fixed in 6.6.0? I'll re-test again when I have chance...

@badrange
Copy link

badrange commented Oct 6, 2015

Turns out I was very unclear in my previous comment. Yes it does work in Drush 6.6.0 but it does not work in Drush 7.0.

I downgraded to 6.6.0 because my colleague working on the same project had it working on his machine, I simply asked which version of Drush he was using and switched to it.

@dustinleblanc
Copy link

Also possible that this error I am seeing:
The requested resource /admin/config/content/panelizer/node/page.page_manager/layout/move/bootstrap_twocol_stacked was not found on this server.

Is related. I am using drush runserver on this panels powered site and it barfs when I try to move from my custom panel config to the bootstrap version...

@weitzman
Copy link
Member

Fixed by #2023 at least for some versions of Drupal.

@dustinleblanc
Copy link

<3

@darthsteven
Copy link

From what I could tell, Drush 7 uses the built-in PHP server, whereas Drush 6 uses either the php-cgi binary or a contributed PHP server script.
I'm guessing that only the php-cgi version allows creating image derivatives, because people are reporting that this works in Drush 6, but I can't seem to get Drush runserver working with the php-cgi server, and can't create derivatives.

@weitzman what in #2023 will help resolve this issue? At the moment the only commits there look unrelated. Are you specifically talking about the error in @dustinleblanc's comment rather than the image derivative issue?

@darthsteven
Copy link

So, looks like if you drush runserver a Drupal 7 site then Drush 7 is just appending some PHP to the top of PHP files that the PHP builtin webserver: runserver-prepend.php.
Whereas, if you drush runserver a Drupal 8 site then Drush 7 is actually telling the built-in server to use a 'router script', which for Drupal 8 is: d8-rs-router.php.

This router script does a simple return FALSE if a file exists, so that static files etc get served up quickly, otherwise it calls Drupal's index.php at the bottom:

include 'index.php';

I've just done a quick and dirty hack and commented out the conditional so that Drupal 7 sites are served using the Drupal 8 router, and now image styles work :)

According to the PHP cli docs (http://php.net/manual/en/features.commandline.webserver.php) if a file is not found, then it searches for an index.php or index.html up the directory tree, but that should mean that it hits Drupal's index.php, which should handle the image style derivative, right?

It appears that PHP is not doing this correctly :(

Maybe we should just replicate the way that the Drupal 8 bootstrap works for Drupal 7 and call the Drupal 7 index.php directly?

@darthsteven
Copy link

Yeah so appending the following code to commands/runserver/runserver-prepend.php:

$url = parse_url($_SERVER["REQUEST_URI"]);
if (file_exists('.' . $url['path'])) {
  // Serve the requested resource as-is.
  return FALSE;
}

// Include the main index.php and let core take over.
// n.b. Drush sets the cwd to the Drupal root during bootstrap.
include 'index.php';

Seemed to work fine for me. Normal clean URLs work, and image derivatives are created.

EDIT: Sorry, I also changed the way that php -S is invoked to not prepend the file, but to call the script as per the Drupal 8 style of invoke

@richardbporter
Copy link
Contributor

@dustinleblanc

Did you ever find a fix for the Panelizer 404s? I'm currently having the same problem with Drush 8.0.5 and PHP 5.6.20.

See: #1641, #1658

@darthsteven
Copy link

Oh, so it looks like #1658 is the PR trying to resolve this issue.

@weitzman
Copy link
Member

Lets focus conversation in #1658

@dsnopek
Copy link
Author

dsnopek commented May 1, 2017

It looks like #1658 was superceded by #2501

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

No branches or pull requests

9 participants