From/To Date Validation not working for VIEWS

Bug #722470 reported by Anthony Ramos
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Mahara
Expired
High
Unassigned

Bug Description

Mahara: 1.3.3
SunOS java 5.11
PHP 5.2.6
MySQL
Chrome 9.0.597.102, Mozilla 3.6.13, Safari 5.0.3

When you go to EDIT ACCESS for a particular View and add any of the following:
- Public
- Logged In Users
- Friends
- Secret URL
- A particular individual

AND include a FROM and TO Date where the FROM date IS before the TO Date and the TO Date is in the future, you receive an error message: "The stop date cannot be in the past" which is clearly not correct.

Changed in mahara:
status: New → Triaged
importance: Undecided → High
milestone: none → 1.4.0
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

I'm unable to reproduce this behaviour with Mahara 1.3.5 on either Postgres or MySQL.

Anthony, does this problem still occur on your installation?

Can you also reproduce it on demo.mahara.org? If not, it may be to do with your OS or php version I suppose. We've had problems with the strptime function on some OSes in the past.

Changed in mahara:
status: Triaged → Incomplete
Revision history for this message
Melissa Draper (melissa) wrote :

bug 633632 appears a duplicate of this. May well be fixed in 1.4

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

If it is due to buggy strptime, we could possibly increase php dependencies from 5.2.0 to 5.3.0 and use date_parse_from_format instead, or have a wrapper that uses that if possible and strptime if not. Reasoning behind this possible change is below.

Internally, this function calls the strptime() function provided by the system's C library. This function can exhibit noticeably different behaviour across different operating systems. The use of date_parse_from_format(), which does not suffer from these issues, is recommended on PHP 5.3.0 and later.

Changed in mahara:
assignee: nobody → Hugh Davenport (hugh-catalyst)
Revision history for this message
Anthony Ramos (planetjupiter08) wrote : Re: [Bug 722470] Re: From/To Date Validation not working for VIEWS

Hi Hugh and Richard,

My apologies Richard - I did get an email from you back on the 31st of
March asking if the bug persists and it does.

I posted bug 722470 along with bug 422475 (they both relate to the TO
and FROM date problem).

I can confirm that we use PHP version 5.2.6. I'd be reluctant to
upgrade this to 5.3 simply because we also run quite a significant
installation of Moodle and I am not sure what side effects might come
about. Are you able to provide any feedback on this?

I have tested it on demo.mahara.org and it does seem to work there so
you may well have hit the nail on the head about the cause of the
problem.

However, bug 722475 is still a problem on demo.mahara.org. I'll reply
to that bug shortly using the link specifically for that bug.

Thanks,

Anthony

On 10/05/2011, at 8:12 AM, Hugh Davenport wrote:

> If it is due to buggy strptime, we could possibly increase php
> dependencies from 5.2.0 to 5.3.0 and use date_parse_from_format
> instead,
> or have a wrapper that uses that if possible and strptime if not.
> Reasoning behind this possible change is below.
>
> Internally, this function calls the strptime() function provided by
> the
> system's C library. This function can exhibit noticeably different
> behaviour across different operating systems. The use of
> date_parse_from_format(), which does not suffer from these issues, is
> recommended on PHP 5.3.0 and later.
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/722470
>
> Title:
> From/To Date Validation not working for VIEWS
>
> Status in Mahara ePortfolio:
> Incomplete
>
> Bug description:
> Mahara: 1.3.3
> SunOS java 5.11
> PHP 5.2.6
> MySQL
> Chrome 9.0.597.102, Mozilla 3.6.13, Safari 5.0.3
>
> When you go to EDIT ACCESS for a particular View and add any of the
> following:
> - Public
> - Logged In Users
> - Friends
> - Secret URL
> - A particular individual
>
> AND include a FROM and TO Date where the FROM date IS before the TO
> Date and the TO Date is in the future, you receive an error message:
> "The stop date cannot be in the past" which is clearly not correct.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/mahara/+bug/722470/+subscribe

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

From bug #722475:

- Bug 722470 is a result of our version of PHP. To fix this we will need to go to PHP 5.3 as there is no other fix. Is that correct?

Anthony, I don't think we're 100% sure about the cause of the problem. Hugh's saying that it's likely due to your OS having a different strptime implementation to the one we're used to.

Simply moving to PHP 5.3 won't help, because the code on that page is still using the strptime function. So one way to fix the problem would be to make PHP 5.3 a requirement for Mahara, and then rewrite the page to use date_parse_from_format() instead of strptime().

