I'm getting this error upon enabling the module. It also essentially breaks fields and adding content until disabled and uninstalled.

"Notice: Undefined offset: 1 in rules_linkevent_get_links() (line 83 of /home2/easteru0/public_html/sites/all/modules/rules_linkevent/rules_linkevent.module).
Notice: Undefined offset: 2 in rules_linkevent_get_links() (line 84 of /home2/easteru0/public_html/sites/all/modules/rules_linkevent/rules_linkevent.module).
Notice: Undefined offset: 1 in rules_linkevent_get_links() (line 83 of /home2/easteru0/public_html/sites/all/modules/rules_linkevent/rules_linkevent.module).
Notice: Undefined offset: 2 in rules_linkevent_get_links() (line 84 of /home2/easteru0/public_html/sites/all/modules/rules_linkevent/rules_linkevent.module)."

I checked there and those lines contain this portion.

function rules_linkevent_get_links() {
$rules_string = variable_get('rules_linkevent', '');
$rules_list = explode("\n", $rules_string);
$rules = array();
foreach ($rules_list as $rule) {
$rule_parts = explode("|", $rule);
$link = new stdClass;
$link->name = $rule_parts[0];
$link->path = $rule_parts[1];
$link->label = $rule_parts[2];

$rules[] = $link;
}

Specifically lines 83 and 84 are in bold.

Anyone have an idea what might be up? Thanks.

Ryan

Comments

aidanlis’s picture

Hi Ryan,

Oh you're getting this when the module is enabled? The easiest way to fix it is to simply add a rule in, then the error will go away. I'll fix it properly in the next release.

jpontani’s picture

Status: Active » Needs review
StatusFileSize
new695 bytes

Attached is a patch that fixes this issue. All it does it make sure there is more than 1 item in the exploded array. Temporary fix as aidanlis is moving away from variables table eventually.

ryan.ryan’s picture

@jpontani

Thank you so much for your work on this fix, you were a huge help to me!

jpontani’s picture

@aidanlis The issue is that the function rules_linkevent_get_links() is causing the error, but it is also called in hook_menu so the menu router items never get created since it throws an error. Thus, you cannot register a path as the menu router never knows that admin/config/workflow/rules/links should use your defined form to create a link.

aidanlis’s picture

Ohh nice find, thanks jpontani. Not sure how that escaped my pre-release testing.

jckonczal’s picture

The root of the problem is that explode, strangely, returns a one-element array, containing the original string, when the delimiter is not found and the limit is not negative. Then the foreach loop is run once, and the explode there does the same thing before lines 83 and 84 try to access parts 1 and 2. I fixed it myself by adding an if statement to allow the foreach to run only when $rules_string is not empty, right before I thought of looking at these issues.

ryan.ryan’s picture

So is there any works into getting this taken care of? I'm still getting the error.

dave kopecek’s picture

This is still an issue with 7.x-1.0-alpha1

coleman.sean.c’s picture

Here's a patch that uses the solution described in #6. Not very pretty, but seems to work.

socialnicheguru’s picture

patch works for me

michaeldhart’s picture

patch also works for me

rerooting’s picture

works great for me. would highly suggest committing this patch or an improved version if possible!

stefansan’s picture

hi,
i have the same problem.
where must i put the patch to?
thanks for answers.
stefan

stefansan’s picture

ok, i got it. it works.
thanks for the patch...

SolomonGifford’s picture

Status: Needs review » Needs work

This patch doesn't work unless applied after going to admin/config/workflow/rules/links and setting some rules.

Funksmaname’s picture

patch #9 seemed to do the trick for me straight after initial install.
Now to work out how to create link events! :P

silkogelman’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Priority: Normal » Critical

This issue prevents being able to use the module.

silkogelman’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new3.62 KB

Applied Patch from #2 and #6 and tested with the configuration suggested in http://drupal.org/node/1491940#comment-6174798

It seems to work perfectly, so setting this to RTBC.
Thanks for the patches guys!

Attached is the patched version of the module, so people can test it without having to apply both patches.

P.S.
In my case having rules_link enabled prevented this rules_linkevent configuration from working properly.
However, that seems like a matter for another issue.

deggertsen’s picture

Status: Reviewed & tested by the community » Needs work

Could somebody roll this into one patch and then I will try to get it committed?

Thanks.

deggertsen’s picture

Status: Needs work » Fixed
StatusFileSize
new987 bytes

Committed. Thanks to @jpontani, @coleman.sean.c, and all who contributed here.

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