Friday, 18 April 2014

How to send a developer USEFUL information - Debugging Strictly AutoTags

How to send a developer USEFUL information - Debugging Strictly AutoTags

By Strictly-Software

I understand that a lot of people who use CMS systems like Joomla or Word Press don't know how to code other wise they would be using proper code they had written. However as most people don't know how to code and install plugins expecting them to everything they want plus more and free support as well they need to realise that
a) A developers time is not spent just working for free on open source projects
b) A donation for time spent fixing a problem that is only apparent to the user in question would be nice at the very least.
c) A developer cannot fix a problem  on a server across the world without
   -Access to it (logins, FTP, SSH, Database etc)
   -Information about the poblem

If the developer cannot replicate the problem then how on earth are they supposed to be able to fix it for you?

Therefore the first thing you should do if you have a problem with 3rd party code is check to see if other people have the same PROBLEM and the same SOLUTION.

It may be you are asking a common rookie mistake that many previous people have done before and all you need to do is find out from those people what they did to fix it.

However if a search of Google, BING, Techie Forums like stackoverflow.com and others does not reveal an answer then you should go through a step by step guide to narrow down the problem before contacting the developer in question. Believe it or not they do have lives and don't live to fix other peoples bugs.

Below I have reproduced one I give out to my WordPress plugin users for one of my own popular plugins Strictly AutoTags, therefore some of the steps are relevant just to that plugin.

However in general the steps are useful for ALL plugins or problems and should be read by all WordPress users. 

It should ALWAYS be followed before even thinking of emailing me and if I do find a problem and fix it for you then some kind of appreciation would be nice e.g a donation would not go a miss.

Steps to narrowing down your problem with a WordPress plugin


1. If you add a post but no tags are added then it does not mean the plugin is not working just that no tags could be found to associate with the post.

2. Test the plugin is working by creating a new post with the following content and saving it as a draft (this is relevant to Strictly AutoTags and may not be needed with your own problem) :

Article Title:
The CIA now admits responsibility for torture at Guantanamo Bay
Content Body:
Today the CIA admitted it was responsible for the recent accusations of torture at Guantanamo Bay.
Billy Bob Johnson, the chief station manager at the Guantanamo Bay prison said that the USA had to hold its hands up and admit that it had allowed its CIA operatives to feed the prisoners nothing but McDonalds and Kentucky Fried Chicken meals whilst forcing them to listen to Christian Rock Music for up to 20 hour periods at a time without any break.
The CIA apologised for the allegations and promised to review its policy of using fast food and Christian Rock Music as a method of torture.

3. Save the draft post and check the number of tags that get added. The plugin should have found a number of words to use even if you have no existing saved tags in your site. It is always best to save the article as a draft, check which tags have been used, remove or add any yourself before publishing an article.

4. Some people have complained that they have added words to the stop/noise word list which still get tagged and think the plugin is broken. This is not the case and the problem is usually that the user hasn't removed any new noise words from the system first BEFORE re-scanning. The noise words are only used in the auto discovery stage of the auto tagging and if tags have already been saved in the system then the site will use them in it's relevancy check whether or not they have been marked as noise words. Version 2.0 has a new option to aid the easy removal of noise words from the saved post tag list and this option should be run whenever new noise words are added.

5. If you have articles with lots of capital words in the title e.g THIS IS A TEST ARTICLE or body then set the Ignore Capital Percentage to a level appropriate for your site. Otherwise words will be treated as acronyms when they shouldn't.

6. If you don't want the plugin to hunt out possible new tags for your site then turn Auto Discovery OFF. Then only existing saved post tags will be used to find relevant tags in new articles.

7. Auto Discovery will find new possible words to use as tags using the settings you give it so set them carefully. However if these new words are not found to be relevant to your article they won't get saved against the post OR in the system. Use the Rank Title and Rank HTML options to ensure words in the post title or already in special formatting HTML such as headers or strong tags are considered more relevant than other words.

8. If you have any problems make sure it not related to Wordpress, your server/hosting or other plugins before requesting support.

9. Please check existing support tickets before writing a new support ticket as the problem may have already been answered.

10. Always disable all other plugins and leave just Strictly AutoTags on before considering it the likely cause of a problem.

11. If you are going to write a new support question that hasn't already been answered can you please provided the following information all which can be got from your host, WP, plugins, DB or a combination of  all.

12. Download the wp-config.php file from your server, edit it and turn the constant WP_DEBUG to TRUE and re-upload e.g

