Jump to content

adoxus

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by adoxus

  1. The issue, which I'd like to call Agent Smith Bug, that caused a Repeater/RepeaterMatrix field copying itself onto other same type fields while erasing the contents of the fields happened to me inversely without warning. Fortunately, it happened on a site while it's in development. I installed the module way before while browsing for new modules in the directory, and I forgot it was ever installed. It was later I upgraded the core many times, and available modules with the ProcessWireUpgrade module and later I installed the ProFields.

    I think we need a special cross-checking notification system, just like a product changes its price or availability in Amazon's shopping cart. One way it was achieved, while you're installing a module it shows a warning for the system version. Right there, a system should notify us with a critical warning that module x would possibly break the behavior of module y. In my case, it would be great if the ProFields installation notified me. But how can it know? (Reminds me the Project Insight scene of Winter Soldier) As humans, we can't check every issue, every board entry.  Hence we need a database, testers, modifiers, structural changes, etc. Too many resources, scratch this idea.

  2. 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
×
×
  • Create New...