User login

Agaric wants to know how to deny access to settings form in 4.7

Agaric got this error message:

Cannot use string offset as an array

(in, say, modules/system.module on line 745, as a hypothetical example)

Turns out this is from using return t("Access Denied") syntax when the hook_settings function expects a form array to be returned.

We thought we had the answer and posted as such here:

http://drupal.org/node/22797#comment-240833

But while this effectively denies access, no error message appears and the form is provided as just the save and reset buttons. Not the greatest user interface feedback.

CORRECTION: The above happens when you go to a settings page for a module that doesn't exist (again hypothetically, if you've deleted it and not copied it in again). However' the form buttons still appear below the error message and it'd be nice to get rid of them.

Life is so much better in Drupal 5.

Unrelated background on research into the error:

The fix here - http://drupal.org/node/16481 - made us think the problem was we needed to use FALSE not '' to set empty variables with variable_get

In this case, the problem was not caused by using an empty string, rather than FALSE.

This may only affect some versions of PHP, so a module could work on one server and destroy everything on the next.

Agaric ran into this problem on Drupal 4.7 (we are not using 4.7 of our own volition).

Agaric got this error message:

Cannot use string offset as an array

(in, say, modules/system.module on line 745, as a hypothetical example)

Turns out this is from using return t("Access Denied") syntax when the hook_settings function expects a form array to be returned.

We thought we had the answer and posted as such here:

http://drupal.org/node/22797#comment-240833

But while this effectively denies access, no error message appears and the form is provided as just the save and reset buttons. Not the greatest user interface feedback.

CORRECTION: The above happens when you go to a settings page for a module that doesn't exist (again hypothetically, if you've deleted it and not copied it in again). However' the form buttons still appear below the error message and it'd be nice to get rid of them.

Life is so much better in Drupal 5.

Unrelated background on research into the error:

The fix here - http://drupal.org/node/16481 - made us think the problem was we needed to use FALSE not '' to set empty variables with variable_get

In this case, the problem was not caused by using an empty string, rather than FALSE.

This may only affect some versions of PHP, so a module could work on one server and destroy everything on the next.

Agaric ran into this problem on Drupal 4.7 (we are not using 4.7 of our own volition).

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.