When no render engines is enabled following error will be displayed:

Notice: Undefined index: in graphapi_demo_engine() (line 48 of /home/drupalpro/websites/virtual7.local/sites/all/modules/graphapi/modules/graphapi_demo/graphapi_demo.module).

No big deal since there is a message at the bottom of the page stating "No Graph API render engines enabled. Check your modules page for a Graph API render engine".

Proposeal: Fix the Notice, change the text to a warning so it can't be overlooked, add a link to the modules page.

Patch follows.

Comments

s.daniel’s picture

StatusFileSize
new2.45 KB

Patch attached.

s.daniel’s picture

Title: Notice: Undefined index: in graphapi_demo_engine when no » Notice: Undefined index: in graphapi_demo_engine when no engine is available

title fix

clemens.tolboom’s picture

Status: Active » Needs work

The root cause is

function graphapi_demo_page($engine = NULL) {
  $engines = graphapi_get_engines();
  if (is_null($engine) && count($engines)) {
    $engine = key($engines);
  }
  return graphapi_demo_engine($engine);
}

injecting a NULL value which should not happen :(

function graphapi_demo_page($engine = NULL) {
  $engines = graphapi_get_engines();
  if (is_null($engine) && count($engines)) {
    $engine = key($engines);
  }
  if (isset($engine) {
    # valid engine
    return graphapi_demo_engine($engine);
  }
  else {
    # show warning
  }
}

What do you think?

clemens.tolboom’s picture

Status: Needs work » Fixed

I fixed the notice according to #3 and the message to the module page from #1

Thanks @s.Daniel

s.daniel’s picture

Nice - I checked your commit and its definitely better. Good way to learn some proper coding. :)

Status: Fixed » Closed (fixed)

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