Profiler can create nodes, terms, users, etc. It would be really great if it could create custom blocks as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | profiler-blocks-1955904-07.patch | 3.68 KB | jhedstrom |
| #5 | add_block_support-1955904-5.patch | 2.72 KB | jyee |
| #1 | add_block_support-1955904.patch | 2.33 KB | jyee |
Comments
Comment #1
jyee commentedFirst attempt to provide the functionality is attached.
Comment #2
jyee commentedoops. forgot to set status to needs review.
Comment #3
mariacha1 commentedIt's a good start, but for blocks, since there isn't any built-in validation like there is with node_save(), a wrongly-entered value will fail the install with an ungraceful pdo error. Here's one of the ways I got it to die:
Second, there's an easily-fixable bug. There should be a default value in the 'format' field. So this code:
'format' => $block['format'],should be:
'format' => isset($block['format'])? $block['format'] : 'full_html',Finally, the "info" field in the blocks_custom table must be unique. Is there a way to check for that before trying to save the block?
I can attempt to fix these things later...
Comment #4
jyee commentedThanks, I can take a look into error checking, but theoretically, content is being created by a developer, so i'm not sure how far down the rabbit hole we should go on that.
I'll update it to set the default format to plain_text, as that exists in both minimal and typical install profiles (full_html only exists in typical) and should be a safer default.
As for the unique info field, we can check for that, by storing previous block info and validating against it. I did something similar in the nested menu node creation, but I'm concerned that continued use of that process could start consuming much more memory and become a problem.
Comment #5
jyee commentedUpdated patch to use plain_text when a format isn't declared. I've also added a check for the unique info field.
There's a change to execute the block insert within the foreach loop. While executing once at the end is technically more efficient, it creates a problem where a single record failure could fail the entire set of blocks.
Comment #6
jhedstromThis functionality/syntax needs to be called out in the README.
Comment #7
jhedstromHere's some help text for the README.
Comment #8
q0rban commentedjyee, feel free to commit this after you have reviewed / tested.
Comment #9
jyee commented@jhedstrom thanks for the readme update. This has been committed to 7.x-2.x.