If the base_path() is '/' this code below removes all '/' from the $href and what I can see is that it should only remove the base_path in the begining of $href. Or am I wrong?

// theme.inc:46 in calendar_preprocess_date_views_pager()
$part_path = str_replace(base_path(), '', $href);

// example
// $href = '/calendar/month/2011-10'
// base_path() is '/'
// $part_path is then 'calendarmonth2011-10'

If I right, a suggestion for a solution to the problem is

$part_path = (strpos($href, base_path()) === 0) ? substr($href, strlen(base_path())) : $href;

// if the base_path() always is first in the $href it could be
// $part_path = substr($href, strlen(base_path()));

// preg_replace may also be used and set the limit to 1, but I am not sure if it is a good idea to use that function when base_path could be / and what I know it is not so good to have that as a pattern in regex expressions.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Scyther’s picture

See next comment

Scyther’s picture

Issue summary: View changes

Rewriten

Scyther’s picture

Title: calendar_menu_local_tasks_alter() $item['href'] gets all the '/' stripped » $part_path in calendar_preprocess_date_views_pager() seems to be incorrect when base_path() is '/'

The issue above also seems to be error causing the Notice: Undefined index: access in calendar_menu_local_tasks_alter() (line 50 of /public_html/sites/all/modules/calendar/calendar.module) in #1265590: My "month | week | day | year " navigation menus are gone from the calendar.

// $tabs['path'] is $part_path from calendar_preprocess_date_views_pager and it is incorrect and $item gets NULL from menu_get_item.
foreach ($calendar_data['tabs'] as $tab) {
$item = menu_get_item($tab['path']);   
// ...
// ...
if ($item['access']) { // $item['access'] is then a undefined index.
drewkeller’s picture

Status: Patch (to be ported) » Active

I changed it to $part_path = substr($href, strlen(base_path())); and got this output for dvr($calendar_links):

array(
  'calendar/month' => array(
    'tabs' => array(
      'month' => array(
        'title' => 'Month',
        'path' => 'calendar/month/2011-09',
      ),
      'week' => array(
        'title' => 'Week',
        'path' => 'calendar/week/2011-W36',
      ),
      'day' => array(
        'title' => 'Day',
        'path' => 'calendar/day/2011-09-01',
      ),
      'year' => array(
        'title' => 'Year',
        'path' => 'calendar/year/2011',
      ),
    ),
    'types' => array(
      'month',
      'week',
      'day',
      'year',
    ),
  ),
)

This does seem to fix the issue and I get the links at the top in whatever style the active theme shows for 'tabs'.

drewkeller’s picture

Status: Active » Patch (to be ported)
FileSize
1.07 KB

I attached the patch in the other thread but i'll attach it here, too. If I mark the status for patching, I assume it will help get it applied?

Scyther’s picture

Status: Active » Needs review

If the maintainers agree that this fixes the problem they will probably apply it. But it may need some more testing from others.

Could any maintainer comment about this issue?

arlinsandbulte’s picture

Assigned: Unassigned » arlinsandbulte
Status: Needs review » Reviewed & tested by the community

Code makes sense to me.
I will test a little more and commit if all goes well or if KarenS has no objections...

Scyther’s picture

Any update on this?

arlinsandbulte’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Added some info