Skip to content

Commit

Permalink
reimplement local_blog_id=0 localization for inside MTTags
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadam committed Sep 29, 2022
1 parent f360a1c commit 14ce10f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/MT/Template/Tags/Tag.pm
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ sub _hdlr_tags {
@slice_tags = @slice_tags[ 0 .. $limit - 1 ];
}

# Remove local blog ID from MTTags since it is cross-blog
# and hence MTMultiBlogIfLocalBlog doesn't make sense there.
local $ctx->{__stash}{local_blog_id} = 0;

local $ctx->{__stash}{include_blogs} = $args->{include_blogs};
local $ctx->{__stash}{exclude_blogs} = $args->{exclude_blogs};
local $ctx->{__stash}{blog_ids} = $args->{blog_ids};
Expand Down
6 changes: 5 additions & 1 deletion php/lib/block.mttags.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# $Id$

function smarty_block_mttags($args, $content, &$ctx, &$repeat) {
$localvars = array(array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count', 'all_tag_count', 'include_blogs', 'exclude_blogs', 'blog_ids', '__out'), common_loop_vars());
$localvars = array(array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count', 'all_tag_count', 'include_blogs', 'exclude_blogs', 'blog_ids', '__out', 'local_blog_id'), common_loop_vars());
if (!isset($content)) {
$ctx->localize($localvars);

Expand All @@ -19,6 +19,10 @@ function smarty_block_mttags($args, $content, &$ctx, &$repeat) {
require_once('multiblog.php');
multiblog_block_wrapper($args, $content, $ctx, $repeat);

# Fix for MTMultiBlogIfLocalBlog which should never return
# true with MTTags block because tags are cross-blog
$ctx->stash('local_blog_id', 0);

$ctx->stash('include_blogs', isset($args['include_blogs']) ? $args['include_blogs'] : null);
$ctx->stash('exclude_blogs', isset($args['exclude_blogs']) ? $args['exclude_blogs'] : null);
$ctx->stash('blog_ids', isset($args['blog_ids']) ? $args['blog_ids'] : null);
Expand Down
2 changes: 0 additions & 2 deletions t/mt7/multiblog/02.tags.t
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ anemones 6
template-module:2
=== MTC-28585 mt:MultiBlogIfLocalBlog never be TRUE in context mode
--- SKIP
--- template
<mt:MultiBlog mode="context"><mt:MultiBlogLocalBlog><MTTags glue=','>[<mt:MultiBlogIfLocalBlog>NEVER-VISIBLE</mt:MultiBlogIfLocalBlog>]</MTTags></mt:MultiBlogLocalBlog></mt:MultiBlog>
--- expected
Expand All @@ -575,7 +574,6 @@ template-module:2
{ 1 => 2, 2 => 2 }
=== MTC-28585 mt:MultiBlogIfLocalBlog never be TRUE in loop mode
--- SKIP
--- skip_php
--- template
<mt:MultiBlog mode="loop"><mt:MultiBlogLocalBlog><MTTags glue=','>[<mt:MultiBlogIfLocalBlog>NEVER-VISIBLE</mt:MultiBlogIfLocalBlog>]</MTTags></mt:MultiBlogLocalBlog>
Expand Down

0 comments on commit 14ce10f

Please sign in to comment.