When using devel generate to create content, I get the following error

Strict warning: Only variables should be passed by reference in _image_devel_generate() (line 36 of .../drupal-8.x-dev/sites/all/modules/devel/devel_generate/image.devel_generate.inc).

Comments

dqd’s picture

StatusFileSize
new153.72 KB

I can confirm the bug with latest D8 core --dev and latest devel --dev from today with hitting submit on default setup. Additional Info: But the images are still generated.

screenshot attached.

salvis’s picture

Ok, I guess

      $source->filename = array_pop(explode("//", $path));

is the culprit... Try this instead:

      $source->filename = end($dummy = explode("//", $path));
arrow’s picture

I'm also seeing this error in 7.x-1.3.... The site is running PHP 5.4 which had caused other issues in Drupal core. Could PHP be the culprit here as well?

salvis’s picture

Status: Active » Postponed (maintainer needs more info)

@Arrow: And — what does #2 do for you?

Or try

      $path_exploded = explode('//', $path);
      $source->filename = end($path_exploded);

or

      $path_exploded = explode('/', $path);
      $source->filename = end($path_exploded);
_sania’s picture

thank you salvis, it helped

salvis’s picture

Which one?

_sania’s picture

first, i'm using D7.14 and Devel 7.x-1.3 on XAMPP

salvis’s picture

I offered a number of variants above. Which is the one that worked for you?

Please paste the one...

_sania’s picture

$path_exploded = explode('//', $path);
$source->filename = end($path_exploded);

salvis’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Fixed

In D8 this was fixed in passing by the patch in #1549662-9: Node, taxonomy, comment, and user are all classed objects.

I've committed the version from there to D7 -dev:

      $filename = explode("//", $path);
      $source->filename = array_pop($filename);

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

it worked, thanks!

kaidjohnson’s picture

Hey, I just ran into this issue (on latest stable - 7.x-1.3). I was looking at the solution above and wondering why we don't just use:

$source->filename = basename($path);

Seems simpler and cleaner. Same thing would apply for _file_devel_generate() (line 21, file.devel_generate.inc).

salvis’s picture

Agreed. Do you want to post a patch?

pcambra’s picture

Title: Strict warning: Only variables should be passed by reference in _image_devel_generate() when generating content » Use basename in file and image devel generation
Status: Closed (fixed) » Active

Let's reopen this as for #13 and #14

kaidjohnson’s picture

Sure thing!
Rolled for latest 7.x-1.x

kaidjohnson’s picture

Assigned: Unassigned » kaidjohnson
Status: Active » Needs review
pere orga’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Needs work

Shouldn't this be applied to 8 instead?

pere orga’s picture

Category: bug » task
Status: Needs work » Needs review
StatusFileSize
new1.65 KB

Patch for 8.x

pcambra’s picture

Assigned: kaidjohnson » Unassigned
kaidjohnson’s picture

salvis’s picture

Status: Needs review » Needs work

Good catch, yes!

sandip choudhury’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev

Hello,

I have also this error. How to use this patch? Under which folder I will put this file or paste this?
Currently I am learning Drupal.

pcambra’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Please don't switch versions, devel changes go first in D8.

You can grab the patch in #19 and use the instructions for applying it, then if it works, you might want to replace the call to basename by drupal_basename and contribute the patch back

kaidjohnson’s picture

Assigned: Unassigned » kaidjohnson
Status: Needs work » Needs review
StatusFileSize
new1.66 KB

Revised patch for D8 using drupal_basename.

pere orga’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me

salvis’s picture

Status: Reviewed & tested by the community » Fixed

Pushed to D8 and D7 — thanks!

salvis’s picture

Assigned: kaidjohnson » Unassigned
estoyausente’s picture

Status: Fixed » Needs review
pere orga’s picture

Status: Needs review » Fixed
salvis’s picture

@SamuelSolis: Please don't do that. After a patch has been applied and pushed into the repository, trying to apply it a second time will necessarily fail. This turns it red and we have no way to turn it green again, even though it was green at the point in time where it mattered.

What exactly was your intention?

torotil’s picture

StatusFileSize
new1.58 KB

Here is a patch for 7.x-1.3 to be used with drush make as long as there is no 1.4 release.

salvis’s picture

Priority: Normal » Minor
Status: Fixed » Needs review

@torotil: Please do not post patches for release versions — that just generates confusion.

This issue is just a minor code clean-up that has absolutely no effect on execution. There's no point in hacking your Devel release version. Use the -dev version instead.

