user-defined block with the given title
mescalito - October 5, 2007 - 17:11
| Project: | Rep[lacement]Tags |
| Version: | 5.x-1.x-dev |
| Component: | Reptag .tags module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
If I use such a string:
{BLOCK:block_1}{YOUTUBE:video_id}{BLOCK:block_2}
I get this error message:
* warning: Invalid argument supplied for foreach() in /path/to/drupal/modules/reptag/tags/block.tags.inc on line 47.I worked around by commenting the line:
"#{BLOCK:(.*?):(.+?)}#e" => "theme('block', (object)_reptag_block_by_title('\\2','\\1'));",
in block.tags.inc, but that's not a patch!

#1
{BLOCK:block_2}is not a valid syntax. It should be{BLOCK:block:2}or stg. (see _reptag_block_help() for sample syntax) ...#2
Sorry if I wasn't clear. I was referring to the
{BLOCK:Contact Details}syntax, which calls a "user-defined block with the given title".#3
Sorry! Got that wrong. Bugfix committed.
#4
Thanks, but your fix is not perfect, and sometimes it catches too much.
Here is a patch for the latest version of block.tags.inc. I simply replaced your regexp:
"#{BLOCK:([^:]+):(.+?)}#e"by:
"#{BLOCK:([^:!}]+):(.+?)}#e"#5
Hi profix,
Do you plan to commit the patch I sent? Do you have any chance to test it?
#6
Missed that completely! Sorry! I'm quite busy at work and updating my modules.
Could you post a list of strings to test against? That would be great :) I'm talking about cases currently failing and those to check all four regexp syntaxes with.
#7
I've tested the following strings:
{BLOCK:test block}{YOUTUBE:un_PjRXV5l8}{BLOCK:test block 2}{BLOCK:1}{YOUTUBE:un_PjRXV5l8}{BLOCK:2}
{BLOCK:block:test block}{YOUTUBE:un_PjRXV5l8}{BLOCK:block:test block 2}
{BLOCK:block:1}{YOUTUBE:un_PjRXV5l8}{BLOCK:block:2}
{BLOCK:test block}{YOUTUBE:un_PjRXV5l8}{BLOCK:block:2}
{BLOCK:block:1}{YOUTUBE:un_PjRXV5l8}{BLOCK:test block 2}
In some cases (when there was more than one tag in the same line and the first one has more than one argument) it was failing because the regexp didn't stop at the first '}'. My submitted patch solves that issue.
#8
But what is the
!needed for? Why is it necessary to stop at the next!?{BLOCK:([^:}]+):(.+?)}should solve the problem of a series of tags being incorrectly treated as one, not?#9
Hmmm... you're absolutely right. The
!is needed for nothing! Mea culpa.#10
No problem. Bugfix committed. Thanks :)
#11