define('WP_DEBUG', false);

define('WP_DEBUG', true);

It will mean your visitors see a lot text all over the screen but it will also help you find any critical errors.

Notices and Warnings do not matter as much. But if you see anything Critical or Erroring - take note to supply the developer with.

If nothing is notable return it to FALSE ASAP!

For example load a version of phpinfo.php onto your server but call it something else so hackers cannot guess it e.g my-3467phpINF.php this way you can see what your server has installed but they can't!

It is very important you tell the developer all of the following information so they know what they are working with.


  1. Version of PHP (or other language) you are running (make sure it's compatible with the code)
  2. Version of MySQL (or other database system) you are running (make sure it's compatible with the code)
  3. Any error message you get when you run the routine that breaks.
  4. The time it takes to run before breaking.
  5. If you can hit F12 and view the console any Nework/JavaScript errors you may have - also if you have lots of 404's due to missing files fix those as that will cause overhead. If you don't have them just create blank file with the same name.
  6. If you can code, turn on the debug constant in the plugin, change your IP in the MyIP function to your own IP address (just type "What is my IP" into Google to get a value, re-upload the file (after backing up) and send me the output of the debug.
  7. If you have lots of browser add-ons try it in a fresh install of a new browser, e.g download Opera/Safari for windows and test it on that.
  8. If possible install HTTP Fox on FireFox, open it, and then press play just before doing the action that causes the problem. This will give you all the HTTP requests and responses from the server. Look for any 500 status codes or errors. Send me anything unusual - and only related to my site/plugin as it will also record all the plugin guff from your FireFox extensions as well.
  9. The more information the better, so screeen shots, video casts (free online, click play, do action, stop, send link etc).and step by step guides of what YOU did to reproduce the problem will help.
  10. How many articles are on your site?
  11. Is it a big or small site?
  12. Do you get hacked a lot?
  13. What were the last errors in your hosts error_log (available through VMIN and SSH e.g PUTTY using a less command on the error log)

So although there is more you can do this should be the first things you do when you notice an issue with your code.

Please remember developers are NOT mind readers. So sending in emails or messages like

"When I do X nothing happens"

of

"When I hit the send button it breaks"

Are more than useless.

Please help a developer have a break! And thank them with more than words if they do spend all day and night helping you!

Thanks

Wednesday, 16 April 2014

Please Don't Upgade to Wordpress 3.9!

Please Don't Upgade to Wordpress 3.9!

I have just been sent this email by WordPress telling me of the changes they are making.

As some of these changes have not been made in my plugins and you DO upgrade to WordPress 3.9 and any of my plugins break e.g

Strictly AutoTags
Strictly TweetBot
Strictly Google Sitemap (no longer supported)
Strictly Content Cleaner
Strictly System Check

Then you WILL HAVE problems due to code they are now using not being in the plugins.

I wanted a quite Easter Weekend not one spend coding!

So if you do get problems by upgrading it's your own fault for not following my blog!

Thursday, 20 February 2014

Quickly Generate A Random Number Between 1 and 9

Quickly Generate A Random Number Between 1 and 9

By Strictly-Software

As you should know by now the RAND() function in SQL has the downside that it will return the same value if the same seed is provided to it.

E.G if I call this code multiple times I get the same number for each result:

SELECT RAND(1) AS [RandomNumber]

This always returns 0.713591993212924 for me.

Therefore when people use RAND() they often end up coming up with various ways to generate a unique seed value as well.

One of the quickest ways I have found to return a random number is by using the NEWID() function which generates a random GUID.

If I wanted to return a random record from a recordset I would use the NEWID() function in my ORDER BY statement. 

I use this a lot in my Jobboard code when I want to return a random banner from a banner group like so:


SELECT TOP 1 BannerPK, BannerURL, RedirectURL
FROM   BANNERS
ORDER BY NEWID()


However if I wanted to return a single number between 1 and 9 I could use the following code.

This basically converts the GUID to a VARBINARY value before converting it to a VARCHAR and then taking off the the first character with a LEFT statement.

I have found that this gives a larger proportion of 1's than any other number but it is useful if you want a quick way in SQL to generate a single number (or more if you extend the numbers returned with a string function) e.g LEFT(val,2) or use a MID or RIGHT. Then this code could do the trick.


DECLARE @RANDNO INT
SELECT @RANDOMNO = CAST(LEFT(CAST(ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT)) AS VARCHAR),1) AS INT)