Download & Extend

Create an API function for adding an instance

Project:MultiBlock
Version:5.x-1.0
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

In #259976: Use a form for Block Deletion, an API function is added for instance deletion. This patch is the complement, providing an API function for instance creation. It's completely functionally equivalent to the version before the patch, just breaking out the creation of instances into a new multiblock_add() function.

This patch conflicts with #259976, which will need to be applied first.

AttachmentSize
multiblock-add.patch4.3 KB

Comments

#1

Title:Create an API function for adding and instance» Create an API function for adding an instance

#2

Status:active» needs review

#3

Status:needs review» needs work

Again, the patch is generally good but I have a couple comments:

1. I think the form function should be named multiblock_add_form since multiblock_form isn't as descriptive
2. Any reason we are converting that array in multiblock_blockinfo_from_form() into an object? I think if anything it's better as an array since it makes it clear it's not the same data structure as from multiblock_get_block
3. I think this somehow overlaps the deletion patch so when that's committed it would be great if you could reroll this one

Any thoughts?

#4

Status:needs work» needs review

Yep, great comments. I agree on both points and I'll indeed reroll after the deletion patch goes in. Here's a preliminary re-roll with the following changes:

- The form is now named "multiblock_add_form" instead of "multiblock_add"
- multiblock_blockinfo_from_form() now returns an array as it did originally.
- multiblock_add now returns the delta of the newly added block, rather than a boolean.

AttachmentSize
multiblock_add.patch 4.1 KB

#5

Status:needs review» needs work

Everything in this patch looks good to me besides one line:

-    !array_key_exists($orig_block['delta'], module_invoke($orig_block['module'], 'block', 'list'))) {
+    !array_key_exists($orig_block->delta, module_invoke($orig_block['module'], 'block', 'list'))) {

I think the first reference to $orig_block should treat it as an array (not an object), right? Fix this and also reroll it to apply to the latest CVS and I will commit.

Thanks again!

#6

Status:needs work» needs review

Ah, very right! Cleaned up and rerolled to work with the latest CVS.

AttachmentSize
multiblock_add.patch 3.47 KB

#7

Status:needs review» fixed

Committed that last patch as-is. Thanks again for everything

#8

Status:fixed» closed (fixed)

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

nobody click here