phpBB 3.2 Upgrade Notes for Extensions

Discussion forum for Extension Writers regarding Extension Development.
User avatar
kinerity
Registered User
Posts: 1150
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by kinerity » Sun Aug 07, 2016 2:56 pm

kasimi wrote:$phpbb_container->get('language');
This doesn't seem to work - unless I'm doing it wrong. I have an ACP module file with the following:

Code: Select all

global $phpbb_container;
$phpbb_container->get('language');
$language->lang('HOME');
I'm still getting the member function error:
[Sun Aug 07 10:53:23 2016] [error] [client 192.168.1.146] PHP Fatal error: Call to a member function lang() on null in /var/www/html/phpBB3/ext/kinerity/homepage/acp/homepage_module.php on line 34, referer: http://www.project-w.org/phpBB3/adm/ind ... eca81&i=12
*EDIT* Nevermind, forgot to actually define $language :oops:
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

aleha
Code Contributor
Posts: 61
Joined: Wed Dec 19, 2012 10:42 pm

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by aleha » Thu Jan 05, 2017 1:18 am

If I was to use the language object for translation in an exact same file as the exception files for boardrules, my guess is that the next steps are enough, right?
  • For base.php
    • Change add_lang to use the language object instead of the user object.
    • Replace every user object with a language object. That should work for all calls of call_user_func_array.
  • For the rest of the files, just replace the user with the language object.

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by 3Di » Thu Jan 05, 2017 2:38 am

There is already a 3.2-dev branch for board rules, it's up to the author to do some changes there.
https://github.com/phpbb-extensions/boa ... elop-3.2.x

Translators should provide just the language files.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

aleha
Code Contributor
Posts: 61
Joined: Wed Dec 19, 2012 10:42 pm

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by aleha » Thu Jan 05, 2017 12:16 pm

Uhh, I don't know how I missed that. Thank you!

User avatar
MarkDHamill
Registered User
Posts: 3321
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill » Fri Jan 13, 2017 2:29 am

I am changing $this->user->lang to $this->language>lang in my extension. In my ACP interface though the language strings aren't getting translated, although those on the sidebar and the title and legend are.
mass_subscribe.png
Here is a snippet of my code. There have been no changes below the $submit line except global replaces of $this->user->lang to $this->language>lang:

Code: Select all

class main_module
{

	private $auth;
	private $config;
	private $db;
	private $helper;
	private $language;
	private $pagination;
	private $phpbb_extension_manager;
	private $phpbb_log;
	private $phpbb_path_helper;
	private $phpbb_root_path;
	private $phpEx;
	private $request;
	private $table_prefix;
	private $template;
	private $user;

	function __construct()
	{
		global $phpbb_container;

		// Get global variables via containers to minimize security issues
		$this->phpbb_root_path = $phpbb_container->getParameter('core.root_path');
		$this->phpEx= $phpbb_container->getParameter('core.php_ext');
		$this->table_prefix = $phpbb_container->getParameter('core.table_prefix');

		// Encapsulate certain phpBB objects inside this class to minimize security issues
		$this->auth = $phpbb_container->get('auth');
		$this->config = $phpbb_container->get('config');
		$this->db = $phpbb_container->get('dbal.conn');
		$this->helper = $phpbb_container->get('phpbbservices.digests.common');
		$this->language = $phpbb_container->get('language');
		$this->pagination = $phpbb_container->get('pagination');
		$this->phpbb_extension_manager = $phpbb_container->get('ext.manager');
		$this->phpbb_log = $phpbb_container->get('log');
		$this->phpbb_path_helper = $phpbb_container->get('path_helper');
		$this->request = $phpbb_container->get('request');
		$this->template = $phpbb_container->get('template');
		$this->user = $phpbb_container->get('user');
	}

