Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning's when no sideboxes present #2

Closed
avril-gh opened this issue Jan 9, 2013 · 4 comments
Closed

Warning's when no sideboxes present #2

avril-gh opened this issue Jan 9, 2013 · 4 comments
Assignees
Milestone

Comments

@avril-gh
Copy link
Contributor

avril-gh commented Jan 9, 2013

MyBB 1.6.9 / PHP 5.4.10

when there are no sideboxes present in 'manage sideboxes' tab, (for example - just after installing plugin)
following warnings occur in website front page

Warning [2] Invalid argument supplied for foreach() - Line: 99 - File: inc/plugins/adv_sidebox.php PHP 5.4.10 (Linux)

/inc/plugins/adv_sidebox.php 99 errorHandler->error
/inc/class_plugins.php 101 adv_sidebox_start
/index.php 25 pluginSystem->run_hooks

Ofcourse warnings can be hidden but it would be better to fix it now while there are still no other issues, than fight it later when many new warnings would accumulate on stack.

@WildcardSearch
Copy link
Owner

I can't reproduce that error. Are you using the latest version?

@ghost ghost assigned WildcardSearch Jan 9, 2013
WildcardSearch pushed a commit that referenced this issue Jan 9, 2013
Check for non array result from adv_sidebox_get_all_sideboxes() before foreach loop
@WildcardSearch
Copy link
Owner

Try that update and see if it solves your problem. 👍

@avril-gh
Copy link
Contributor Author

Are you using the latest version?

Advanced Sidebox (1.2) (at php 5.4.10)

I can't reproduce that error.

Some servers may be configured to hide errors and warnings.
Try enabling error_reporting for test before foreach in line 90.

error_reporting(E_ALL ^ E_NOTICE);
foreach($sideboxes as $this_box)

Check for non array result from adv_sidebox_get_all_sideboxes() before foreach loop

Yes, when there are no sideboxes published then $sideboxes is empty and cause warnings.
Theres many ways to fix it. Personally i added (array) in line 90.
Seems everything working ok now and not cause warnings when theres no sideboxes.

    foreach((array)$sideboxes as $this_box)

Fixed. Thanks

(btw - your plugin is awesome, i love how freely it can be customised
and that practically anything can be put to sideboxes.
Excellent. Keep up good work)

@avril-gh avril-gh reopened this Jan 10, 2013
@WildcardSearch
Copy link
Owner

Thanks for your kind words.

I can't cast the return of adv_sidebox_get_all_sideboxes() as an array because non-array is meant to signify no sideboxes. I just forgot to check.

Added a check that exits the function if the return is non-array. :)

Cheers.

WildcardSearch pushed a commit that referenced this issue Feb 2, 2013
Issue #32 fixed in which boxes using default title get a decription as well

Issue #31 fixed by porxy of other changes

Issue #30 fixed by passing correct information to custom box `build_template()` method

Issue #26 should be finished as well

Issue #29 (discussion) add-on modules no longer have to worry about separating template variable for Stereo type modules. It is handled within the core so that devlopers never need worry about this functionality unless they wish to use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants