[Info] phpBB 3.2 Upgrade Notes for Extensions

Discussion forum for Extension Writers regarding Extension Development.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2900
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by KaileyT »

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:
Kailey Truscott - Community Team
aleha
Code Contributor
Posts: 61
Joined: Wed Dec 19, 2012 10:42 pm

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by aleha »

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
Former Team Member
Posts: 16091
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 »

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.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º 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 »

Uhh, I don't know how I missed that. Thank you!
User avatar
MarkDHamill
Registered User
Posts: 4348
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill »

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.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
3Di
Former Team Member
Posts: 16091
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 »

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.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
MarkDHamill
Registered User
Posts: 4348
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill »

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.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4348
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill »

BTW, I upgraded to 3.2 before attempting to make any changes to my extension.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4348
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by MarkDHamill »

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'],
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
RMcGirr83
Former Team Member
Posts: 21835
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by RMcGirr83 »

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
:?:
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5329
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 MattF »

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
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
RMcGirr83
Former Team Member
Posts: 21835
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by RMcGirr83 »

Right, so that would be a BC break from 3.1 to 3.2.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 27130
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 »

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.
martec
Registered User
Posts: 259
Joined: Sat Sep 19, 2009 2:15 pm

Re: phpBB 3.2 Upgrade Notes for Extensions

Post by martec »

sorry, wrong thread.
User avatar
3Di
Former Team Member
Posts: 16091
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 »

Not sure I am missing something, I read the whole topic, but..

how should I translate that line:

foreach ($user->lang['hlposts_tokens'] as $token => $explain)

using the 3.2.'s language object?

edit: forgot to mention the lang it is an array which lies into the language file..

Code: Select all

'hlposts_tokens'	=> array(
	'TOKEN1'		=> 'token1 it is a blah..',
	'TOKEN2'		=> 'token2 it is also blah..',
),
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply

Return to “Extension Writers Discussion”