Skip Navigation

[Resolved] Issue editing the existing custom code snippets

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by simonM-5 3 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#1806079

Hi

I had a chat ticket with Waqar an hour ago, which he marked as resolved, but unfortunately it is not resolved, and I cannot see it under my list of tickets.. Here's the transcript.. Please re-open the ticket...

Thanks and regards
Simon

=================
Dear customer,

Ticket "Issue editing the existing custom code snippets" has been marked as Resolved by supporter.

Below is transcript of the chat:

Issue editing the existing custom code snippets
Toolset Support Bot : Hi, before assigning your chat to Waqar, please describe in details, what is happening - note that there are buttons below that can help you add debug information, screens and more
simonM-5 : Hi Support

Our Custom Code Snippet sections is giving errors when trying to save items.

If I create a new item, it gets created OK.

I cannot update or delete any items. I get the error message:
\"There was an error when updating snippets.\"

I saw this post
https://toolset.com/forums/topic/cannot-save-custom-code-snippet/ which describes something similar, however the error message is different.

Also checked that the following are not present in the wp-config.php file
define( \'DISALLOW_FILE_EDIT\', true );
define( \'DISALLOW_FILE_MODS\', true );

Also checked that the folder and contents have read and write permissions (see screenshot).

I can workaround this for the moment by moving files back and forth with FTP, but that\'s not ideal and is prone to errors. I would like to get this working again from the GUI.

Also, if I create a new snippet, eg test.php and then delete it via the FTP server, it is no longer visible in the GUI, but if I then try to re-create test.php in the GUI, it is somehow remembering that I had such a file before - where is this information being stored in the database?

Thanks and regards
Simon
Waqar : Hi,

Thank you for contacting us and I\'d be happy to assist.

I\'m currently reviewing your question for more details. Please wait
Waqar : Thank you for waiting.

Have you checked the server\'s error logs to see if any other error or warning is logged related to this?
Waqar : As for the database storage, Toolset stores the information about these code snippets in a serialized format in the options table under the name \"toolset_code_snippet_options\".
Waqar : Are you with me Simon?
simonM-5 : Yes, I was looking in the wp_options table
Waqar : I\'ll recommend making a backup of your existing custom code snippets and then delete existing files and the \"toolset_code_snippet_options\" record from the options table.

In case the issue still persists, you check the server\'s error logs for any error or warning and also test the clone/snapshot of this website on a different server.

If the custom snippet feature works properly on a different server, then you\'ll need to consult your hosting support team to see if there is any security measure in placed, which can stop the editing of PHP files.

simonM-5 : OK, but if I replace the files on the server, will the record in the database be updated correctly then?
Waqar : Yes, when there will be no \"toolset_code_snippet_options\" record in the options table it will be re-created when you\'ll create a new file through the GUI.

An important part is that no existing snippet file should be left in the \"wp-content/toolset-customizations\" folder.
simonM-5 : OK, my question is - if I manually add files to the folder, is the database record updated? Or are updates only registered there when created via the GUI.

I want to avoid having to create all snippets again via the GUI if I can just drop the files into the newly created toolset_customisations folder
Waqar : No, I\'m afraid, the database record will be updated only when the files will be added/edited through the GUI.
simonM-5 : One further question - does deleting a snippet via the GUI update the record to remove the existing (used) slug?
simonM-5 : OK, just so I\'ve understood correctly, you\'re suggesting I cut and paste all the snippets again cleanly via the GUI to have everything registered correctly after backup and deletion?

Waqar : > One further question - does deleting a snippet via the GUI update the record to remove the existing (used) slug?
- yes when the snippet will be deleted through the GUI, it will update the record in the database and the same slug would be available to be recreated too.
Waqar : > OK, just so I\'ve understood correctly, you\'re suggesting I cut and paste all the snippets again cleanly via the GUI to have everything registered correctly after backup and deletion?

That is correct because the data is saved in a serialized form, it is possible that some conflict has arisen due to manual direct manual changes.

You\'re also welcome to check the server\'s error logs first.

simonM-5 : OK, I understand, thanks. We had a virus recently and I replaced the folder after backup, so that\'s probably where all this started. I\'ll cut and paste all the snippets again and see how things go
Waqar : You\'re very welcome and feel free to reach us anytime - we\'re here to help!

The state of this thread is:
Resolved

#1806319

On Waqar's advice,
1) I backed up all code snippets
2) Removed the folder toolset-customizations from the server
3) deleted FROM `wp_options` where option_name = 'toolset_code_snippet_options'
4) recreated all snippet names in the GUI
-- a new toolset-customizations folder was created on the server
-- the record in the database contains all the correct names

Still cannot update or delete from the front end, so updated their content via the FTP Server.

However it is not possible to activate any of the snippets. I'm getting the same error "There was an error when updating snippets."

Due to the Custom Code Snippets feature not working correctly, many of the major functions of our site are not working.

Thanks and regards
Simon

#1806723

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

Sorry to learn that the issue still persists.

Did you find anything in the server's error logs?

You're also welcome to share a clone/snapshot of the website so that I can troubleshoot this on a different server.
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

Note: I've set your next reply as private.

regards,
Waqar

#1807033

Hi Waqar

I just did the same test on test.native-nanny.com and hidden link using Toolset Blocks plugin only. (The sites aren't live yet).

The same issue is happening on test.native-nanny.com but it works fine on hidden link.

I don't know if that helps us but just thought I'd point it out.

Kind regards
Simon

#1808591

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

Thank you for sharing the admin access.

During troubleshooting, I noticed that when a code snippet is saved through the custom code GUI, a long 403 forbidden message is shown in the browser's console, which is basically the HTML code of the warning page from the Wordfence plugin.
( screenshot: hidden link )

The Wordfence plugin is incorrectly blocking the AJAX call from Toolset that is used to update the code snippet, mixing it with some suspicious/malicious attack.

You can consult Wordfence's official support or documentation to learn about how to allow or whitelist AJAX calls such as these.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1808793

Hi Waqar

Thank you for your insights, I suspected WordFence might be the culprit. I have opened a support request with them. Can we please keep this ticket open until we I get it working? Usually they are pretty fast to answer. You could set it to waiting for my feedback again, so it's not in your queue. 🙂

Thanks and kind regards
Simon

#1809775

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

Thanks for the update and I'm sure Wordfence's support will be able to help you out with this.

This ticket will stay open for the next couple of weeks.

regards,
Waqar

#1819007

Hi Waqar

the ticket seems to have been marked as resolved by the robot, however the support at my host provider has not been able to help me yet. Can you please re-open this ticket and prevent it from auto-closing until I can see the code snippets working again in the front end?

I am trying to reach my host support again this afternoon. I deeply appreciate your patience here.

Kind regards
Simon

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.