	function main($id, $mode)
	{

		$this->language->add_lang(array('acp/info_acp_common', 'acp/common'), 'phpbbservices/digests');

		$submit = (isset($_POST['submit'])) ? true : false;

		$form_key = 'phpbbservices/digests';
		add_form_key($form_key);

Any idea what may be causing this problem? You can see the full pre 3.2 source here:

https://github.com/MarkDHamill/digests/ ... module.php

The problem has to be in lines of code like this one, which were basically copied and pasted from an ACP example:

Code: Select all

						'phpbbservices_digests_enable_log'					=> array('lang' => 'DIGESTS_ENABLE_LOG',						'validate' => 'bool',	'type' => 'radio:yes_no', 'explain' => true),
I've experimented changing lang to language and adding a L_ prefix but this suppresses the language constants from even showing up.
Last edited by MarkDHamill on Fri Jan 13, 2017 2:54 am, edited 1 time in total.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
3Di
Registered User
Posts: 11864
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by 3Di » Fri Jan 13, 2017 2:48 am

try this
$this->language->add_lang('acp/common', 'phpbbservices/digests');
not tested though.

Note, the language object is meant to be used for extensions coded only for phpBB 3.2 or more, not compatible with the 3.1.x series.

Language files starting with info_* or permissions_* are usually automatically loaded, in 3.1.x at least.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
MarkDHamill
Registered User
Posts: 3321
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill » Fri Jan 13, 2017 2:57 am

3Di wrote:
Fri Jan 13, 2017 2:48 am
try this
$this->language->add_lang('acp/common', 'phpbbservices/digests');
not tested though.

Note, the language object is meant to be used for extensions coded only for phpBB 3.2 or more, not compatible with the 3.1.x series.

Language files starting with info_* or permissions_* are usually automatically loaded, in 3.1.x at least.
I tried one line at a time for each language file instead of using an array in the first parameter but it made no difference.

See the edit in my last post at the bottom.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
MarkDHamill
Registered User
Posts: 3321
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill » Fri Jan 13, 2017 3:00 am

BTW, I upgraded to 3.2 before attempting to make any changes to my extension.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
MarkDHamill
Registered User
Posts: 3321
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill » Fri Jan 13, 2017 3:17 am

Okay, figured it out. Previously in this topic there was a discussion about language variables with arrays. So I had to change a line of code from:

Code: Select all

				'TITLE'			=> (isset($this->language->lang[$vars['lang']])) ? $this->language->lang($vars['lang']) : $vars['lang'],
to:

Code: Select all

				'TITLE'			=> (null !== $this->language->lang($vars['lang'])) ? $this->language->lang($vars['lang']) : $vars['lang'],
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 20424
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by RMcGirr83 » Wed Mar 15, 2017 3:13 pm

Looks like one was missed? Namely dealing with db tools. If a 3.1 extension states the service in the yml file '@dbal.tools' and constructs it in the class as \phpbb\db\tools $db_tools then an error
__construct() must be an instance of phpbb\db\tools, instance of phpbb\db\tools\tools given
:?:
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4482
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by VSE » Tue Mar 21, 2017 11:36 pm

RMcGirr83 wrote:
Wed Mar 15, 2017 3:13 pm
Looks like one was missed? Namely dealing with db tools. If a 3.1 extension states the service in the yml file '@dbal.tools' and constructs it in the class as \phpbb\db\tools $db_tools then an error
__construct() must be an instance of phpbb\db\tools, instance of phpbb\db\tools\tools given
:?:
Try phpbb\db\tools\tools_interface
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.
Dictated but not read.

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 20424
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by RMcGirr83 » Wed Mar 22, 2017 10:01 am

Right, so that would be a BC break from 3.1 to 3.2.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

User avatar
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 23711
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by Paul » Wed Mar 22, 2017 10:18 am

RMcGirr83 wrote:
Wed Mar 22, 2017 10:01 am
Right, so that would be a BC break from 3.1 to 3.2.
As far I know it will be fixed in 3.2.1.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

martec
Registered User
Posts: 171
Joined: Sat Sep 19, 2009 2:15 pm

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by martec » Sat Jun 17, 2017 11:01 am

sorry, wrong thread.

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests