AU-Landing-Project / au_widgets

Provides a range of widgets and enhancements to existing widgets that provide more customization, including blog, bookmarks, files, groups, pages, random content, liked content and tag tracking
3 stars 0 forks source link

pages widget not compatible with elgg 2.2.x #1

Open oseg opened 7 years ago

oseg commented 7 years ago

There is a database exception in views/default/widgets/pages/content.php when calling: $widget->eligo_subtype = array('page_top', 'page'); It seems the database does not like the array...

[22-Dec-2016 09:14:23 UTC] PHP WARNING: 2016-12-22 09:14:23 (UTC): "PDO::quote() expects parameter 1 to be string, array given" in file C:\xampp\htdocs\elgg-2.2.3\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php (line 115)

[22-Dec-2016 09:14:23 UTC] Exception at time 1482398063: exception 'DatabaseException' with message 'PDO::quote did not return surrounding single quotes.' in C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\Database.php:696 Stack trace:

0 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\Database\PrivateSettingsTable.php(376): Elgg\Database->sanitizeString(Array)

1 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\private_settings.php(99): Elgg\Database\PrivateSettingsTable->set(73, 'eligo_subtype', Array)

2 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\ElggEntity.php(658): set_private_setting(73, 'eligo_subtype', Array)

3 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\ElggWidget.php(80): ElggEntity->setPrivateSetting('eligo_subtype', Array)

4 C:\xampp\htdocs\elgg-2.2.3\mod\au_widgets\views\default\widgets\pages\content.php(10): ElggWidget->__set('eligo_subtype', Array)

5 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(362): include('C:\xampp\htdocs...')

6 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(300): Elgg\ViewsService->renderViewFile('widgets/pages/c...', Array, 'default', true)

7 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\views.php(343): Elgg\ViewsService->renderView('widgets/pages/c...', Array, false, '')

8 C:\xampp\htdocs\elgg-2.2.3\mod\widget_manager\views\default\object\widget\elements\content.php(25): elgg_view('widgets/pages/c...', Array)

9 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(362): include('C:\xampp\htdocs...')

10 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(300): Elgg\ViewsService->renderViewFile('object/widget/e...', Array, 'default', true)

11 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\views.php(343): Elgg\ViewsService->renderView('object/widget/e...', Array, false, '')

12 C:\xampp\htdocs\elgg-2.2.3\mod\widget_manager\views\default\object\widget.php(66): elgg_view('object/widget/e...', Array)

13 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(362): include('C:\xampp\htdocs...')

14 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ViewsService.php(300): Elgg\ViewsService->renderViewFile('object/widget', Array, 'default', true)

15 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\views.php(343): Elgg\ViewsService->renderView('object/widget', Array, false, '')

16 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\views.php(864): elgg_view('object/widget', Array, false, false)

17 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\actions\widgets\add.php(35): elgg_view_entity(Object(ElggWidget), Array)

18 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ActionsService.php(132): include('C:\xampp\htdocs...')

19 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\ActionsService.php(121): Elgg\ActionsService::includeFile('C:\xampp\htdocs...')

20 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\lib\actions.php(20): Elgg\ActionsService->execute('widgets/add')

21 [internal function]: _elgg_action_handler(Array, 'action')

22 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\Router.php(95): call_user_func('_elgg_action_ha...', Array, 'action')

23 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\Application.php(429): Elgg\Router->route(Object(Elgg\Http\Request))

24 C:\xampp\htdocs\elgg-2.2.3\vendor\elgg\elgg\engine\classes\Elgg\Application.php(377): Elgg\Application->run()

25 C:\xampp\htdocs\elgg-2.2.3\index.php(8): Elgg\Application::index()

26 {main}

oseg commented 7 years ago

I workaround the issue

by replacing: $widget->eligo_subtype = array('page_top', 'page'); by $widget->eligo_subtype = 'pages'; in both files views/default/widgets/pages/content.php & views/default/widgets/pages/edit.php

and by replacing

        if (is_array($widget->eligo_subtype)) {
            $options['subtypes'] = $widget->eligo_subtype;

by

        if ($widget->eligo_subtype === 'pages') {
            $options['subtypes'] = array('page_top', 'page');

in both eligo_get_display_entities_options() and eligo_get_selected_entities_options() functions in lib/functions.php

But what about the migration from an elgg v1.12.x to an elgg v2.2.x website ???