Moodle

search gives empty page --> ctype_spacer()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.5, 1.9
  • Fix Version/s: 1.8.6, 1.9.1
  • Component/s: General, Installation, Libraries
  • Labels:
    None
  • Environment:
    Linux
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_15_STABLE, MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

Trying to do a search in forums or on the whole site results in an empty page when using f.i. a word like color.

Using as search string +color all goes well.

Log error message of apache:

Call to undefined function ctype_space() in ../lib/searchlib.php on line 297

Moodle version: 2005052300 1.5dev

Issue Links

Activity

Hide
Martin Dougiamas added a comment -

From Herbert Keijers (herbert.keijers at vanhorne.nl) Saturday, 4 June 2005, 05:32 PM:

Forgot to mention php version 4.1.2

From Herbert Keijers (herbert.keijers at vanhorne.nl) Sunday, 5 June 2005, 05:20 PM:

Some (elder) php4 versions do not support the ctype functions.

So it is not a bug.

See my postings in : http://moodle.org/mod/forum/discuss.php?d=24762

Show
Martin Dougiamas added a comment - From Herbert Keijers (herbert.keijers at vanhorne.nl) Saturday, 4 June 2005, 05:32 PM: Forgot to mention php version 4.1.2 From Herbert Keijers (herbert.keijers at vanhorne.nl) Sunday, 5 June 2005, 05:20 PM: Some (elder) php4 versions do not support the ctype functions. So it is not a bug. See my postings in : http://moodle.org/mod/forum/discuss.php?d=24762
Hide
Martin Dougiamas added a comment -

Assigning to me temporarily because Vy-Shane no longer works for Moodle HQ.

Show
Martin Dougiamas added a comment - Assigning to me temporarily because Vy-Shane no longer works for Moodle HQ.
Hide
Chris Bandy added a comment - - edited

We have the same issue with Moodle 1.6.5+ (2006050550) on PHP 5.1.2, Postgresql 8.1.4, and openSUSE 10.1.

"PHP Fatal error: Call to undefined function ctype_space() in .../moodle/lib/searchlib.php on line 296"

This function requires the ctype extension for PHP:
extension_loaded('ctype');

Show
Chris Bandy added a comment - - edited We have the same issue with Moodle 1.6.5+ (2006050550) on PHP 5.1.2, Postgresql 8.1.4, and openSUSE 10.1. "PHP Fatal error: Call to undefined function ctype_space() in .../moodle/lib/searchlib.php on line 296" This function requires the ctype extension for PHP: extension_loaded('ctype');
Hide
Dirk Weller added a comment -

We have the same issue with Moodle 1.8.2 and 1.8.3 on Mysql 5.0.26 Apache 2.2.0 PHP 5.1.2 Suhosin Patch 0.9.6 and Zend Engine v2.1.0 - SuSE 10.1

Show
Dirk Weller added a comment - We have the same issue with Moodle 1.8.2 and 1.8.3 on Mysql 5.0.26 Apache 2.2.0 PHP 5.1.2 Suhosin Patch 0.9.6 and Zend Engine v2.1.0 - SuSE 10.1
Hide
Dirk Weller added a comment -

Issue closed for SuSE 10.1 / See http://moodle.org/mod/forum/discuss.php?d=80814 --> ctype is an extra php module for SuSE and needs to be installed

Show
Dirk Weller added a comment - Issue closed for SuSE 10.1 / See http://moodle.org/mod/forum/discuss.php?d=80814 --> ctype is an extra php module for SuSE and needs to be installed
Hide
Chris Bandy added a comment - - edited

As of Moodle 1.8.3, ctype functions are still used in:

course/lib.php
lib/adodb/adodb-datadict.inc.php
lib/searchlib.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php
search/Zend/Search/Lucene/Search/QueryTokenizer.php

The ctype module is optional[1] in PHP, and other distributions (Gentoo for one) optionally include it.
The resolution to this this long-standing bug is to add ctype as a PHP requirement in environment.xml

Please vote for this issue.

[1] http://www.php.net/manual/en/ref.ctype.php#ctype.installation

Show
Chris Bandy added a comment - - edited As of Moodle 1.8.3, ctype functions are still used in: course/lib.php lib/adodb/adodb-datadict.inc.php lib/searchlib.php search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php search/Zend/Search/Lucene/Search/QueryTokenizer.php The ctype module is optional[1] in PHP, and other distributions (Gentoo for one) optionally include it. The resolution to this this long-standing bug is to add ctype as a PHP requirement in environment.xml Please vote for this issue. [1] http://www.php.net/manual/en/ref.ctype.php#ctype.installation
Hide
Mathieu Petit-Clair added a comment -

