Made some changes to a my Mindbody Schedule API plugin WordPress as well as our site’s theme yesterday which worked nicely on the dev server, and expected a short transfer to the live server this morning.
Spent a few hours today trying to figure out why the bootstrap modal pop-up in the plugin suddenly stopped working, intermittently!
Intermittent problems are fun (not!?) to troubleshoot because first you have to figure out when they happen.
- First thing I did was try a previous version of the code, thinking maybe I had broken something in the last upgrade. Same problem.
- I had also made some changes to the (child) theme, so tried switching to a few other different themes.
- The problem was occurring on the public server, but not on the dev server, which should have clued me in to the source of the issue.
- I noticed that the problem did not occur when simply using the MBO test account (-99), no matter which theme was in place.
- So maybe there’s something in the specific text being returned from our MBO account. Perhaps an orphaned DIV tag or something.
- I checked the HTML of the page against the W3 HTML validator (and fixed a bunch of unrelated issues).
- Also ran the url through the W3 CSS validator (and decided to ignore most of the many many warnings and issues contained in some of the popular libraries I’m using).
- Added the PHP strip_tags() function to the return value to remove any stray or malformed HTML that might be contained in the class descriptions. Still no luck.
- Finally checked the “schedule” for s different day and saw that the problem was gone. This definitely had to do with content in a specific class.
- Have you guessed yet?
- Maybe they’re too long. I checked the calendar of another site which I know uses the plugin and it had even longer descriptions. That can’t be it.
- Pull out the offending href tags for a closer look in a text editor.
- Will they pull up as single browser pages? No. Will “good” ones? Yes.
- Take pieces of the “bad” url – I’m looking for content that might break the pop-ups – and try them in the browser. First half works. Second half works. Is it because there are too many hyphens in the text?
- Try appending the long url/description that works on the other website at the end of our domain name. Doesn’t work!
- It’s a length issue. Hit up web search for something like “url cut short” or max-length php url”
- Turns out that when the suhosin package is being invoked with php, each $_GET value is limited to something like 527 characters – and these two exceeded it.
So I added the line
suhosin.get.max_name_length = 5024 to the php.ini file – actually copied the php.ini file to the public_html directory with that line added, and added a line to the
.htaccess file so that all of the directories below public_html would pull from the same php.ini file. The line is
SetEnv PHPRC /path_to/public_html/php.ini.
And it’s working again!