In working on a good solution for #2184517: Fatal error: Call to undefined function strptime() I discovered that we were not validating the letters used in the scheduler date format. When using date_popup the extra letters were working fine and the dates were returned. But switching back to text entry suddenly corrupted the scheduled nodes, ie when editing the node the format being used was not accepted in _scheduler_strptime() and the date had to be re-entered. I also noticed that the date letters being used in scheduler_admin_submit() were not the same as the letters shown in the help description.
To remedy this I have created two new constants
// The full set of date and time letters allowed in the scheduler date format.
define('SCHEDULER_DATE_LETTERS', 'djmnyY');
define('SCHEDULER_TIME_LETTERS', 'hHgGisaA');
These are now used in the help text and for validation in scheduler_admin_validate(). I have also reorganised _scheduler_strptime() so that it is easier to see what its doing. In a later patch I will add new letters (the ones that were accepted by date-popup) but this patch simply makes all the letter lists consistent and checks that we do not allow any additional lettters which are not catered for in _scheduler_strptime()
Comment | File | Size | Author |
---|---|---|---|
#5 | 2187361_interdiff.txt | 2.37 KB | jonathan1055 |
#3 | 2187361_3.validate_formatting_letters.patch | 7.07 KB | jonathan1055 |
Comments
Comment #1
jonathan1055 CreditAttribution: jonathan1055 commentedPatch for testing and comment.
Comment #2
pfrenssenThis looks good, the comments add more detail, and the code is much cleaner and easier to read. I only found a couple of coding standards violations.
Use single quotes instead of double quotes.
Start these comments with a capital letter and end them in a period. I would personally prefer using // instead of /* */ but that is not strictly against coding standards, so if you prefer to keep it this way then that's fine.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 commentedWell spotted with the double quotes. Yes I prefer the // but somehow I forgot that they could be used within an array (probably due to my programming in a different language from php in my day job). New patch attached. I also changed another double quotes to single quotes in that function.
When this patch is ok, could you mark as RTBC but not commit, then I can practice at making a commit to Scheduler. Thanks
Comment #4
jonathan1055 CreditAttribution: jonathan1055 commentedForgot to set status
Comment #5
jonathan1055 CreditAttribution: jonathan1055 commentedHere's the interdiff to show clearly the previous minor changes. The patch in #3 still applies cleanly.
Jonathan
Comment #6
pfrenssenLooks good! I have not retested the latest patch, but it contains only comment changes and a double quote to single quote conversion, so it will work equally well as the last one.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 commentedThanks Pieter. Committed.
I made the array $date_entities_and_replacements even clearer by moving the lines so that they are grouped into date elements and time elements, in the same order as in the two new constants.