Skip to content

Commit d608802

Browse files
Merge pull request #43 from VSEphpbb/update
Some fixes and updates for phpBB 3.2.x
2 parents f7bae33 + 9d142ee commit d608802

3 files changed

Lines changed: 48 additions & 37 deletions

File tree

ext.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,31 @@ class ext extends \phpbb\extension\base
2828
*/
2929
public function is_enableable()
3030
{
31-
return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=') && class_exists('ZipArchive');
31+
return class_exists('ZipArchive') && ($this->phpbb_legacy_compatibility() || $this->phpbb_current_compatibility());
32+
}
33+
34+
/**
35+
* Check phpBB 3.1 compatibility
36+
*
37+
* Requires phpBB 3.1.4 or greater
38+
*
39+
* @return bool
40+
*/
41+
protected function phpbb_legacy_compatibility()
42+
{
43+
return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<');
44+
}
45+
46+
/**
47+
* Check phpBB 3.2 (and later) compatibility
48+
*
49+
* Requires phpBB 3.2.0-b3 or greater
50+
*
51+
* @return bool
52+
*/
53+
protected function phpbb_current_compatibility()
54+
{
55+
return phpbb_version_compare(PHPBB_VERSION, '3.2.0-b3', '>=');
3256
}
3357
}
3458

helper/packager.php

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -246,45 +246,21 @@ protected function get_template_engine()
246246
}
247247
else
248248
{
249-
// TODO: Remove these hacks once 3.2.x is stable
250-
if ($this->phpbb_container->hasParameter('core.cache_dir'))
251-
{
252-
// Set up for phpBB > 3.2.0-b3
253-
$cache_dir = $this->phpbb_container->getParameter('core.cache_dir');
254-
$environment = new environment(
255-
$config,
256-
$this->phpbb_container->get('filesystem'),
257-
$this->phpbb_container->get('path_helper'),
258-
$cache_dir,
259-
$this->phpbb_container->get('ext.manager'),
260-
new loader(
261-
new \phpbb\filesystem\filesystem()
262-
)
263-
);
264-
}
265-
else
266-
{
267-
// Set up for phpBB 3.2.0-dev to 3.2.0-b2
268-
$cache_dir = $this->phpbb_container->getParameter('core.root_path') . 'cache/';
269-
$environment = new environment(
249+
$template_engine = new twig(
250+
$this->phpbb_container->get('path_helper'),
251+
$config,
252+
new context(),
253+
new environment(
270254
$config,
271255
$this->phpbb_container->get('filesystem'),
272256
$this->phpbb_container->get('path_helper'),
273-
$this->phpbb_container,
274-
$cache_dir,
257+
$this->phpbb_container->getParameter('core.cache_dir'),
275258
$this->phpbb_container->get('ext.manager'),
276259
new loader(
277260
new \phpbb\filesystem\filesystem()
278261
)
279-
);
280-
}
281-
282-
$template_engine = new twig(
283-
$this->phpbb_container->get('path_helper'),
284-
$config,
285-
new context(),
286-
$environment,
287-
$cache_dir,
262+
),
263+
$this->phpbb_container->getParameter('core.cache_dir'),
288264
$this->phpbb_container->get('user')
289265
);
290266
}

skeleton/tests/dbal/simple_test.php.twig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace {{ EXTENSION.vendor_name }}\{{ EXTENSION.extension_name }}\tests\dbal;
1515
1616
// Need to include functions.php to use phpbb_version_compare in this test
17-
require_once dirname(__FILE__) . '/../../../../../includes/functions.php';
17+
require_once __DIR__ . '/../../../../../includes/functions.php';
1818
1919
class simple_test extends \phpbb_database_test_case
2020
{
@@ -28,14 +28,25 @@ class simple_test extends \phpbb_database_test_case
2828
2929
public function getDataSet()
3030
{
31-
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
31+
return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml');
3232
}
3333
3434
public function test_column()
3535
{
3636
$this->db = $this->new_dbal();
37-
$tools = (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<') ? '\phpbb\db\tools' : '\phpbb\db\tools\tools');
38-
$db_tools = new $tools($this->db);
37+
38+
if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<'))
39+
{
40+
// This is how to instantiate db_tools in phpBB 3.1
41+
$db_tools = new \phpbb\db\tools($this->db);
42+
}
43+
else
44+
{
45+
// This is how to instantiate db_tools in phpBB 3.2
46+
$factory = new \phpbb\db\tools\factory();
47+
$db_tools = $factory->get($this->db);
48+
}
49+
3950
$this->assertTrue($db_tools->sql_column_exists(USERS_TABLE, 'user_acme'), 'Asserting that column "user_acme" exists');
4051
$this->assertFalse($db_tools->sql_column_exists(USERS_TABLE, 'user_acme_demo'), 'Asserting that column "user_acme_demo" does not exist');
4152
}

0 commit comments

Comments
 (0)