HTTP 500 in local_mobile webservice

HTTP 500 in local_mobile webservice

by Oscar Martínez -
Number of replies: 3

Hi,

when we access in the Moodle Mobile app any function given by the local_mobile webservice we get in the app an "error conecting to the server" and in de Apache server an HTTP 500 "internal server error" like this:

10.180.197.166 - - [17/Jan/2018:12:42:16 +0100] "POST 
/centros/zonapobra/aulavirtual2/webservice/rest/server.php?moodlewsrestformat=json 
HTTP/1.1" 500 - "-" "Mozilla/5.0 (Linux; Android 5.0.2; LG-D405 
Build/LRX22G.A1454843669; wv) AppleWebKit/537.36 (KHTML, like Gecko) 
Version/4.0 Chrome/63.0.3239.111 Mobile Safari/537.36 MoodleMobile"

The functions by de Moodle Mobile core webservice works fine.

We have Moodle 2.6.11+, local_mobile 2.6.312 (2014060329), Apache, PHP 5.3.3 and OPCache.

Is it perhaps about the PHP versión?

Thanks.

Attachment private_files_error.png
Average of ratings: -
In reply to Oscar Martínez

Re: HTTP 500 in local_mobile webservice

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi,

are you sure that you have the correct local_mobile version? This error usually happens when you are using a local_mobile version for a different version (for example, local_mobile for Moodle 2.7 installed in a Moodle 2.6 site)

In reply to Juan Leyva

Re: HTTP 500 in local_mobile webservice

by Oscar Martínez -

Hi,

i think so.

We had installed this way:

# cd local/
# git clone https://github.com/jleyva/moodle-local_mobile mobile
# cd mobile/
# git branch -a
# git checkout -b MOODLE_26_WWDD remotes/origin/MOODLE_26_STABLE

Here are the version.php file:

# cd local/mobile/

# cat version.php

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>;.

/**
 * Version information
 *
 * @package    local_mobile
 * @copyright  2014 Juan Leyva <juan@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die();

$plugin->version   = 2014060329;            // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires  = 2013111800;            // Requires this Moodle version.
$plugin->component = 'local_mobile';        // Full name of the plugin (used for diagnostics).
$plugin->maturity  = MATURITY_STABLE;
$plugin->release   = '2.6.312';


And all files in directory are:

#ls -lR
.:
total 648
-rwxr-xr-x 1 root apache   4326 may 11  2016 checkconfiguration.php
-rwxr-xr-x 1 root apache   2491 may 11  2016 check.php
drwxr-xr-x 2 root apache   4096 mar  2  2017 db
-rwxr-xr-x 1 root apache 469437 mar  2  2017 externallib.php
-rwxr-xr-x 1 root apache 114106 mar  2  2017 futurelib.php
drwxr-xr-x 3 root apache   4096 may 11  2016 lang
-rwxr-xr-x 1 root apache   8672 mar  2  2017 launch.php
-rwxr-xr-x 1 root apache  12855 may 11  2016 locallib.php
-rwxr-xr-x 1 root apache    583 may 11  2016 README.md
-rwxr-xr-x 1 root apache   2503 may 11  2016 server.php
-rwxr-xr-x 1 root apache   2514 mar  2  2017 settings.php
-rwxr-xr-x 1 root apache   1247 mar  2  2017 version.php
drwxr-xr-x 2 root apache   4096 ene 17 10:33 webservice

./db:
total 52
-rwxr-xr-x 1 root apache 41988 mar  2  2017 services.php
-rwxr-xr-x 1 root apache  3441 may 11  2016 upgrade.php

./lang:
total 4
drwxr-xr-x 2 root apache 4096 mar  2  2017 en

./lang/en:
total 4
-rwxr-xr-x 1 root apache 2854 mar  2  2017 local_mobile.php

./webservice:
total 4
-rwxr-xr-x 1 root apache 2335 may 11  2016 pluginfile.php


And the core version.php file:

cat version.php
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>;.

/**
 * MOODLE VERSION INFORMATION
 *
 * This file defines the current version of the core Moodle code being used.
 * This is compared against the values stored in the database to determine
 * whether upgrades should be performed (see lib/db/*.php)
 *
 * @package    core
 * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die();

$version  = 2013111811.01;              // 20131118      = branching date YYYYMMDD - do not modify!
                                        //         RR    = release increments - 00 in DEV branches.
                                        //           .XX = incremental changes.

$release  = '2.6.11+ (Build: 20150619)'; // Human-friendly version name

$branch   = '26';                       // This version's branch.
$maturity = MATURITY_STABLE;             // This version's maturity level.


Any way a will install again!

Thanks.

In reply to Juan Leyva

Re: HTTP 500 in local_mobile webservice

by Oscar Martínez -

Hi,

i have found it!

It is because of de PHP version.

externallib.php uses the abreviated sintax to declare arrays [] that doesn't work in PHP 5.3.3

I have changed those declarations and now it works!

Here are de diff between the original file and the modified one:

7697c7697

<                 $viewablefields = array();

---

>                 $viewablefields = [];

9402,9403c9402,9403

<         $result['someoptions'] = array();

<         $result['alloptions'] = array();

---

>         $result['someoptions'] = [];

>         $result['alloptions'] = [];

9535c9535

<                 $errors = $accessmanager->validate_preflight_check($provideddata, array(), $currentattemptid);

---

>                 $errors = $accessmanager->validate_preflight_check($provideddata, [], $currentattemptid);

9639c9639

<             $errors = $accessmanager->validate_preflight_check($provideddata, array(), $params['attemptid']);

---

>             $errors = $accessmanager->validate_preflight_check($provideddata, [], $params['attemptid']);


Thanks for your help!