Jump to content

Cannot add new language in latest dev. Bug?


Peter
 Share

Recommended Posts

Adding a new language in pw 2.5.14 throws this error:

Error: Call to a member function setIsDefaultLanguage() on boolean (line 144 of /Users/user/Sites/domains/blog/htdocs/wire/modules/LanguageSupport/LanguageSupport.module)

Works in 2.5.3 and 2.5.5

Link to comment
Share on other sites

I don't know how this is triggered but under version 2.5.14 dev does not add related language page IDs to the database.

// ensure all languages are loaded and get instantiated versions of system/default languages
		foreach($languages as $language) {
			if($language->id == $defaultLanguagePageID) {
				$this->defaultLanguagePage = $language; 
			} else if($language->name == 'default') {
				$_default = $language; // backup plan
			}
		}
		
		if(!$this->defaultLanguagePage) {
			if($_default) $this->defaultLanguagePage = $_default;
				else $this->defaultLanguagePage = $languages->getAll()->first();
		}
		$this->defaultLanguagePage->setIsDefaultLanguage();
		$languages->setDefault($this->defaultLanguagePage);
		Wire::setFuel('languages', $languages); 
	/**
	 * Hook before Inputfield::render to set proper default language value
	 *
	 * Only applies to Inputfields that have: useLanguages == true
	 *
	 */
	public function hookInputfieldBeforeRender(HookEvent $event) {

		$inputfield = $event->object; 
		if(!$inputfield->useLanguages) return; 

		$userLanguage = $this->wire('user')->language; 
		if(!$userLanguage) return;
		
	
		// set 'value' attribute to default language values	
		if($userLanguage->id !== $this->defaultLanguagePageID) {
			$t = $inputfield->trackChanges();
			if($t) $inputfield->setTrackChanges(false);
			$inputfield->attr('value', $inputfield->get('value' . $this->defaultLanguagePageID)); 
			if($t) $inputfield->setTrackChanges(true); 
		}
	}

The error-causing part is checking the defaultLanguagePageID which wasn't automatically added to the modules table for the LanguageSupport class, hence a quick hack, which is manually finding page IDs and entering the correct info into the data field of LanguageSupport class, as follows, temporarily solves the issue and your install starts working again, since it was a fatal error affecting whole system this may be a lifesaver.

You'll see something like this:

{"otherLanguagePageIDs":[4220]}

Find page IDs and change it to this:

{"languagesPageID":4181,"defaultLanguagePageID":4182,"otherLanguagePageIDs":[4219],"languageTranslatorPageID":4183}

Trying to add another 3rd language triggers the issue again, changing user default language is harmless.  ^_^

Edit: Trying to delete a language clears whole data field.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I've an SQL error adding a new language (in latest dev).

This is the error

Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.name1020' in 'where clause' (in /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/PageFinder.php line 292)

#0 [internal function]: PageFinder->___find(Object(Selectors), Array)
#1 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#2 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array)
#3 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): Wire->__call('find', Array)
#4 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): PageFinder->find(Object(Selectors), Array)
#5 [internal function]: Pages->___find('path=/admin/set...', Array)
#6 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#7 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array)
#8 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(299): Wire->__call('find', Array)
#9 /Users/and
This error message was shown because you are logged in as a Superuser. Error has been logged.

After this i can not access the admin page anymore.

I've opened an issue to the PW Github page.

Link to comment
Share on other sites

I've an SQL error adding a new language (in latest dev).

This is the error

Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.name1020' in 'where clause' (in /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/PageFinder.php line 292)

#0 [internal function]: PageFinder->___find(Object(Selectors), Array)
#1 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#2 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array)
#3 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): Wire->__call('find', Array)
#4 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): PageFinder->find(Object(Selectors), Array)
#5 [internal function]: Pages->___find('path=/admin/set...', Array)
#6 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#7 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array)
#8 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(299): Wire->__call('find', Array)
#9 /Users/and
This error message was shown because you are logged in as a Superuser. Error has been logged.