This problem (ctype_space in searchlib) will still exists in Moodle 1.9, and there's another call (ctype_alpha in course/lib.php) that will be a problem for people without ctype.

Possibilities :

  • make ctype an official requirement for Moodle;
  • change the ctype_space() call to a trim() (seems to be equivalent) and include a "western-equivalent" function to ctype_alpha (see http://au.php.net/manual/en/function.ctype-alpha.php#75854 for the code, which is probably a problem for scripts not using western characters);
  • find a way to do without ctype functions.
Show
Mathieu Petit-Clair added a comment - This problem (ctype_space in searchlib) will still exists in Moodle 1.9, and there's another call (ctype_alpha in course/lib.php) that will be a problem for people without ctype. Possibilities :
  • make ctype an official requirement for Moodle;
  • change the ctype_space() call to a trim() (seems to be equivalent) and include a "western-equivalent" function to ctype_alpha (see http://au.php.net/manual/en/function.ctype-alpha.php#75854 for the code, which is probably a problem for scripts not using western characters);
  • find a way to do without ctype functions.
Hide
Mathieu Petit-Clair added a comment -

Here's a start of a patch.. This needs to be changed depending on whether ctype is required for moodle or not.

Show
Mathieu Petit-Clair added a comment - Here's a start of a patch.. This needs to be changed depending on whether ctype is required for moodle or not.
Hide
Eloy Lafuente (stronk7) added a comment -

Hi, just saw this. Two comments:

1) course.lib use looks really trivial, It's being used to check if the fist letter is alpha (and the list of log actions are simple english words). Can be matched with regexp instead.
2) searchlib.php use of ctype_space can be also safely replaced by one simple trim() === ''

With this... all Moodle 1.9 would be ctype_* free (unless you enable HTMLPurifier or Global search). Perhaps it could be added as OPTIONAL.

For 2.0 we must REQUIRE ctype IMO, mainly because HTMLPurifier has high probabilities to become the standard filter and we cannot patch it locally.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi, just saw this. Two comments: 1) course.lib use looks really trivial, It's being used to check if the fist letter is alpha (and the list of log actions are simple english words). Can be matched with regexp instead. 2) searchlib.php use of ctype_space can be also safely replaced by one simple trim() === '' With this... all Moodle 1.9 would be ctype_* free (unless you enable HTMLPurifier or Global search). Perhaps it could be added as OPTIONAL. For 2.0 we must REQUIRE ctype IMO, mainly because HTMLPurifier has high probabilities to become the standard filter and we cannot patch it locally. Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Raising this to critical. Should be fixed ASAP IMO. Assigning to Mathieu.

Show
Eloy Lafuente (stronk7) added a comment - Raising this to critical. Should be fixed ASAP IMO. Assigning to Mathieu.
Hide
Mathieu Petit-Clair added a comment -

Adding Martín Langhoff to this issue, since he's to author of the code in course/lib.php. Martín : is it necessary to use ctype_alpha on line 120? Can $modaction contain non-latin characters?

Show
Mathieu Petit-Clair added a comment - Adding Martín Langhoff to this issue, since he's to author of the code in course/lib.php. Martín : is it necessary to use ctype_alpha on line 120? Can $modaction contain non-latin characters?
Hide
Mathieu Petit-Clair added a comment -

I modified the call in searchlib.php.

Eloy, should I commit the patch (attached to this issue) to 1.9? If we require ctype for 2.0, I will modify the patch for this requirement in head.

Show
Mathieu Petit-Clair added a comment - I modified the call in searchlib.php. Eloy, should I commit the patch (attached to this issue) to 1.9? If we require ctype for 2.0, I will modify the patch for this requirement in head.
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Mathieu,

I think your patch about doing ctype optional in 1.9 is ok. So +1 for that, with 3 comments:

1) It should be applied from 17_STABLE to HEAD (that way people running older Moodle versions will know about that recommendation, without downloading xml).
2) If you add new strings that are going to be showed by the installer... you need to add them to all those branches too (en_utf8) and, important, add them to install/stringnames.txt . That way, nightly package generators are able to put them in the proper installer lang files.
3) Perhaps I'd delay this until next HQ chat to see if definitively we are going to make ctype mandatory for 2.0. To send the whole solution in the same commit.

