Jump to content
HancoEuropa

Disappearing Announcements

Recommended Posts

Bit stumped.

The Setup:  Say I have an announcement in English, and I have not made any other language text by hook or by the Admin interface for Announcements.

Using AnnouncementEdit hook, on save, I add a record in tblannouncements, set to the second language (parentid = englishid, language = newlanguage)

I do that addition with insertGetId, and yeah, I get the new id for the inserted tblannouncements record just fine.    It's sequential, the next one that was available.

However, a second later, the record is not there.   Doing a refresh on the tblannouncements table in phpMyAdmin, the new language  record never shows, like it never existed.

I'm able to take that insertGetId number and put it into a different table, which is why I know what it is and that it existed.

So the id advances one each time -- but on save, something erases the new announcement  record made in my hook.

Can someone point me to where this happens?   Cuz it's not in my hook, spent like 5 hours going over it.

Guessing it is a "nobody but WHMCS is allowed to insert an announcement record with parentid" feature 👊

Thanks!

Share this post


Link to post
Share on other sites

Without knowing the code, it is difficult to make a conclusion. If I were in this situation, the first thing I would do would be to see if the entry was really added (even if the ID was incremented, and that speaks for it) by looking for the ID in the database right after the insertGetId query and logging the content via:

logActivity (json_encode($query->field));

If the expected content is logged, I would then grep for any hooks that change something in the announcement table.

Edit: The other thing I would think of is that WHMCS may automatically remove incorrect entries. For example, if some relation is not correct. To exclude this thesis, you can place the existing values of an entry in your hook, delete the entry from the database and see what happens if you run the hook again.

Edited by string

Share this post


Link to post
Share on other sites

Hi, 

When the initial announcement is created or edited, the AnnouncementEdit/AnnouncementAdd hook point is run. 

After this hook point is run, the announcement logic will sync the languages within the announcement based on the data entered in the form just submitted. Part of the sync removes all child entries and then loops through each language and loops through only inserting rows where the content has been defined for the language.

Your issue here is that you are attempting to insert a row into the table just before the sync happens.

I have opened CORE-16927 internally to change when the hook points mentioned above run to ensure that all the announcement data has been written. 

Share this post


Link to post
Share on other sites

I have just noticed, as a workaround, you could use the API to add/update your announcements where this hook does run differently, without the additional language sync.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated