Jump to content

Topic on Extension talk:TemplateStyles

Class 'Wikimedia\CSS\Parser\Parser' not found

53
Summary last edited by Willy1018 14:18, 2 November 2022 2 years ago

How to do

  1. Creat composer.json in TemplateStyles Folder.
  2. Run composer install --no-dev in the extension directory (TemplateStyles Folder).
Magol (talkcontribs)

When I try to save a css file, I get following error:

[2a9066e3ada1b0687cfa9e27] /w/index.php?title=Mall:Blank_head_empty/styles.css&action=submit Error from line 76 of /var/www/html/extensions/TemplateStyles/includes/TemplateStylesContent.php: Class 'Wikimedia\CSS\Parser\Parser' not found

Backtrace:
#0 /var/www/html/extensions/TemplateStyles/includes/TemplateStylesContent.php(131): TemplateStylesContent->sanitize(array)
#1 /var/www/html/includes/page/WikiPage.php(2129): TemplateStylesContent->getParserOutput(Title, NULL, ParserOptions)
#2 /var/www/html/extensions/TemplateData/includes/TemplateDataHooks.php(90): WikiPage->prepareContentForEdit(TemplateStylesContent, NULL, User, string)
#3 /var/www/html/includes/Hooks.php(177): TemplateDataHooks::onPageContentSave(WikiPage, User, TemplateStylesContent, string, integer, NULL, NULL, integer, Status)
#4 /var/www/html/includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
#5 /var/www/html/includes/page/WikiPage.php(1618): Hooks::run(string, array)
#6 /var/www/html/includes/EditPage.php(2214): WikiPage->doEditContent(TemplateStylesContent, string, integer, boolean, User, string, array, integer)
#7 /var/www/html/includes/EditPage.php(1506): EditPage->internalAttemptSave(array, boolean)
#8 /var/www/html/includes/EditPage.php(652): EditPage->attemptSave(array)
#9 /var/www/html/includes/actions/EditAction.php(60): EditPage->edit()
#10 /var/www/html/includes/actions/SubmitAction.php(38): EditAction->show()
#11 /var/www/html/includes/MediaWiki.php(500): SubmitAction->show()
#12 /var/www/html/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#13 /var/www/html/includes/MediaWiki.php(861): MediaWiki->performRequest()
#14 /var/www/html/includes/MediaWiki.php(524): MediaWiki->main()
#15 /var/www/html/index.php(42): MediaWiki->run()
#16 {main}
Anomie (talkcontribs)
Tofiq Kərimli (talkcontribs)
Magol (talkcontribs)

Thanks, I didn't see that information as it was written AFTER the YesY Done step

Mchje (talkcontribs)

I get the same error as described above when trying to upload Templates to a new server with 1.32.0. I only encounter the problem with 1.32.0 (on Windows or Linux Ubuntu), while it works without a problem 1.31.1. Is there any solution to the problem?

216.165.95.192 (talkcontribs)

I am also having the same issue. Same exact Class 'Wikimedia\CSS\Parser\Parser' not found. Have been struggling all night to find a fix. According to the TemplateStyles#Installation, the code "composer update --no-dev" should only be necessary if downloaded from git, which I did not. Any help would be greatly appreciated.


91.211.57.172 (talkcontribs)

bump

Can't import infoboxes because of this error.

Klipik12 (talkcontribs)

I have the same problem, but I can't Anomie's fix because I didn't download the extension (or any of the installation) through Git.

ArchonBoi (talkcontribs)

I have the same problem too. I downloaded the extension from MW and uploaded it to the server directly. I also don't have access to the server's console to run any commands.

Anomie (talkcontribs)
81.83.3.119 (talkcontribs)

I had this exact problem. I installed version 1.31 instead of 1.32 of the TemplateStyles extension to fix it. It seems like the folder structure of the 1.31 changed drastically, the whole vendor folder is not present. As is reflected in the filesize being only 49kB instead of 274kB.

86.28.232.96 (talkcontribs)

Thank you. I had exactly the same problem, your solution worked for me.

Squirkiz (talkcontribs)

Yep, for anyone wondering, it worked for me too. Thanks !

Extarys (talkcontribs)

Is there a way to bypass the check until this is resolved? I just installed 1.32.1 as I had some issues with 1.31. I'm the sole editor/owner of my wiki hosted on a local network so security isn't quite an issue. (It's mainly tech stuff and game strats for me and my friends)

Tofiq Kərimli (talkcontribs)
Peacedev (talkcontribs)

You can run composer update --no-dev in the command line (terminal) by first going to the extension folder which in this case is like {path}/{to}/{public_html}/extensions/TemplateStyles

Tofiq Kərimli (talkcontribs)

@Peacedev thank you for your attention.

{path}/{to}/{public_html}/extensions/TemplateStyles - Here is these: i18n; includes; tests. CODE_OF_CONDUCT.md; composer.json; COPYING; extension.json; Gruntfile.js; hooks.txt; package.json.

Which of these files do I need to change? Or should I upload a new file here?

Thanks in advance.

Tofiq Kərimli (talkcontribs)

@Peacedev {path}/{to}/{public_html}/extensions/TemplateStyles - should I place a file named "composer update" here?

Tofiq Kərimli (talkcontribs)

{path}/{to}/{public_html}/extensions/TemplateStyles/composer.json - Should I change this? Should I write "no-dev" instead of "require-dev"?

130.226.169.2 (talkcontribs)
130.226.169.2 (talkcontribs)

Make sure you have PHP dependancy manager composer istalled from your Linux distro. Run

composer require wikimedia/css-sanitizer

in the base mediawiki directory.

203.220.52.22 (talkcontribs)

thanks for that. this was the issue for me. should be detailed on the css-sanitizer plugin page

Terrawide (talkcontribs)

All of the below information and sources were researched and found on 8.30.2019.  I mention it because if you're looking at this several years later, things might have changed.  Also, I'm using CentOS 7.6, so if you're using a different distribution you'll probably need to locate the specific files elsewhere (PS, I only tested this solution on CentOS).  This also assumes you've got the TemplateStyles Extension set up per directions here: https://www.mediawiki.org/wiki/Extension:TemplateStyles and working, except for the issue noted here. (Check the Special Pages / Version Page on your Wiki for the TemplateStyles Extension)

The below fix is for people like me that do the installation manually instead of using Composer (I've gotten burned several times using Composer, so I prefer to do things manually.  Nothing against the nice people that created, support, etc. Composer, as it is very probably my own fault when using Composer.)

Anyway, as mentioned by a previous user if you download the TemplateStyles Extension for MediaWiki 1.32 or 1.33 the TAR file you get will not include a directory named vendor (This directory contains a bunch of classes, dependencies, etc.).  That's a bad thing, because it is the source of the error discussed on this page. Later versions also seem to move several PHP files from the root directory to the include directory (but that doesn't affect this issue or solution, just noting it).


Solution:

Download (see below for URL) the TemplateStyles Extension for Mediawiki 1.31 (It's the last one I found to contain the vendor directory)

Copy the vendor directory in the TAR file (not the other directories or files) into your WhatEverPathOnYourComputer/extensions/TemplateStyles directory (this is assuming you've installed / copied version 1.32 or 1.33 already of the TemplateStyles Extension to this location)

All of the extensions are available here: https://extdist.wmflabs.org/dist/extensions/

The TemplateStyles Extension 1.31 file is here: https://extdist.wmflabs.org/dist/extensions/TemplateStyles-REL1_31-814b63c.tar.gz

And for good measure, make sure permissions and ownership are set correctly

chown -R apache:apache PathAnd-OrDirectoryName

find PathAnd-OrDirectoryName -type d -exec chmod 755 {} \;

find PathAnd-OrDirectoryName -type f -exec chmod 644 {} \;

PathAnd-OrDirectoryName for me is /var/www/html/MyWIKI/extensions/TemplateStyles, so adjust for your installation.


My best guess as to the reason this issue exists is the nice person(s) that created the TemplateStyles Extension use composer and might have forgotten about us people that do things manually and relied on Composer to install dependencies like the vendors directory and did not include it in the TAR file.  Maybe it can be included in later versions if someone can suggest it to the person(s) that make / made and support the TemplateStyles Extension.

Hopefully this helps some people fix the problem in less than the 4 hours it took me to figure this thing out.

And remember in newer versions of Mediawiki, when importing templates (or other stuff), the "Interwiki prefix" is a country code.  IE, if you're using an English based version of Mediawiki, use en for the "Interwiki prefix".

85.233.76.85 (talkcontribs)

Thank you!!!!

SheldonBole (talkcontribs)

I have downloaded all the different versions of TemplateStyles from the server you shared.


However, none of them have a Vendor directory in them.


Very sad not to be able to get this to work!

SheldonBole (talkcontribs)
85.233.76.85 (talkcontribs)

Thank you!!!!!!

Tofiq Kərimli (talkcontribs)

I had to change the server. Now I'm working in this direction. I chose the best server. I downloaded the latest version. But I still can't create "styles.css" files: 1

But they were active on my previous site:  2

Please look at it and tell me my mistake.


Tofiq Kərimli (talkcontribs)

I solved the problem. I changed "TemplateStyles" in the "extensions" folder. I put the files of the old site here. Everything is in order.

Tofiq Kərimli (talkcontribs)

I moved my site to a new server. PuTTY didn't work on this server either. My future plans have been in vain. I will never have "Wikibase" or "Wikidata". TemplateStile will never be updated. I'm so sorry.

46.46.137.114 (talkcontribs)

I have the same problem. I can't create a CSS file. there is no vendor directory at the address above in the TestLanguageNameGrammar-REL 1_31-990de97 TAR file. please tell me where I can find the TemplateStyles folder with the vendor directory. I can't run composer, I also don't have access to the server console to run any commands.

Please help me solve this problem

46.46.137.114 (talkcontribs)

Can someone share the vendor catalog with me

Tofiq Kərimli (talkcontribs)
Luceatx (talkcontribs)

Hi @Tofiq Kərimli, looks like the document is no longer there. Is it possible to upload the directory to somewhere public, or just send it to my email pc15@tuta.io?

Greatly appreciated, thanks in advance

Tofiq Kərimli (talkcontribs)

I haven't been on Wikipedia in a long time. That's why I didn't see your request. If you have not yet received this file, I can send it to you. Should I send it?

Tofiq Kərimli (talkcontribs)
46.46.137.114 (talkcontribs)

Thanks for the link. But I can't download the files.

All downloaded files are empty. I tried downloading from different browsers.Maybe I'm not doing it right.

46.46.137.114 (talkcontribs)

Maybe I don't have access

Tofiq Kərimli (talkcontribs)

Give me your email and I'll send it to you.

Letzte Übermensch (talkcontribs)

i have same problem and Done all of the steps but nothing changed. can i ask you send the files for me?

my address mfmfallah@gmail.com

Tofiq Kərimli (talkcontribs)

Ok. I've sent.

46.46.137.114 (talkcontribs)

thank you for your help, my address moodspook@hotmail.com

Tofiq Kərimli (talkcontribs)

I've sent.

47.26.201.202 (talkcontribs)

@Tofiq Kərimli Can I please also have them sent to me? skinnypunkzine@yahoo.com

Thank you!!

Tofiq Kərimli (talkcontribs)

I haven't been on Wikipedia in a long time. That's why I didn't see your request. If you have not yet received this file, I can send it to you. Should I send it?

46.46.137.114 (talkcontribs)

Thank you very much, it works!

BeardyJP (talkcontribs)

I'm trying to set up TemplateStyles on a host that I don't have SSH access to. Any suggestions as to how I can get round this issue? This is really disappointing, as I've set up Wikis using earlier versions of MediaWiki without any problems at all.

AhmadF.Cheema (talkcontribs)

The only ways I can think of is to get someone like @Tofiq Kərimli to share the /vendor directory with you, or set-up a local development environment, run composer install --no-dev there and then upload the /vendor directory to your host.

BeardyJP (talkcontribs)

Many thanks, Ahmad. Maybe that's what I'll have to do.

AhmadF.Cheema (talkcontribs)
Luceatx (talkcontribs)

@AhmadF.Cheema I tried, (I wrote that question) but it's not working. Setting up a local environment also did not work for me (I downloaded a PHP Shell but found I miss some root access, if that's what you mean by a local environment).

BeardyJP (talkcontribs)

Well, all I can say is that it worked for me (so thanks, Ahmad!). I unpacked the tar into a location on my Mac, ran the composer command as specified, compressed the resulting vendor directory, uploaded that and extracted it into the right place on my server and suddenly everything's working.

Reply to "Class 'Wikimedia\CSS\Parser\Parser' not found"