Another way to fix it on PHP 5.2 (hinted at in bug #564001) would be to modify your code to use the workaround strptime function that's included in view/access.php (it's included there for Windows users who don't have strptime at all).

Revision history for this message
Anthony Ramos (planetjupiter08) wrote :

Hi Richard,

Your final suggestion for changing the code to get it working on PHP5.2 will work well for us.

Just to make sure I don't do the wrong thing, can you send me a link with the specific code changes that need to be made please and the file name I need to make them to?

Thanks very much - I appreciate the assistance,

Anthony

On 16/05/2011, at 7:39 AM, Richard Mansfield wrote:

>> From bug #722475:
>
> - Bug 722470 is a result of our version of PHP. To fix this we will need
> to go to PHP 5.3 as there is no other fix. Is that correct?
>
> Anthony, I don't think we're 100% sure about the cause of the problem.
> Hugh's saying that it's likely due to your OS having a different
> strptime implementation to the one we're used to.
>
> Simply moving to PHP 5.3 won't help, because the code on that page is
> still using the strptime function. So one way to fix the problem would
> be to make PHP 5.3 a requirement for Mahara, and then rewrite the page
> to use date_parse_from_format() instead of strptime().
>
> Another way to fix it on PHP 5.2 (hinted at in bug #564001) would be to
> modify your code to use the workaround strptime function that's included
> in view/access.php (it's included there for Windows users who don't have
> strptime at all).
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/722470
>
> Title:
> From/To Date Validation not working for VIEWS
>
> Status in Mahara ePortfolio:
> Incomplete
>
> Bug description:
> Mahara: 1.3.3
> SunOS java 5.11
> PHP 5.2.6
> MySQL
> Chrome 9.0.597.102, Mozilla 3.6.13, Safari 5.0.3
>
> When you go to EDIT ACCESS for a particular View and add any of the following:
> - Public
> - Logged In Users
> - Friends
> - Secret URL
> - A particular individual
>
> AND include a FROM and TO Date where the FROM date IS before the TO
> Date and the TO Date is in the future, you receive an error message:
> "The stop date cannot be in the past" which is clearly not correct.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/mahara/+bug/722470/+subscribe

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Well, it's all in htdocs/view/access.php. You're on your own here, because I don't have time to try it & test it.

You'll notice there's a strptime function in that file that's defined inside a "if (!function_exists('strptime')) {" block.

That's the one you want to use. But in your case, the function strptime *does* already exist, so the function defined there is not used.

If you were to simply pull that function definition out of the if block, you'd probably get an error saying you can't redefine the function with the name 'strptime'.

So what I'd do is pull the function definition out of the block, but rename it to something else like say 'strptime1', and then go through the rest of the file, and find all the calls to 'strptime', and change them to your new name.

I just did a quick search, and conveniently it seems that's the only file you'll need to change.

Revision history for this message
Anthony Ramos (planetjupiter08) wrote :

Thanks Richard,

I'll have a shot at it and see how it goes.

Antonio

On 16/05/2011, at 9:11 AM, Richard Mansfield wrote:

> Well, it's all in htdocs/view/access.php. You're on your own here,
> because I don't have time to try it & test it.
>
> You'll notice there's a strptime function in that file that's defined
> inside a "if (!function_exists('strptime')) {" block.
>
> That's the one you want to use. But in your case, the function strptime
> *does* already exist, so the function defined there is not used.
>
> If you were to simply pull that function definition out of the if block,
> you'd probably get an error saying you can't redefine the function with
> the name 'strptime'.
>
> So what I'd do is pull the function definition out of the block, but
> rename it to something else like say 'strptime1', and then go through
> the rest of the file, and find all the calls to 'strptime', and change
> them to your new name.
>
> I just did a quick search, and conveniently it seems that's the only
> file you'll need to change.
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/722470
>
> Title:
> From/To Date Validation not working for VIEWS
>
> Status in Mahara ePortfolio:
> Incomplete
>
> Bug description:
> Mahara: 1.3.3
> SunOS java 5.11
> PHP 5.2.6
> MySQL
> Chrome 9.0.597.102, Mozilla 3.6.13, Safari 5.0.3
>
> When you go to EDIT ACCESS for a particular View and add any of the following:
> - Public
> - Logged In Users
> - Friends
> - Secret URL
> - A particular individual
>
> AND include a FROM and TO Date where the FROM date IS before the TO
> Date and the TO Date is in the future, you receive an error message:
> "The stop date cannot be in the past" which is clearly not correct.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/mahara/+bug/722470/+subscribe

Changed in mahara:
assignee: Hugh Davenport (hugh-catalyst) → nobody
Changed in mahara:
milestone: 1.4.0 → none
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Mahara because there has been no activity for 60 days.]

Changed in mahara:
status: Incomplete → Expired
Revision history for this message
Bernard Neary (bneary) wrote :

I'm getting this error in 15.04rc1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.