$theFileType = preg_replace('/^.+\.([^\.]+)$/', '$1', $theDownloadInfo['downloadFile']);$theFileType = substr($theDownloadInfo['downloadFile'], -4);

// $theFileType = preg_replace('/^.+\.([^\.]+)$/', '$1', $theDownloadInfo['downloadFile']);
/* $theFileType = preg_replace('/^.+\.([^\.]+)$/', '$1', $theDownloadInfo['downloadFile']); */
This question has been answered by BobRay. See the first response.
First guess would be a character encoding conflict of one sort or another. Any chance there's a disconnect between your MODX config include and your database character set? I could be way off, but it does kinda sound like a character encoding problem to me.I do not believe so. Both databases were created with the same parameters and the tables in one were created by an import of a .sql file created by exporting the tables of the other (i.e. backed up one database, restored in the other).
That sounds like a typical mod_security issue.Both the "live" website and the "test" website are running on exactly the release of MODX (and the Login extra). My code, with the exception of this problem — preg_replace() in the live site, substr() in the test site — are identical, including resource ids, element names and ids (one database is an import of the other).
I think BobRay is referring to Apache's mod_security. I've had bountiful issues with that sucker in the past.
Think about what is happening:
- One visits a MODX website, using the Manager. However you cut it, once you are in the Manger, there are restricted things the code can do that will be impacted by Apache.
- You enter text into a glorified textarea that is part of a, probably very complex, form. There is probably JavaScript and who knows what else running in your browser on your computer. Again, however it works, it's still text, even if it represents PHP code. "Nobody" but you and MODX (because you are editing a snippet) knows it is PHP code unless the text is being intercepted and parsed.
- At some point you click the SAVE button (or use a keyboard shortcut) and the browser sends the fields to the server (i.e. MODX receives the fields and processes them).
- MODX then updates the MODX database using xPDO as its access mechanism. Unless MODX is parsing or filtering snippets before saving them or an xPDO function is doing so, I fail to see why one little bit of text in snippet breaks the update. I also fail to understand why, if MODX is trashing the update, it is not displaying an error.