Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After updating to the latest Dev version of Views, 7.x-3.5+21-dev (2012-Oct-30), I started getting the following error:
Notice: Undefined index: quantity in omega_views_mini_pager() (line 214 of /home/***/public_html/sites/all/themes/omega/omega/includes/omega.theme.inc).
I know nothing about coding so I don't know how to correct this. However, here is lines 208-236 from omega.theme.inc to maybe figure out why these errors suddenly started occurring.
function omega_views_mini_pager($vars) {
global $pager_page_array, $pager_total;
$tags = $vars['tags'];
$element = $vars['element'];
$parameters = $vars['parameters'];
$quantity = $vars['quantity'];
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// current is the page we are currently paged to
$pager_current = $pager_page_array[$element] + 1;
// max is the maximum page number
$pager_max = $pager_total[$element];
// End of marker calculations.
$li_previous = theme('pager_previous',
array(
'text' => (isset($tags[1]) ? $tags[1] : t('‹‹')),
'element' => $element,
'interval' => 1,
'parameters' => $parameters,
)
);
if (empty($li_previous)) {
$li_previous = "";
}
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#49 | omega-mini-pager-1828552-49.patch | 678 bytes | drupal_was_my_past |
#46 | omega-hook_views_mini_pager-1828552-46.patch | 928 bytes | druroot |
#44 | omega-hook_views_mini_pager-1828552-42.patch | 1020 bytes | druroot |
#42 | omega-hook_views_mini_pager-1828552-42.patch | 640 bytes | druroot |
#15 | 1828552-omega-hook_views_mini_pager.patch | 678 bytes | mrfelton |
Comments
Comment #1
dawehnerSeems to be an issue of omega.
Comment #2
wimberb CreditAttribution: wimberb commented@dawehner I would agree with you there about it being an issue with Omega. Except the issue was never there before the latest Views Dev release. So something has apparently changed in Views to cause this. If the latest Dev is causing problems in one theme it might also be causing the same problem in other themes as well.
Comment #3
wimberb CreditAttribution: wimberb commentedHmmm...I just realized this somehow got moved from Views over to Omega and was marked as a 7.4 issue. I am actually using Omega 7.x-3.1.
Comment #4
RobertInOP CreditAttribution: RobertInOP commented@wimberb I am also getting this error. I have Views 7.x-3.5+21-dev and Omega theme 7.x-3.1+4-dev.
The header for that include file section is:
/**
* Implements hook_views_mini_pager().
*
* This custom theming for views_mini_pager changes the previous/next
* links to remove theme completely when not present to avoid the
* messing up the spacing/theming in the list.
*/
So it is the Omega theme overriding Views code - and now causing an error doing so. the line seems to be:
$quantity = $vars['quantity'];
so I am guessing that the quantity value in $vars has been changed/renamed. I'm not a great coder either but maybe this will help someone else out?
Comment #5
wimberb CreditAttribution: wimberb commentedDoes anybody have a clue how to correct this? I would really like to stop the hundreds and hundreds of errors this is producing every day.
Comment #6
likewhoa CreditAttribution: likewhoa commented@wimberb turn off error reporting if this is on a production site.
Comment #7
wimberb CreditAttribution: wimberb commentedThat is the solution? Perhaps I should put electrical tape over the engine warning light in my Jeep too just in case it decides to come on.
Comment #8
likewhoa CreditAttribution: likewhoa commented@wimberb production sites should not have error reporting on :P that should only be on on development sites.
Comment #9
wimberb CreditAttribution: wimberb commentedMy site is constantly under development. I add new functionality and update modules all the time. If error reporting is turned off then I won't know if a problem arises. I also use it to alert me to security threats such as spam bots constantly trying to gain access to the site. My site is not something that I just developed then started adding content. It is growing all the time.
Comment #10
likewhoa CreditAttribution: likewhoa commented@wimberb i guess you don't understand the concept of a production vs development environment. You shouldn't be doing all your updates on a single site, this is why you have a development site which you do your development on and then you push these changes to a production site after it has gone through QA.
Some people have Development, Staging then Production environments.
Comment #11
Yuri CreditAttribution: Yuri commentedI confirm that this issue indeed is still present and needs a solution
Comment #12
wimberb CreditAttribution: wimberb commentedJust wondering if the general consensus is that the log messages should be turned off on a production site. I find the log messages very informative and it does state right on the log messages page "The Database logging module monitors your website, capturing system events in a log (shown here) to be reviewed by an authorized individual at a later time. This log is a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the Recent log messages report on a regular basis, as it is often the only way to tell what is going on."
But apparently I don't know what I'm doing in this regard because I want to keep the log messages turned on.
Comment #13
nsciaccaIt looks like that code was copied & pasted from the "omega_pager" theme function and doesn't really do anything. Although the $quanity var is set (line 214 - omega.theme.inc), all it is used for is setting the $pager_middle var (line 219 - omega.theme.inc), which in turn is not used in the rest of the function. I would suggest commenting out lines 214 & 219, you will see no effect on your system and the log messages will disappear.
Lines to remove/comment out:
214: $quantity = $vars['quantity'];
219: $pager_middle = ceil($quantity / 2);
If you want to see where $pager_middle is actually used, look at the "omega_pager" function (line 21 - omega.theme.inc).
Side note about log messages: It is advisable to turn off all log messages for production sites. If there is some type of message that needs to be displayed based on some action to the end user then you can manually create those using Rules or another module. The log messages that display undefined indexes or other PHP warnings should be recorded and addressed by the site manager. Undefined indexes are often due to legacy code and did not appear before PHP "5.something" so not everything has been checked with isset() before assignment.
Comment #14
wimberb CreditAttribution: wimberb commentedThank you nsciacca. That seems to have done the trick. This has been driving me nuts. Granted that's not a long drive but still....
Comment #15
mrfelton CreditAttribution: mrfelton commentedagreed.
Comment #16
acrollet CreditAttribution: acrollet commentedworks for me, patch is dead simple and gets rid of the error.
Comment #17
fubhy CreditAttribution: fubhy commentedThanks!
Comment #19
quantos CreditAttribution: quantos commentedAlthough ...
... I've just received this error message for the first time, after patching Views 7.x-3.6 out today so far as I know. The previous version that you guys seemed to have had the problem with didn't trigger the warning. I'm on the latest Omega 7.x-3.x line too.
Has there been any official word/update from the Omega management team on this? Would be good to get it sorted properly.
Thanks
Q.
Comment #20
fchandler CreditAttribution: fchandler commentedDrupal 7.21, Views 3.6, Views Slideshow 3.0, Omega 3.1 sub-theme
Just updated to Views 3.6 and got the same error. Solved it for my site by changing the pager sections in Views to not use a pager. It got rid of the error message. However, it is a small site with only two views enabled at this point, and only one of which wanted to use the pager (a slideshow). Probably not a solution for very many. The slideshow only displays one image at a time, so it works.
Under Pager in Views edit.
Use pager: Display all items | All items
Comment #21
tkoterwas CreditAttribution: tkoterwas commentedI can also confirm this error appears after updating to the latest Views release (Security Update).
Drupal 7.20, Views 3.6, Omega 3.1 sub-theme.
I've temporarily switched from using the mini pager to the full pager as a workaround on production sites and tested the patch in #15 above on test sites, and it got rid of the error.
Comment #22
othermachines CreditAttribution: othermachines commentedAlso confirming patch in #15 fixes the problem.
Drupal 7.20, Views 3.6, Omega 3.1
Comment #23
traveller CreditAttribution: traveller commentedPatch from #15 unfortunately didn't work for me.
Drupal 7.21, Views 3.6, Omega 3.1 sub-theme
Comment #24
othermachines CreditAttribution: othermachines commented@traveller - What is the error you get (if any) after applying the patch? This patch actually gets rid of the line in the error, so you couldn't possibly be getting the same one.
Comment #25
traveller CreditAttribution: traveller commented@othermachines
I get the same "Notice: Undefined index: quantity in omega_views_mini_pager() etc." entry in log, as well as strange acting [<<] and [>>] navigation buttons, which become fully described ones, with "previous" and "next".
Reverting to Views 3.5 and original omega.theme.inc clears the problems.
Comment #26
likewhoa CreditAttribution: likewhoa commented@traveller "Notice: Undefined index: quantity in omega_views_mini_pager() etc." means that you didn't actually apply the patch.
Comment #27
Tritof CreditAttribution: Tritof commentedThe patch in #15 works fine for me.
Thanks a lot.
Cheers
Comment #28
nateman332 CreditAttribution: nateman332 commentedGreat! Patch in #15 worked!
Comment #29
JSCSJSCS CreditAttribution: JSCSJSCS commented#15 worked for me too after upgrading to views 3.6 and getting error #1
Comment #30
jordan8037310 CreditAttribution: jordan8037310 commentedJust applied the patch as well.
Drupal 7.22, Views 7.x-3.6, Omega 3.1 Sub-theme.
Comment #31
kimjoel CreditAttribution: kimjoel commented#15 Works for me too.
Comment #32
jamescl CreditAttribution: jamescl commentedI had the similar issue after upgrading views on pages that used a views pager. I resolved this by setting a pager ID in the pager settings for that view (i.e. a number greater than zero in the Pager ID field)Only had one pager on the page, so don't believe I really need to set this at all.
My errors were below, I'm assuming that the errors on line 214 will be resolved by doing the same?Notice: Undefined variable: pager_middle in sites/all/themes/omega/omega/omega/includes/omega.theme.inc on line 32
Notice: Undefined variable: quantity in sites/all/themes/omega/omega/omega/includes/omega.theme.inc on line 34
EDIT: OK. So this reverted back to the error. No idea what's going on
Comment #33
mastermindg CreditAttribution: mastermindg commented#15 works for me.
Drupal 7.22, Views 7.x-3.7, Omega 3.1 Sub-theme.
Comment #34
AaronBaumanpatch in #15 removes 2 variable declarations for variables referenced 2 lines later.
this is not a well-formed patch.
For those reporting that patch #15 worked: there must have been some other changes you made that hid the issue.
That said, updating to latest version dev actually solved the issue for me.
Marking this as postponed until someone can provide steps to reproduce using latest dev version.
Comment #35
marbaque CreditAttribution: marbaque commentedGreat, thanks
Comment #36
chirhotec CreditAttribution: chirhotec commented@aaronbauman, which project did you update to dev to get it to work: views or the omega theme?
I first noticed this error when I switched from Views 7.x-3.5 to 7.x-3.7. I switched to the dev version, 7.x-3.7+2-dev, and it didn't fix the problem.
I'm using a sub-theme based on Omega 7.x-3.1. In case the error was caused by Omega somehow removing $variables['quantity'] before my mini pager function was called, I switched to the dev version of the theme (7.x-3.1+7-dev). Didn't fix it.
My sub-theme implements its own mini pager function via theme_views_mini_pager($vars). Its implementation is a modified version of the core theme_pager($vars) taken directly from drupal_core/includes/pager.inc. The parts that are causing errors are still in the original core function, and according to the API for theme_pager, $vars['quantity'] should be available. Is theme_views_mini_pager not based on theme_pager? Is there a reason Views wouldn't include the same parameters?
Comment #37
chirhotec CreditAttribution: chirhotec commentedOk, so playing around with it some more...
$variables['quantity'] should be the value listed in the View's pager settings, under "Number of pager links visible". So it really should be getting to this function somehow. Are we sure this is an omega problem, not a Views issue?
For my purposes, I'm already implementing my own version of the function, so its sufficient for me to just hard code the $quantity for now.
Comment #38
AaronBaumanI'm running omega 7.x-3.1+7-dev and views-7.x-3.6+4-dev and don't have the notice anymore.
sorry, I can't remember the sequence in which I updated them.
Comment #39
othermachines CreditAttribution: othermachines commentedIt would make sense that the error would appear after upgrading to Views 7.x-3.6 because of this commit: Issue #1625248 by Jorrit | sigent: Fixed Mini Pager ('tags') aren't being applied. As of 7.x-3.6 'quantity' is being unset by Views as an "unused setting".
@aaronbauman says:
I think you may be looking at omega_pager(), not omega_views_mini_pager(). #15 removes two variables which are entirely superfluous (and were likely carried over from omega_pager()). As far as I can tell it's still good.
That said, this patch was committed to dev on Jan. 25 (see #17): Issue #1828552 by nsciacca, mrfelton: Fixed pagers.
Update to latest dev and the error will be resolved.
Comment #40
rpinckney CreditAttribution: rpinckney commentedThe patch worked for me! Thanks!
Comment #41
codemode01 CreditAttribution: codemode01 commentedOMG-Thank you for the patch! This was getting progressively worse, to the point that I had to scroll to reach the bottom of the errors.
Pagers work fine - displayed only when required - zero errors.
(the comment about the electrical tape over the engine light was hilarious)
Thanks ppl.
Comment #42
druroot CreditAttribution: druroot commentedI think it's better to wrap the quantity assignment in and isset() conditional and provide a default than to just delete the variable completely. This code shouldn't interfere with the pager quantity calculations because a default is provided.
Comment #44
druroot CreditAttribution: druroot commentedActually, there are two instances of the quantity assignment. The second one was the one causing the warning in my case. This patch addresses them both.
Comment #46
druroot CreditAttribution: druroot commentedLets try that again from the right directory.
Comment #47
pixelsweatshop CreditAttribution: pixelsweatshop commentedComment #48
pepipe CreditAttribution: pepipe commentedThe last patch seems to correct the problem. Thanks!
Previous patch work fine when view pager was set to "Paged output, mini pager" but if it's set to "Paged output, full pager" it would give a similar error so I think $quantity is needed.
Comment #49
drupal_was_my_past CreditAttribution: drupal_was_my_past commentedomega_views_mini_pager()
doesn't actually need $quantity or $pager_middle. Here is a patch that just removes both variables and gets rid of the error.Comment #50
othermachines CreditAttribution: othermachines commentedKinda going in circles here, folks. ;)
The problem was fixed and committed in 7.x-3.x-dev. See comment #39. Either use that or patch and wait for a new 3.x release. Might be awhile since it looks like maintainers are busy with 4.x and are looking for a new maintainer for this branch.
@rocket_nova, your patch is identical to that which was committed (see #15).
Comment #52
idcm CreditAttribution: idcm commented#32 comment - we are experiencing the following intermittently. I applied the patches and solved a couple of my issues.
Notice: Undefined variable: pager_middle in omega_pager() (line 32 of /var/.../sites/all/themes/omega/omega/includes/omega.theme.inc).
Notice: Undefined variable: pager_middle in omega_pager() (line 34 of /var/.../sites/all/themes/omega/omega/includes/omega.theme.inc).
Can't figure out what's causing it. It appears on a page, we refresh and sometimes it disappears, sometimes not.
thoughts?
Comment #53
othermachines CreditAttribution: othermachines commentedHi, @idcm - Install latest -dev version, clear caches. If that doesn't get rid of the error, open a new issue.
Comment #54
idcm CreditAttribution: idcm commentedThanks @othermachines. That did the trick.
Comment #55
HeathN CreditAttribution: HeathN commented#15 worked
Comment #56
HeathN CreditAttribution: HeathN commented#15 worked
Comment #57
MariaWebIdeas CreditAttribution: MariaWebIdeas commentedThanks @druroot - patch #46 worked for me (I tried patch #15 with no luck)
Comment #58
howdytom CreditAttribution: howdytom as a volunteer commentedPatch #15 works for me.
Excellent. Thank you, mrfelton
Comment #59
Yazzbe CreditAttribution: Yazzbe commented#15 also works for me on Drupal 7.56