[Liam W.] Post Macros

[Liam W.] Post Macros 5.2.2 Fix 8

No permission to download
I regularly open the Rebuild Caches page to find that the Global Macro Enrolment process has not completed.
I see a message saying that some processes need completing and when I click to continue I see the message saying that it's processing Global Macro Enrolment.
Where is this process being run from? The addon (5.2.0 fix 1) is currently disabled and I see nothing relevant in the Cron jobs page.
 
I regularly open the Rebuild Caches page to find that the Global Macro Enrolment process has not completed.
I see a message saying that some processes need completing and when I click to continue I see the message saying that it's processing Global Macro Enrolment.
Where is this process being run from? The addon (5.2.0 fix 1) is currently disabled and I see nothing relevant in the Cron jobs page.

Same thing happens on my site!
 
I regularly open the Rebuild Caches page to find that the Global Macro Enrolment process has not completed.
I see a message saying that some processes need completing and when I click to continue I see the message saying that it's processing Global Macro Enrolment.
Where is this process being run from? The addon (5.2.0 fix 1) is currently disabled and I see nothing relevant in the Cron jobs page.
Hello,

You mean there is no block to rebluid the inscriptions of the macro gobal post?
like this : http://prntscr.com/w7v3cz

Edit :
It executes a reconstruction during the permission of the global post macro.
This means, when creating a gobal macro post, when changing permission etc... he will have a reconstruction of the post-macro gobal.

Regards, CRUEL-MODZ
 
Last edited:
Hello,

You mean there is no block to rebluid the inscriptions of the macro gobal post?
like this : http://prntscr.com/w7v3cz

Edit :
It executes a reconstruction during the permission of the global post macro.
This means, when creating a gobal macro post, when changing permission etc... he will have a reconstruction of the post-macro gobal.

Regards, CRUEL-MODZ
There is no rebuild option at /admin.php?tools/rebuild.

I’m not clear when the process is run. Is it
  1. when the global macro is created or edited or
  2. when a post using a global macro is created or edited?
Because it is being run regularly and global macros are not being created or edited regularly.
And when it is run, it appears not to complete successfully.
I have suspicions that it’s locking tables and causing our database to crash.
 
Last edited:
There is no rebuild option at /admin.php?tools/rebuild.
Yes

I’m not clear when the process is run. Is it
  1. when the global macro is created or edited or
  2. when a post using a global macro is created or edited?
I think this is the first option who is using, moreover I think that this and run every time a user subscribes to a post macro global
Because it is being run regularly and global macros are not being created or edited regularly.
And when it is run, it appears not to complete successfully.
I have suspicions that it’s locking tables and causing our database to crash.
do you have an error the error log ? because if he can't complete the reconstruction it means that he finds an error
 
I think this is the first option who is using, moreover I think that this and run every time a user subscribes to a post macro global
1. This issue is also triggered when simply changing user group permissions (regardless of any macro permissions). If you do that, 9 out of 10 times the admin cp tells you that some rebuilds have not run to completion and to trigger a re-run.

2. I also have a different issue that worked with Liam's version on XF 2.1. I just upgraded to your version after upgrading to XF 2.2
My macro:
Code:
Changed Name from [ICODE]{?+Old Name}[/ICODE] to [ICODE]{?+New Name}[/ICODE].

This has worked with Liam's version. With yours the modal looks like this:
1608804720546.png

3. Furthermore, when you add the same placeholder name, it requests the same placeholder twice. For example if you enter {?+Old Name} two times, the Old Name placeholder will be shown twice in the "Complete placeholders" modal. I'd suggest you only fill it in once and it gets replaced to every placeholder that has the same name.
 
Last edited:
1. This issue is also triggered when simply changing user group permissions (regardless of any macro permissions). If you do that, 9 out of 10 times the admin cp tells you that some rebuilds have not run to completion and to trigger a re-run.
That makes sense, obviously a lot of people have the same problem, but I can't get this error :(
2. I also have a different issue that worked with Liam's version on XF 2.1. I just upgraded to your version after upgrading to XF 2.2
My macro:
indeed, this will be fixed in the next update.
3. Furthermore, when you add the same placeholder name, it requests the same placeholder twice. For example if you enter {?+Old Name} two times, the Old Name placeholder will be shown twice in the "Complete placeholders" modal. I'd suggest you only fill it in once and it gets replaced to every placeholder that has the same name.
Yes, this is normal, do not put twice the same name,
 
That makes sense, obviously a lot of people have the same problem, but I can't get this error :(
I think this might be depending on the amount of groups or users inside those groups. My best guess would be that the rebuild upon saving takes a longer time the more users you have and hence XF queues this as a rebuild job?

indeed, this will be fixed in the next update.
Nice, thanks!