About your $modaction question for ML... I think I was looking for that when I wrote my previous comment here and I think all I saw were English tokens. So I really think it could be safe to change it. In fact, hehe, exactly in the previous line of the ctype_alpha() call, there is one $firstletter = substr($modaction, 0, 1); and that breaks UTF-8 (non-ascii) strings, so yes, I guess it only can contain english (ascii) letters.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Mathieu, I think your patch about doing ctype optional in 1.9 is ok. So +1 for that, with 3 comments: 1) It should be applied from 17_STABLE to HEAD (that way people running older Moodle versions will know about that recommendation, without downloading xml). 2) If you add new strings that are going to be showed by the installer... you need to add them to all those branches too (en_utf8) and, important, add them to install/stringnames.txt . That way, nightly package generators are able to put them in the proper installer lang files. 3) Perhaps I'd delay this until next HQ chat to see if definitively we are going to make ctype mandatory for 2.0. To send the whole solution in the same commit. About your $modaction question for ML... I think I was looking for that when I wrote my previous comment here and I think all I saw were English tokens. So I really think it could be safe to change it. In fact, hehe, exactly in the previous line of the ctype_alpha() call, there is one $firstletter = substr($modaction, 0, 1); and that breaks UTF-8 (non-ascii) strings, so yes, I guess it only can contain english (ascii) letters. Ciao
Hide
Martin Dougiamas added a comment -

My +1 for optional in 1.9 and required in 2.0.

Show
Martin Dougiamas added a comment - My +1 for optional in 1.9 and required in 2.0.
Hide
Mathieu Petit-Clair added a comment -

Ok, as discussed in meeting : ctype recommended until 1.9, required from 2.0. Patches coming in the next few days.

Show
Mathieu Petit-Clair added a comment - Ok, as discussed in meeting : ctype recommended until 1.9, required from 2.0. Patches coming in the next few days.
Hide
Mathieu Petit-Clair added a comment -

I just had a look on php.net and ctype is enabled by default since php 4.2.0, and builtin since php 4.3.0. Anybody having this problem is on a seriously old host. I'm committing this patch, since I'm done .. but really, this shouldn't be a problem anymore (Moodle won't even run on a php that old!). See (as said above) http://au.php.net/manual/en/ctype.installation.php for details.

Show
Mathieu Petit-Clair added a comment - I just had a look on php.net and ctype is enabled by default since php 4.2.0, and builtin since php 4.3.0. Anybody having this problem is on a seriously old host. I'm committing this patch, since I'm done .. but really, this shouldn't be a problem anymore (Moodle won't even run on a php that old!). See (as said above) http://au.php.net/manual/en/ctype.installation.php for details.
Hide
Mathieu Petit-Clair added a comment -

Fixed in MOODLE_19_STABLE, merged in HEAD. Should the ctype_* removals be backported?

Show
Mathieu Petit-Clair added a comment - Fixed in MOODLE_19_STABLE, merged in HEAD. Should the ctype_* removals be backported?
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Mathieu,

I really think patches are ok. Anyway, I'd backport them to 1.8 as they are trivial and can make life better for some sites.

FYC... with MD. feel free to close this definitively once backported (or not backported).

Only one small comment... install/lang/xxx file must not be edited by us at all. All we need to do it to add them to the install/stringnames.txt file and then one nightly process will build automatically the install/lang/xxx files.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Mathieu, I really think patches are ok. Anyway, I'd backport them to 1.8 as they are trivial and can make life better for some sites. FYC... with MD. feel free to close this definitively once backported (or not backported). Only one small comment... install/lang/xxx file must not be edited by us at all. All we need to do it to add them to the install/stringnames.txt file and then one nightly process will build automatically the install/lang/xxx files. Ciao
Hide
Mathieu Petit-Clair added a comment -

Backported to 1.8. Eloy: it's not clear to me if /admin/environment.xml must be the same over all versions, but I did make the same changes in 1.8, 1.9 and head. Should this file be the same in 16 and 1.7?

Show
Mathieu Petit-Clair added a comment - Backported to 1.8. Eloy: it's not clear to me if /admin/environment.xml must be the same over all versions, but I did make the same changes in 1.8, 1.9 and head. Should this file be the same in 16 and 1.7?
Hide
Eloy Lafuente (stronk7) added a comment -

Well, really it shouldn't be necessary as long as the xml file can be updated online from download.moodle.org.

I really think in this case it's enough to backport up to 1.8, because when the ctype is going to be a requirement is 2.0, and 2.0 requires 1.9 to be installed so everybody will have that info.

So, I think this is ok as is now. Thanks!

Show
Eloy Lafuente (stronk7) added a comment - Well, really it shouldn't be necessary as long as the xml file can be updated online from download.moodle.org. I really think in this case it's enough to backport up to 1.8, because when the ctype is going to be a requirement is 2.0, and 2.0 requires 1.9 to be installed so everybody will have that info. So, I think this is ok as is now. Thanks!

Dates

  • Created:
    Updated:
    Resolved: