I put two g2 blocks:G2 Random and G2 Alphabar on frontpage panel (Add content -> Miscellaneous).

Now I've got this error:

Warning: mt_rand() [function.mt-rand]: max(-1) is smaller than min(0) in g2\random() (line 1175 of Z:\home\paris9.kz\www\emploi\sites\all\modules\g2\g2.module).
Notice: Trying to get property of non-object in g2\random() (line 1201 of Z:\home\paris9.kz\www\emploi\sites\all\modules\g2\g2.module).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7389 of Z:\home\paris9.kz\www\emploi\includes\common.inc).

Problem seems to be with Random block.

Comments

fgm’s picture

It looks like your site does not have at least 3 G2 nodes: have you taken into account the last paragraph of the README.txt file ?

clashar’s picture

Status: Active » Closed (works as designed)

fgm, you are right, I didn't have minimum 3 g2 nodes, sorry for issue opening and thank you for quick reply.

fgm’s picture

Title: Warning: mt_rand() [function.mt-rand]: max(-1) » G2 Random block should warn that it does not work with less than 3 nodes instead of causing an error
Category: bug » feature
Priority: Normal » Minor
Status: Closed (works as designed) » Active

Adjusting title. Looks like a README may not be enough.

clashar’s picture

thank you for kind support))

fgm’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes

New features only in current dev version : bumping to 8.x.

fgm’s picture

Still happens on D10/D9 with a different location:

  • with just two nodes, if the stored random and the WOTD are different
  • with just one node, if either the stored random the WOTD are that node
  • with no node (d'oh)

The better UX is probably to just build an empty block and log the issue instead of exposing it to the front user.