Yes, this is normal, do not put twice the same name,
And what if I want to insert the same text twice without my users needing to type the same info twice? My suggestion would be to simply distinct the placeholder names and replace each placeholder with the value that was entered. Thus you would only show a placeholder input once (regardless of how many times it is specified in the content) and replace all occurences that have the same name.
 
I think this might be depending on the amount of groups or users inside those groups. My best guess would be that the rebuild upon saving takes a longer time the more users you have and hence XF queues this as a rebuild job?
Yes, that's probably what happened, but I won't be able to do much in this case :'(
And what if I want to insert the same text twice without my users needing to type the same info twice?
I'll see what I can do
 
And what if I want to insert the same text twice without my users needing to type the same info twice?
Hello,

I have found a solution, I will share it tomorrow if I have time.

The placeholders will have to be the same, in this case if you want it to be replaced by the same thing.

Regards, CRUEL-MODZ
 
The placeholders will have to be the same, in this case if you want it to be replaced by the same thing.
Sure, that would be expected, I guess. If there are four placeholders, three with the same name, you'd enter two values and one would be inserted three times (the one with the same placeholder name).
 
Sure, that would be expected, I guess. If there are four placeholders, three with the same name, you'd enter two values and one would be inserted three times (the one with the same placeholder name).
I understood,
But in fact when you're going to create your macro post you'll put placeholders wherever you want, and I'm looking to see if the placeholders are the same as another one

Example :
My post macro :
Changed Name from {?+Old Name} to {?+New Name}.
Changed Name from {?+Old Name} to {?+New Name}.

there are 4 placeholders, but there are 2 * 2 the same ones

So: {?+Old Name} and {?+New Name}
When using this macro it will ask you to fill in this two fields, and will automatically put the results for the 2 other ones that correspond.
 
do you have an error the error log ? because if he can't complete the reconstruction it means that he finds an error
Haven't seen one.
I think the SQL of the rebuild needs checking. I have a suspicion that the rebuild is failing because it's locking a major table (possibly xf_user) and then session updates can't continue and they build up until the whole server falls over and the site goes down for half an hour, which is, of course, disastrous.
Is it possible to check the rebuild SQL?
I have had to disable this addon until we can be sure that it's not the cause. Or has been fixed.
 
Haven't seen one.
I think the SQL of the rebuild needs checking. I have a suspicion that the rebuild is failing because it's locking a major table (possibly xf_user) and then session updates can't continue and they build up until the whole server falls over and the site goes down for half an hour, which is, of course, disastrous.
Is it possible to check the rebuild SQL?
I have had to disable this addon until we can be sure that it's not the cause. Or has been fixed.
In my opinion it is not an error of request, for the simple reason that if it was the case there was an error.

here's all the code it executes, if someone finds an error, he can tell me and I'll release an update.:
PHP:
$start = microtime(true);

        $this->data['steps']++;

        $macrosEnrolmentFinder = $this->app->finder('LiamW\PostMacros:GlobalMacroEnrolment')->with('User')
            ->with('Macro')
            ->order('user_id')
            ->order('macro_id');

        if ($this->data['permission_combination_id'])
        {
            $macrosEnrolmentFinder->where('User.permission_combination_id', $this->data['permission_combination_id']);
        }

        $macrosEnrolmentFinder
            ->where('user_id', '>=', $this->data['position'][0])
            ->where('macro_id', '>', $this->data['position'][1]);

        $macroEnrolments = $macrosEnrolmentFinder->fetch(50);
        if (!$macroEnrolments->count())
        {
            return $this->complete();
        }

        /** @var \LiamW\PostMacros\Entity\GlobalMacroEnrolment $macroEnrolment */
        foreach ($macroEnrolments AS $macroEnrolment)
        {
            if (microtime(true) - $start >= $maxRunTime)
            {
                break;
            }

            $this->data['position'] = [$macroEnrolment->user_id, $macroEnrolment->macro_id];

            \XF::asVisitor($macroEnrolment->User, function() use ($macroEnrolment)
            {
                if (!$macroEnrolment->Macro->canEnroll($error, true))
                {
                    $macroEnrolment->delete();
                }
            });
        }

        return $this->resume();

I have had to disable this addon until we can be sure that it's not the cause. Or has been fixed.
I would like to solve this problem as soon as possible!
 
Hello,

The js is loaded with the editor, so if it is loaded it means that the editor and the js that goes with it are loaded too.
So that's not going to interfere with the loading of the page.

Regards,
 
Hello,

As I said, if the js in question is loaded, it means that the editor is loaded, but the editor doesn't come from me but from xenforo. so I can't do anything and it won't change anything at all lol.

Regards, CRUEL-MODZ
 
Top Bottom