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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Project: Views (for Drupal 7) » Omega
Version: 7.x-3.x-dev » 7.x-4.x-dev

Seems to be an issue of omega.

wimberb’s picture

@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.

wimberb’s picture

Hmmm...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.

RobertInOP’s picture

Version: 7.x-4.x-dev » 7.x-3.x-dev
Component: Miscellaneous » Code

@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?

wimberb’s picture

Version: 7.x-3.x-dev » 7.x-3.1

Does 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.

likewhoa’s picture

@wimberb turn off error reporting if this is on a production site.

wimberb’s picture

That 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.

likewhoa’s picture

@wimberb production sites should not have error reporting on :P that should only be on on development sites.

wimberb’s picture

My 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.

likewhoa’s picture

@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.

Yuri’s picture

I confirm that this issue indeed is still present and needs a solution

wimberb’s picture

Just 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.

nsciacca’s picture

It 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.

wimberb’s picture

Thank you nsciacca. That seems to have done the trick. This has been driving me nuts. Granted that's not a long drive but still....

mrfelton’s picture

Status: Active » Needs review
FileSize
678 bytes

agreed.

acrollet’s picture

Status: Needs review » Reviewed & tested by the community

works for me, patch is dead simple and gets rid of the error.

fubhy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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

quantos’s picture

Although ...

... 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.

fchandler’s picture

Drupal 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

tkoterwas’s picture

Title: Latest Dev causing errors in Omega theme » Latest Views Release version 7.x-3.6 causing errors in Omega theme
Status: Closed (fixed) » Reviewed & tested by the community

I 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.

othermachines’s picture

Also confirming patch in #15 fixes the problem.

Drupal 7.20, Views 3.6, Omega 3.1

traveller’s picture

Patch from #15 unfortunately didn't work for me.

Drupal 7.21, Views 3.6, Omega 3.1 sub-theme

othermachines’s picture

@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.

traveller’s picture

@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.

likewhoa’s picture

Title: Latest Views Release version 7.x-3.6 causing errors in Omega theme » Notice: Undefined index: quantity in omega_views_mini_pager()
Version: 7.x-3.1 » 7.x-3.x-dev

@traveller "Notice: Undefined index: quantity in omega_views_mini_pager() etc." means that you didn't actually apply the patch.

Tritof’s picture

The patch in #15 works fine for me.
Thanks a lot.
Cheers

nateman332’s picture

Great! Patch in #15 worked!

JSCSJSCS’s picture

#15 worked for me too after upgrading to views 3.6 and getting error #1

jordan8037310’s picture

Just applied the patch as well.

Drupal 7.22, Views 7.x-3.6, Omega 3.1 Sub-theme.

kimjoel’s picture

#15 Works for me too.

jamescl’s picture

I 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

mastermindg’s picture

#15 works for me.

Drupal 7.22, Views 7.x-3.7, Omega 3.1 Sub-theme.

AaronBauman’s picture

Status: Reviewed & tested by the community » Postponed

patch 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.

marbaque’s picture

Great, thanks

chirhotec’s picture

@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?

chirhotec’s picture

Ok, 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.

AaronBauman’s picture

I'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.

othermachines’s picture

It 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:

patch in #15 removes 2 variable declarations for variables referenced 2 lines later

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.

rpinckney’s picture

The patch worked for me! Thanks!

codemode01’s picture

OMG-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.

druroot’s picture

Version: 7.x-3.x-dev » 7.x-3.1
Status: Postponed » Needs review
FileSize
640 bytes

I 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.

Status: Needs review » Needs work

The last submitted patch, omega-hook_views_mini_pager-1828552-42.patch, failed testing.

druroot’s picture

Status: Needs work » Needs review
FileSize
1020 bytes

Actually, 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.

Status: Needs review » Needs work

The last submitted patch, omega-hook_views_mini_pager-1828552-42.patch, failed testing.

druroot’s picture

Lets try that again from the right directory.

pixelsweatshop’s picture

Status: Needs work » Needs review
pepipe’s picture

The 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.

drupal_was_my_past’s picture

omega_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.

othermachines’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
Status: Needs review » Fixed

Kinda 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).

Status: Fixed » Closed (fixed)

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

idcm’s picture

#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?

othermachines’s picture

Hi, @idcm - Install latest -dev version, clear caches. If that doesn't get rid of the error, open a new issue.

idcm’s picture

Thanks @othermachines. That did the trick.

HeathN’s picture

Issue summary: View changes

#15 worked

HeathN’s picture

#15 worked

MariaWebIdeas’s picture

Thanks @druroot - patch #46 worked for me (I tried patch #15 with no luck)

howdytom’s picture

Patch #15 works for me.

Excellent. Thank you, mrfelton

Yazzbe’s picture

#15 also works for me on Drupal 7.56