{"id":4948,"date":"2021-01-02T07:40:04","date_gmt":"2021-01-02T06:40:04","guid":{"rendered":"https:\/\/diocesanos.es\/blogs\/equipotic\/?p=4948"},"modified":"2021-01-02T07:47:57","modified_gmt":"2021-01-02T06:47:57","slug":"actualizado-moodle-a-v3-10-en-servidor-de-1and1-ionos","status":"publish","type":"post","link":"https:\/\/diocesanos.es\/blogs\/equipotic\/2021\/01\/02\/actualizado-moodle-a-v3-10-en-servidor-de-1and1-ionos\/","title":{"rendered":"Actualizado moodle a v3.10 en servidor de 1and1\/ionos"},"content":{"rendered":"\n<p>Ya tocaba. Realizo la pertinente copia de seguridad, cambio la versi\u00f3n de MySQL, convierto las tablas de UTF8 a utf8mb4 para que puedan contener \u00abemojis\u00bb, habilito en el servidor la versi\u00f3n recomendada de PHP (7.4) que de las otras ya no hay soporte, ejecuto el script de actualizaci\u00f3n y cruzo los dedos (lo de aguantar la respiraci\u00f3n, paso, que le lleva 10min&#8230;) TODO OK!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/update-1672346_640.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"400\" src=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/update-1672346_640.png\" alt=\"\" class=\"wp-image-4949\" srcset=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/update-1672346_640.png 600w, https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/update-1672346_640-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure>\n\n\n\n<p>Hasta que descubres que las im\u00e1genes de resumen de los cursos , las fotos de tus repositorios de preguntas y alg\u00fan que otro elemento ahora ya no se muestra. Vale. Que no cunda el p\u00e1nico&#8230;..<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Veamos:<\/p>\n<ol>\n<li>Revisando permisos en la carpeta de archivos&#8230;.. todo OK.<\/li>\n<li>Revisando los registros en la base de datos, comparando los \u00abhash\u00bb y localizando el documento original&#8230;.Pues s\u00ed, est\u00e1n ah\u00ed.<\/li>\n<li>Cambiando de \u00abtema\u00bb visual&#8230;.. Nada, sigue igual.<\/li>\n<li>\u00bfProblema al migrar las tablas? \u00bfSe ha producido alguna actualizaci\u00f3n de las URLs? No deber\u00eda. Veamos el c\u00f3digo HTML del objeto que no se muestra&#8230;.<\/li>\n<\/ol>\n<pre>https:\/\/diocesanos.es\/moodle\/pluginfile.php\/13019\/course\/overviewfiles\/tic.jpg<\/pre>\n<p>&#8230; y con la versi\u00f3n anterior era algo as\u00ed como:<\/p>\n<pre>https:\/\/diocesanos.es\/moodle\/pluginfile.php<strong>?file=<\/strong>\/13019\/course\/overviewfiles\/tic.jpg<\/pre>\n<p><strong>YA ESTA!<\/strong> Al realizar la actualizaci\u00f3n se ha abilitado por defecto la opci\u00f3n \u00abslasharguments\u00bb. Vamos a la configuraci\u00f3n del servidor de moodle y&#8230;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/Captura-de-pantalla-de-2021-01-02-06-24-39.png\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"207\" src=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/Captura-de-pantalla-de-2021-01-02-06-24-39.png\" alt=\"\" class=\"wp-image-4950\" srcset=\"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/Captura-de-pantalla-de-2021-01-02-06-24-39.png 993w, https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/Captura-de-pantalla-de-2021-01-02-06-24-39-300x63.png 300w, https:\/\/diocesanos.es\/blogs\/equipotic\/wp-content\/uploads\/sites\/2\/2021\/01\/Captura-de-pantalla-de-2021-01-02-06-24-39-768x160.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/a><\/figure>\n\n\n\n<p>O ser\u00e1 la rev\u00e9s. Qu\u00e9 pasar\u00e1 si la activo&#8230;. <strong>DESASTRE<\/strong>! Adi\u00f3s a los estilos CSS y a todas las im\u00e1genes (por lo menos).<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%; border-style: solid; border-color: #ff0303; background-color: #fcc0c0;\"><em><strong>NOTA<\/strong>: el servidor linux de 1and1 \/ Ionos\u00a0 <strong>NO soporta<\/strong> el uso de \u00abslasharguments\u00bb de ninguna forma (al menos por ahora), y no puede habilitarse mediante archivos \u00ab.htaccess\u00bb<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>No existe opci\u00f3n, par\u00e1metro o ajuste en la configuraci\u00f3n de Moodle, del servidor (las que me dejan tocar) o del sistema de archivos que muestre como antes (v3.5)\u00a0 las im\u00e1genes que \u00abhan desaparecido\u00bb (y las he probado todas).<\/p>\n<p>\u00abGoogleando\u00bb un poco descubro que el problema comienza precisamente al actualizar la versi\u00f3n 3.5 en adelante, y se da principalmente en instalaciones con 1and1&#8230;..pero nadie da una soluci\u00f3n satisfactoria&#8230;hasta que llego a un <strong><a href=\"https:\/\/tracker.moodle.org\/browse\/MDL-28538\">post [MDL-28538]<\/a> <\/strong>que hace referencia a un \u00aberror\u00bb y propuesta de correcci\u00f3n sobre el uso de la variable \u00abPATH_INFO\u00bb del servidor&#8230; o eso intenta porque dicha variable nunca llega a definirse!<\/p>\n<h2>El fichero \u00abweblib.php\u00bb<\/h2>\n<p>Moodle tiene una \u00ablibrer\u00eda\u00bb de funciones para ayudar generar los contenidos web en \u00ab<strong>moodle\/lib\/weblib.php<\/strong>\u00ab, y entre otras muchas \u00fatiles proporciona la funci\u00f3n \u00ab<strong>get_file_argument()<\/strong>\u00bb a partir de la l\u00ednea 1116:\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * Extracts file argument either from file parameter or <strong>PATH_INFO<\/strong>\n *\n * Note: $scriptname parameter is not needed anymore\n *\n * @return string file path (only safe characters)\n *\/\nfunction get_file_argument() {\n    global $SCRIPT;\n\n    $relativepath = false;\n    $hasforcedslashargs = false;\n\n    if (isset($_SERVER&#91;'REQUEST_URI']) &amp;&amp; !empty($_SERVER&#91;'REQUEST_URI'])) {\n        \/\/ Checks whether $_SERVER&#91;'REQUEST_URI'] contains '\/pluginfile.php\/'\n        \/\/ instead of '\/pluginfile.php?', when serving a file from e.g. mod_imscp or mod_scorm.\n        if ((strpos($_SERVER&#91;'REQUEST_URI'], '\/pluginfile.php\/') !== false)\n                &amp;&amp; isset($_SERVER&#91;'<strong>PATH_INFO<\/strong>']) &amp;&amp; !empty($_SERVER&#91;'<strong>PATH_INFO<\/strong>'])) {\n            \/\/ Exclude edge cases like '\/pluginfile.php\/?file='.\n            $args = explode('\/', ltrim($_SERVER&#91;'<strong>PATH_INFO<\/strong>'], '\/'));\n            $hasforcedslashargs = (count($args) &gt; 2); \/\/ Always at least: context, component and filearea.\n        }\n    }\n    if (!$hasforcedslashargs) {\n        $relativepath = optional_param('file', false, PARAM_PATH);\n    }\n\n    if ($relativepath !== false and $relativepath !== '') {\n        return $relativepath;\n    }\n    $relativepath = false;\n\n    \/\/ Then try extract file from the slasharguments.\n    if (stripos($_SERVER&#91;'SERVER_SOFTWARE'], 'iis') !== false) {\n        \/\/ NOTE: IIS tends to convert all file paths to single byte DOS encoding,\n        \/\/       we can not use other methods because they break unicode chars,\n        \/\/       the only ways are to use URL rewriting\n        \/\/       OR\n        \/\/       to properly set the 'FastCGIUtf8ServerVariables' registry key.\n        if (isset($_SERVER&#91;'<strong>PATH_INFO<\/strong>']) and $_SERVER&#91;'<strong>PATH_INFO<\/strong>'] !== '') {\n            \/\/ Check that PATH_INFO works == must not contain the script name.\n            if (strpos($_SERVER&#91;'<strong>PATH_INFO<\/strong>'], $SCRIPT) === false) {\n                $relativepath = clean_param(urldecode($_SERVER&#91;'<strong>PATH_INFO<\/strong>']), PARAM_PATH);\n            }\n        }\n    } else {\n        \/\/ All other apache-like servers depend on PATH_INFO.\n        if (isset($_SERVER&#91;'<strong>PATH_INFO<\/strong>'])) {\n            if (isset($_SERVER&#91;'SCRIPT_NAME']) and strpos($_SERVER&#91;'<strong>PATH_INFO<\/strong>'], $_SERVER&#91;'SCRIPT_NAME']) === 0) {\n                $relativepath = substr($_SERVER&#91;'<strong>PATH_INFO<\/strong>'], strlen($_SERVER&#91;'SCRIPT_NAME']));\n            } else {\n                $relativepath = $_SERVER&#91;'<strong>PATH_INFO<\/strong>'];\n            }\n            $relativepath = clean_param($relativepath, PARAM_PATH);\n        }\n    }\n\n    return $relativepath;\n}\n<\/code><\/pre>\n\n\n\n<p>Si insert\u00e1semos la l\u00ednea<\/p>\n<pre id=\"yui_3_17_2_1_1609560187540_43\"> <span id=\"yui_3_17_2_1_1609560187540_46\">echo var_export($_SERVER, true);<\/span><\/pre>\n<p>al inicio de la misma y recarg\u00e1semos la URL de la imagen que echamos en falta en moodle obtendr\u00edamos (en un servidor de 1and1) algo similar a esto:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array (\n 'REDIRECT_UNIQUE_ID' =&gt; 'X-xxxxxxxxxxx', \n 'REDIRECT_DOCUMENT_ROOT' =&gt; '\/kunden\/homepages\/x\/xxxxx\/x\/xxxxx\/htdocs', \n 'REDIRECT_HTTPS' =&gt; 'on', \n 'REDIRECT_HANDLER' =&gt; 'x-mapp-php5.4',\n 'REDIRECT_STATUS' =&gt; '200', \n 'UNIQUE_ID' =&gt; 'X-xxxxxxxxxxx', \n 'HTTPS' =&gt; 'on', \n 'HTTP_HOST' =&gt; 'diocesanos.es', \n 'HTTP_USER_AGENT' =&gt; 'Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko\/20100101 Firefox\/84.0', \n 'HTTP_ACCEPT' =&gt; 'text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8', \n 'HTTP_ACCEPT_LANGUAGE' =&gt; 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3', \n 'HTTP_ACCEPT_ENCODING' =&gt; 'gzip, deflate, br', \n 'HTTP_UPGRADE_INSECURE_REQUESTS' =&gt; '1', \n 'HTTP_CACHE_CONTROL' =&gt; 'max-age=0', \n 'HTTP_COOKIE' =&gt; 'xxxxxxxxxxx', \n 'PATH' =&gt; '\/bin:\/usr\/bin', \n 'SERVER_SIGNATURE' =&gt; '', \n 'SERVER_SOFTWARE' =&gt; 'Apache', \n 'SERVER_NAME' =&gt; 'diocesanos.es', \n 'SERVER_ADDR' =&gt; '11.22.33.44', \n 'SERVER_PORT' =&gt; '443', \n 'REMOTE_ADDR' =&gt; '55.66.77.88', \n 'DOCUMENT_ROOT' =&gt; '\/kunden\/homepages\/x\/xxxxx\/x\/xxxxx\/htdocs', \n 'REQUEST_SCHEME' =&gt; 'https', \n 'CONTEXT_PREFIX' =&gt; '\/system-bin\/', \n 'CONTEXT_DOCUMENT_ROOT' =&gt; '\/kunden\/usr\/lib\/cgi-bin\/', \n 'SERVER_ADMIN' =&gt; 'webmaster@diocesanos.es', \n 'SCRIPT_FILENAME' =&gt; '\/kunden\/homepages\/x\/xxxxx\/x\/xxxxx\/htdocs\/moodle\/pluginfile.php', \n 'REMOTE_PORT' =&gt; '25220', \n 'REDIRECT_URL' =&gt; '\/moodle\/pluginfile.php\/93019\/course\/overviewfiles\/tic.jpg', \n 'GATEWAY_INTERFACE' =&gt; 'CGI\/1.1', \n 'SERVER_PROTOCOL' =&gt; 'HTTP\/1.1', \n 'REQUEST_METHOD' =&gt; 'GET', \n 'QUERY_STRING' =&gt; '', \n 'REQUEST_URI' =&gt; '\/moodle\/pluginfile.php\/93019\/course\/overviewfiles\/tic.jpg', \n 'SCRIPT_NAME' =&gt; '\/moodle\/pluginfile.php', \n 'STATUS' =&gt; '200', \n '<strong>ORIG_PATH_INFO<\/strong>' =&gt; '\/93019\/course\/overviewfiles\/tic.jpg', \n 'ORIG_PATH_TRANSLATED' =&gt; '\/kunden\/homepages\/x\/xxxxx\/x\/xxxxx\/htdocs\/moodle\/pluginfile.php', \n 'PHP_SELF' =&gt; '\/moodle\/pluginfile.php', \n 'REQUEST_TIME_FLOAT' =&gt; 1609568156.633002, 'REQUEST_TIME' =&gt; 1609568156, 'argv' =&gt; array ( ), 'argc' =&gt; 0,\n ) <\/code><\/pre>\n\n\n\n<p>&#8230; y por ning\u00fan lado aparece la variable \u00ab<strong>PATH_INFO<\/strong>\u00ab, sino \u00ab<strong>ORIG_PATH_INFO<\/strong>\u00ab.<\/p>\n<h2>Soluci\u00f3n<\/h2>\n<p>Hagamos algunos cambios a la funci\u00f3n:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * Extracts file argument either from file parameter or PATH_INFO\n *\n * Note: $scriptname parameter is not needed anymore\n *\n * @return string file path (only safe characters)\n *\/\nfunction get_file_argument() {\n    global $SCRIPT;\n\n    $relativepath = false;\n    $hasforcedslashargs = false;\n    <strong>$pathinfo = '';\n\n    if (isset($_SERVER&#91;'PATH_INFO'])) {\n        $pathinfo = $_SERVER&#91;'PATH_INFO'];\n    } else if (isset($_SERVER&#91;'ORIG_PATH_INFO'])) {\n        $pathinfo = $_SERVER&#91;'ORIG_PATH_INFO'];\n    }<\/strong>\n\n    if (isset($_SERVER&#91;'REQUEST_URI']) &amp;&amp; !empty($_SERVER&#91;'REQUEST_URI'])) {\n        \/\/ Checks whether $_SERVER&#91;'REQUEST_URI'] contains '\/pluginfile.php\/'\n        \/\/ instead of '\/pluginfile.php?', when serving a file from e.g. mod_imscp or mod_scorm.\n        if ((strpos($_SERVER&#91;'REQUEST_URI'], '\/pluginfile.php\/') !== false)\n              <strong>  &amp;&amp; !empty($pathinfo)) {<\/strong>\n            \/\/ Exclude edge cases like '\/pluginfile.php\/?file='.\n            <strong>$args = explode('\/', ltrim($pathinfo, '\/'));<\/strong>\n            $hasforcedslashargs = (count($args) &gt; 2); \/\/ Always at least: context, component and filearea.\n        }\n    }\n    if (!$hasforcedslashargs) {\n        $relativepath = optional_param('file', false, PARAM_PATH);\n    }\n\n    if ($relativepath !== false and $relativepath !== '') {\n        return $relativepath;\n    }\n    $relativepath = false;\n\n    \/\/ Then try extract file from the slasharguments.\n    if (stripos($_SERVER&#91;'SERVER_SOFTWARE'], 'iis') !== false) {\n        \/\/ NOTE: IIS tends to convert all file paths to single byte DOS encoding,\n        \/\/       we can not use other methods because they break unicode chars,\n        \/\/       the only ways are to use URL rewriting\n        \/\/       OR\n        \/\/       to properly set the 'FastCGIUtf8ServerVariables' registry key.\n        <strong>if ($pathinfo !== '') {\n<\/strong>            \/\/ Check that PATH_INFO works == must not contain the script name.<strong>\n            if (strpos($pathinfo, $SCRIPT) === false) {\n                $relativepath = clean_param(urldecode($pathinfo), PARAM_PATH);<\/strong>\n            }\n        }\n    } else {\n        \/\/ All other apache-like servers depend on PATH_INFO.\n        <strong>if ($pathinfo !== '') {\n            if (isset($_SERVER&#91;'SCRIPT_NAME']) and strpos($pathinfo, $_SERVER&#91;'SCRIPT_NAME']) === 0) {\n                $relativepath = substr($pathinfo, strlen($_SERVER&#91;'SCRIPT_NAME']));\n<\/strong>            } else {<strong>\n                $relativepath = $pathinfo;\n<\/strong>            }\n            $relativepath = clean_param($relativepath, PARAM_PATH);\n        }\n    }\n\n    return $relativepath;\n}<\/code><\/pre>\n\n\n\n<p>&#8230; sustituimos el archivo \u00abweblib.php\u00bb por el modificado y <strong>EUREKA<\/strong>! Todo vuelve a mostrarse como deber\u00eda haberlo hecho a la primera.<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"border-style: solid; border-color: #ff0000; background-color: #ffb8b8;\"><em><strong>IMPORTANTE<\/strong>: este cambio debemos realizarlo con cada nueva actualizaci\u00f3n, a no ser que ya incorporen la correci\u00f3n desde el archivo \u00abweblib.php\u00bb original.<br><\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Ya tocaba. Realizo la pertinente copia de seguridad, cambio la versi\u00f3n de MySQL, convierto las tablas de UTF8 a utf8mb4 para que puedan contener \u00abemojis\u00bb, habilito en el servidor la versi\u00f3n recomendada de PHP (7.4) que de las otras ya no hay soporte, ejecuto el script de actualizaci\u00f3n y cruzo los dedos (lo de aguantar &hellip; <a href=\"https:\/\/diocesanos.es\/blogs\/equipotic\/2021\/01\/02\/actualizado-moodle-a-v3-10-en-servidor-de-1and1-ionos\/\" class=\"more-link\">Seguir leyendo <span class=\"screen-reader-text\">Actualizado moodle a v3.10 en servidor de 1and1\/ionos<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":292,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[75,279],"class_list":["post-4948","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-moodle","tag-php"],"_links":{"self":[{"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/posts\/4948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/users\/292"}],"replies":[{"embeddable":true,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/comments?post=4948"}],"version-history":[{"count":4,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/posts\/4948\/revisions"}],"predecessor-version":[{"id":4955,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/posts\/4948\/revisions\/4955"}],"wp:attachment":[{"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/media?parent=4948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/categories?post=4948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diocesanos.es\/blogs\/equipotic\/wp-json\/wp\/v2\/tags?post=4948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}