Pages in Plesk return Internal error: Failed to parse metadata, File aps_php.php

Started by mahesh, Mar 12, 2024, 06:54 AM

Previous topic - Next topic

mahesh

Symptoms
  • The Plesk > Domains page cannot be opened due to the following error:

Internal error: Failed to parse metadata

Message Failed to parse metadata
File aps_php.php
Line 12559
Type Exception


  • The same error appears in an attempt to create/remove a customer/subscription.
  • APS package settings cannot be checked:
/usr/local/psa/bin/aps --get-packages-global-settings

Failed to parse metadata

#/usr/local/psa/bin/aps --get-packages-global-settings
PHP Warning : aps_registry_packageconfiguration_getglobalsettings(): Entity: line 7: parser error : Char 0x0 out of allowed range; File: /usr/share/aps_php/aps_php.php, Line: 10024
PHP Warning : aps_registry_packageconfiguration_getglobalsettings(): ; File: /usr/share/aps_php/aps_php.php, Line: 10024
...
Failed to parse metadata

  • It is not possible to install an application.
  • Unable to clear cache at Tools & Settings > Application Vault > Clear Cache on Plesk:
Internal error: Cannot find package cache directory: '/usr/local/psa/var/apspackages/apscatalog7R2ZJ5.zipb17fa7a9-c64e-c0'
Message Cannot find package cache directory: '/usr/local/psa/var/apspackages/apscatalog7R2ZJ5.zipb17fa7a9-c64e-c0'
File Content.php
Line 73
Type CommonPanel_Aps_Cache_Exception


  • When creating a server backup, the following error message appears in the backup task sumary:
Warning: server "server"
Unable to get Global settings for APS Applications (ErrorCode: 3, STDOUT:).
  • The /opt/psa/var/apspackages or /usr/local/psa/var/apspackages was accidentally cleared.
Cause
The metafile_uri directory (from the apsc.aps_package table) is missing on the server or the APP-META.xml file is corrupted.

Resolution
If the apspackages folder was accidentally cleared, the best way is restoring it from the full server backup.

If it does not contain all applications, follow steps below as well as for other cases.

For Windows
1.Connect to the server via RDP.

2.Download the script restore-cache.ps1.

3.-click on it and select Run in Powershell.
For Linux
1.Connect to the server via SSH.

2.Download the script:

#wget https://github.com/plesk/kb-scripts/raw/0ead0b7853b2e795d0918709f990ba73f7f51a9d/restore-aps-cache/restore-cache.sh
3.Make it executable:

#chmod +x restore-cache.sh
4.Run the script:

#./restore-cache.sh
If the issue persists after 10 minutes, do the following:

1.Clear the Apps cache: Tools & Settings > Application Vault > Clear Cache

2.Create the reported directory if unable to clear cache and retry:

#mkdir /usr/local/psa/var/apspackages/apscatalog7R2ZJ5.zipb17fa7a9-c64e-c0
# chown -R psaadm:psaadm /usr/local/psa/var/apspackages/apscatalog7R2ZJ5.zipb17fa7a9-c64e-c0

3.Make sure that SQL query debug is disabled in config file /usr/local/psa/admin/conf/panel.ini.

The script does not work with enabled debug.

4.Login to the MySQL server:

#MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin apsc
5.Determine metafile_uri path by using the following sql query:

mysql> select `id`, `name`, `version`, `release`, `metafile_uri` from apsc.aps_package;
+-----+-----------+---------+---------+----------------------------------------------------------------------------------+
| id | name | version | release | metafile_uri |
+-----+-----------+---------+---------+----------------------------------------------------------------------------------+
| 66 | WordPress | 2.3.3 | 5 | /usr/local/psa/var/apspackages/556229a0-5008-41b5-83d1-3c0b32649196/APP-META.xml |
| 77 | WordPress | 3.3.1 | 4 | /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a/APP-META.xml |
| 106 | WordPress | 3.5.2 | 2 | /usr/local/psa/var/apspackages/c22666c4-b469-4eb2-a0e7-7c6f3f4f11eb/APP-META.xml |
+-----+-----------+---------+---------+----------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

6.Make sure that the metafile_uri directories exist on the server.

Directories should exist as below:

#ls -la /usr/local/psa/var/apspackages/c22666c4-b469-4eb2-a0e7-7c6f3f4f11eb/APP-META.xml
-rw-r--r-- 1 psaadm psaadm 50828 Mar 12 21:23 /usr/local/psa/var/apspackages/c22666c4-b469-4eb2-a0e7-7c6f3f4f11eb/APP-META.xml

# ls -la /usr/local/psa/var/apspackages/556229a0-5008-41b5-83d1-3c0b32649196/APP-META.xml
-rw-r--r-- 1 psaadm psaadm 21506 Mar 12 21:23 /usr/local/psa/var/apspackages/556229a0-5008-41b5-83d1-3c0b32649196/APP-META.xml

# ls -la /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a/APP-META.xml
-rw-r--r-- 1 psaadm psaadm 21706 Mar 12 21:23 /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a/APP-META.xml

7.Make sure that all the APP-META.xml files are readable:

#head /usr/local/psa/var/apspackages/a1a41e6f-f5ae-4f80-8e30-788a0a418196/APP-META.xml

<application packaged="2014-12-19T14:05:21" version="1.2" xmlns="http://apstandard.com/ns/1">
<id>http://wordpress.org/</id>
<name>WordPress</name>
<version>4.1</version>
<release>74</release>
<homepage>http://wordpress.org/</homepage>

<vendor>
<name>WordPress.org</name>
<homepage>http://wordpress.org/</homepage>

If it is not readable or binary, remove and recreate the package folder as listed below.

1.If the metafile_uri directory is missing, create it:

#mkdir /usr/local/psa/var/apspackages/c22666c4-b469-4eb2-a0e7-7c6f3f4f11eb
# mkdir /usr/local/psa/var/apspackages/556229a0-5008-41b5-83d1-3c0b32649196
# mkdir /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a
2.Download APS packages with the corresponding name and version from dev.apsstandard.org to the directories created in the previous step. If your WordPress version is not present on the above mentioned page, visit apscatalog.com .

Upon downloading via browser nginx 403 Forbidden error can occur. In that case copy generated link to the archive from the browser and download it using wget tool, e.g.:

#wget https://apscatalog.com/storage/wordpress.org/WordPress/2.7.1-2/parallels.com/undefined/undefined/undefined/WordPress-2.7.1-2.app.zip
3.Extract the zip file in the same directory, for example:

#ls -la /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a/

drwxr-xr-x 5 psaadm psaadm 4096 Jan 17 2013 ./
drwxr-xr-x 15 psaadm psaadm 4096 Sep 5 04:34 ../
-rw-r--r-- 1 psaadm psaadm 13434 Jan 17 2013 APP-META.xml
drwxr-xr-x 2 psaadm psaadm 4096 Jan 17 2013 htdocs/
drwxr-xr-x 2 psaadm psaadm 4096 Jan 17 2013 images/
drwxr-xr-x 2 psaadm psaadm 4096 Jan 17 2013 scripts/

4.Change permissions to psaadm:psaadm on the package folder recursively:

#chown -R psaadm:psaadm /usr/local/psa/var/apspackages/2abd12d2-7017-46ee-a80b-ed42599f7c0a/