(Marking this NR to turn #32 red.)

Status: Needs review » Needs work

The last submitted patch, devel_generate_use_basename_1.3.patch, failed testing.

salvis’s picture

Status: Needs work » Fixed

Back to fixed as per #27.

torotil’s picture

@salvis: reality is: this bug makes my unit-tests fail. I use the release version. I posted a fix for others who have this problem.

salvis’s picture

reality is: this bug makes my unit-tests fail. I use the release version. I posted a fix for others who have this problem.

How can that be? What kind of failure do you get?

Even then, people should not hack modules. 7.x-1.x-dev is perfectly fine to use.

torotil’s picture

I have a devel-build that automatically generates content on drush site-install. Drush returns a non-zero return value if there are warnings. So this makes my builds "fail". This has nothing to do with hacking this module.

salvis’s picture

"Hacking" core or a module means applying a random set of patches or self-made changes to your installation. This makes your version of Devel unique in the world — if we had a support contract, it would invalidate it.

http://drupal.org/best-practices/do-not-hack-core
http://drupal4hu.com/node/293

This applies just the same to well-maintained contribs.

What keeps you from installing the -dev version?

torotil’s picture

@salvis: I neither modified core nor any contrib modules. I just write my own modules too - and I don't want their continuous integration scripts to fail because of warnings issued by the devel module. That's why I'm going with devel-1.3 (because in need a stable build) + bug-fixes (like the patch I posted).

salvis’s picture

@torotil:

I neither modified core nor any contrib modules.

By posting a patch against 7.x-1.3 in #32 you are encouraging people to do just that: create their own branch of Devel that does not exist in the repository. Have you not applied your own patch on your server?

What keeps you from installing the -dev version?

pcambra’s picture

What keeps you from installing the -dev version?

I guess it's what he's mentioning in #40, is not unusual that CI policies require some kind of tag to pull from, a beta, a stable, and not just the --dev, so it's the same code each time.
You probably can checkout --dev in a given point of time for those purposes something like:
git co '8.x-1.x@{2013-03-07 10:38:28}'
But you'll get a detached HEAD in any case.

Devel 1.3 is from June 2012, it's about time to tag a new release...
We might want to add a policy of releasing a stable each X months (for D7) as we don't have specific feature breakpoints.
I'd say once every 3 months, or given months, Jan - May - Sep would make sense.

pere orga’s picture

Hi salvis:

I don't see the issue in patching a stable release of a contributed module for fixing a bug. He is not hacking core.

If the -dev version is the recommended release, why not release it as 1.4?

salvis’s picture

is not unusual that CI policies require some kind of tag to pull from, a beta, a stable, and not just the --dev, so it's the same code each time.

Yes, that's possible, but in that case, applying your own patches is even worse than using the -dev version. Update module can tell you how many commits you're away from the latest tag, and you can also identify the exact version using git's hash. git describe --tags will also give you this information, e.g. it gives me 7.x-1.3-43-g0a498a4 in my repo right now, meaning I'm 43 commits past 7.x-1.3, and git checkout 0a498a4 will give me that version at any time.

(You always end up in detached HEAD mode, when you're not at the head of a branch, whether you go there by hash, by date, or by tag.)

He is not hacking core.

No, he's hacking contrib. The same principles apply for the same reasons.

If the -dev version is the recommended release, why not release it as 1.4?

This is the Devel module. It's continually under development. If we did what you suggest, we'd be at 1.46 or so by now, and people would complain because we'd keep triggering their update notifications for no good reason. I like to think that people who use the Devel module are close enough to development to understand how this works.

pere orga’s picture

No, I've suggested it once, no 43 times :P
But yes you are right, using dev makes sense

torotil’s picture

This is the Devel module. It's continually under development. If we did what you suggest, we'd be at 1.46 or so by now, and people would complain because we'd keep triggering their update notifications for no good reason. I like to think that people who use the Devel module are close enough to development to understand how this works.

Then why not drop the 1.3 release and make exactly this statement in the module description?

(You always end up in detached HEAD mode, when you're not at the head of a branch, whether you go there by hash, by date, or by tag.)

Essentially I create my own 7.x-1.3stable branch with a few bug-fixes (in this case one trivial one) cherry-picked from 7.x-1.x.

The way I am doing this is by putting devel-7.x-1.3 in my make-files and then adding the patch with a comment that points me to this issue and a note "remove this when switching to next version".

This is a solution that has proven to work over and over for drupal modules, whereas using dev-releases has proven to break things from time to time - which I can't afford.

torotil’s picture

… so essentially you are saying that the releases marked as recommended on the module page are in reality neither recommended nor supported.

bleen’s picture

This is not the correct venue for a discussion about who should patch what version of modules and how often maintainers should create new releases. If you have a problem with (or suggestions about) the current conventions in using, developing & patching Drupal contrib modules then please open an issue against one of the Drupal.org projects and not this issue which is about image generation in the devel module.

That is the only way your thoughts/ideas will get their due consideration from the community and in the time people are just looking at this as an unfortunate rant or noise...

salvis’s picture

Indeed, I wish I could mark the -dev version as the recommended version, but d.o just won't let me do that.

In general I agree with the 'official' preference of release versions over snapshots, but I really do believe that Devel is different in this regard.

estoyausente’s picture

@salvis:
Sorry,it was my mistake. I didn't try to do this, sorry.

Status: Fixed » Closed (fixed)

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