After this i can not access the admin page anymore.

I've opened an issue to the PW Github page.

Have a read over here:

https://processwire.com/talk/topic/5286-switching-fields-to-language-fields-produces-fatal-errors/

I also noted a temp fix for you on the Github issue you posted.

Link to comment
Share on other sites

I got this same SQL error (pw-dev 2.5.18, php 2.3.29) as verdeandrea. It occurred when adding a new language.

Used Adrains fix to restore the database and got PW running again. But after that there still are things not OK with the database.

When adding a title to the language it gave the error:

 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'status1247' in 'field list'

Deleted the whole language, installed the latest dev (2.5.21) and changed to php 5.4.34. Added a new language again but got exactly the same error as posted by verdeandrea.

If you need additional information or want me to test something I'll be happy to do that.

Alfred

Link to comment
Share on other sites

  • 1 month later...
This appears to still be the case (tried updating to latest stable version and latest dev-version). It is a major issue since everything crashes as soon as I try to add another language. I can't reach admin and the site itself breaks. 

If you don't feel comfortable messing with the SQL-data manually, is there any idea how/if/when this might get resolved? 

Link to comment
Share on other sites

  • 3 weeks later...

I installed an additional language on 2.5.27 dev and everything went fine.

Now I added a 3rd language and get several errors:

Session: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_title.data1372' in 'field list'

Session: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'data1372'

Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data_exact1372'

Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data1372'

and warnings

Session: language is missing column field_title.data1372

Session: language nl is missing column field_title.data1372

Prior to installing the 3rd language I created an options field. Upon entering the transaltion for the field options I got errors but I didn't note them down. But I cannot save translations for the options. Field for entering translations remains blank after save.

Maybe add language error is related to the problems with that options field?

I removed the 3rd language and upgraded to 2.5.29 dev. But same errors when adding the 3rd language again.

Link to comment
Share on other sites

  • 3 weeks later...

today I installed the latest dev (2.6 dev) and tried to install language files into the default language. The language files aren't visible, but the backend is translated. Clicking different pages or buttons in the admin result in a fatal error:

Recoverable Fatal Error: Argument 3 passed to LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in E:\xampp\htdocs\devtest\wire\modules\LanguageSupport\LanguageTranslator.php on line 389 and defined (line 106 of E:\xampp\htdocs\devtest\wire\modules\LanguageSupport\LanguageTranslator.php)
This error message was shown because you are logged in as a Superuser. Error has been logged.

seems, there is something broken in LanguageTranslator.php

EDIT: found 2 corrupted language files, which caused the problem. Replaced them --> all fine!

  • Like 1
Link to comment
Share on other sites

Now I added a 3rd language and get several errors:

Just wondering if anyone has been able to duplicate this?

I removed the 3rd language and upgraded to 2.5.29 dev. But same errors when adding the 3rd language again.

Since I'm not able to duplicate locally, I'm having to look closely at the error messages: 

Session: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_title.data1372' in 'field list'

Session: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'data1372'
 
 
Did these two occur immediately after each other? On one hand it's saying the column doesn't exist. PW catches that, and attempts to add it. Then it's producing a "column already exists" error. So it's like the column both exists and doesn't exist at the same time. The next thing I would suggest is running a DB repair, as it sounds like something might be corrupted. Though I'm interested to hear if anyone else sees the same problem.
 
We did have an issue here a couple months ago on the dev branch, but it was fixed. It's always possible that something about your DB still has a leftover from when there was a problem. I'm curious if you are able to duplicate the issue on a fresh installation of 2.6? A good way to test would be to install with the "languages" profile that it comes with. Thanks. 
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I have some problems loafing the 3rd language in the empty multilanguage profile.

EN and DE is working ok, but when I'm adding Dutch or FR the permalinks are not changing /fr or /nl

Can someone help me with a quick answer?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...