Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OJS 3.3] Cannot create Announcements: General error: 1364 Field 'setting_type' doesn't have a default value #6748

Closed
davidjb opened this issue Feb 11, 2021 · 11 comments
Assignees
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.

Comments

@davidjb
Copy link

davidjb commented Feb 11, 2021

Describe the bug
Creating an announcement on a journal with fails to create the announcement, erroring with:

Message: SQLSTATE[HY000]: General error: 1364 Field 'setting_type' doesn't have a default value (SQL: INSERT INTO announcement_settings (announcement_id, locale, setting_name, setting_value) VALUES (26, en_US, description, ?)) 

However, a half-created announcement was created; screenshot below. I can delete this fine from the UI.

The insert SQL doesn't supply a setting_type, which is required by the database (setting_type varchar(6) NOT NULL is in my announcement_settings table in the database). Looking at the lib/pkp/classes/migration/AnnouncementsMigration.inc.php sets the field as nullable, but another field in the PKPv3_3 migration, submission_file_settings.setting_type, gets a default type of 'string' set.

To Reproduce

  1. Go to Announcements
  2. Click Add Announcement
  3. Enter a title
  4. Click Save
  5. Note exception in the web server logs

What application are you using?
OJS 3.3.0_3

Additional information
All existing rows in the table have setting_type as 'string'.

Happy to provide a full traceback if required.

Here's how the announcement looks when the creation fails.

image

@drugurkocak
Copy link
Contributor

Hi,
I also experience the same error when I try to insert new announcement. I get a 500 internal server error, and an emtpy (having no title, no body) announcement was added. The annoncements disappeared from tha frontpage, but I can see empty ones in the announcement page.
php-error log contains those lines
Regards,

Previous error:
Type: PDOException
Code: HY000
Message: SQLSTATE[HY000]: General error: 1364 Field 'setting_type' doesn't have a default value
File: /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
Line: 115
Trace: #0 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(115): PDOStatement->execute(NULL)
#1 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(489): Doctrine\DBAL\Driver\PDOStatement->execute()
#2 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\Database\Connection->Illuminate\Database{closure}('INSERT INTO ann...', Array)
#3 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\Database\Connection->runQueryCallback('INSERT INTO ann...', Array, Object(Closure))
#4 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(496): Illuminate\Database\Connection->run('INSERT INTO ann...', Array, Object(Closure))
#5 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php(200): Illuminate\Database\Connection->affectingStatement('INSERT INTO ann...', Array)
#6 /home/adlitipbulteni/public_html/lib/pkp/classes/db/DAO.inc.php(138): Illuminate\Database\Capsule\Manager::__callStatic('affectingStatem...', Array)
#7 /home/adlitipbulteni/public_html/lib/pkp/classes/db/SchemaDAO.inc.php(93): DAO->update('INSERT INTO ann...', Array)
#8 /home/adlitipbulteni/public_html/lib/pkp/classes/services/PKPAnnouncementService.inc.php(211): SchemaDAO->insertObject(Object(Announcement))
#9 /home/adlitipbulteni/public_html/lib/pkp/api/v1/announcements/PKPAnnouncementHandler.inc.php(202): PKP\Services\PKPAnnouncementService->add(Object(Announcement), Object(Request))
#10 [internal function]: PKPAnnouncementHandler->add(Object(Slim\Http\Request), Object(APIResponse), Array)
#11 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func(Array, Object(Slim\Http\Request), Object(APIResponse), Array)
#12 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/Route.php(281): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\Request), Object(APIResponse), Array)
#13 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(APIResponse))
#14 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(APIResponse))
#15 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/App.php(503): Slim\Route->run(Object(Slim\Http\Request), Object(APIResponse))
#16 /home/adlitipbulteni/public_html/lib/pkp/classes/security/authorization/internal/ApiAuthorizationMiddleware.inc.php(77): Slim\App->__invoke(Object(Slim\Http\Request), Object(APIResponse))
#17 [internal function]: ApiAuthorizationMiddleware->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Slim\App))
#18 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(ApiAuthorizationMiddleware), Array)
#19 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Slim\App))
#20 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Slim\App))
#21 /home/adlitipbulteni/public_html/lib/pkp/classes/security/authorization/internal/ApiCsrfMiddleware.inc.php(46): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#22 [internal function]: ApiCsrfMiddleware->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#23 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(ApiCsrfMiddleware), Array)
#24 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#25 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#26 /home/adlitipbulteni/public_html/lib/pkp/classes/security/authorization/internal/ApiTokenDecodingMiddleware.inc.php(121): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#27 [internal function]: ApiTokenDecodingMiddleware->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#28 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(ApiTokenDecodingMiddleware), Array)
#29 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#30 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#31 /home/adlitipbulteni/public_html/lib/pkp/classes/handler/APIHandler.inc.php(68): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#32 [internal function]: APIHandler->{closure}(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#33 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#34 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#35 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#36 /home/adlitipbulteni/public_html/lib/pkp/classes/handler/APIHandler.inc.php(127): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#37 [internal function]: APIHandler->{closure}(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#38 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#39 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#40 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#41 /home/adlitipbulteni/public_html/lib/pkp/classes/handler/APIHandler.inc.php(132): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#42 [internal function]: APIHandler->{closure}(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#43 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#44 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#45 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(APIResponse), Object(Closure))
#46 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(APIResponse))
#47 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(APIResponse))
#48 /home/adlitipbulteni/public_html/lib/pkp/lib/vendor/slim/slim/Slim/App.php(297): Slim\App->process(Object(Slim\Http\Request), Object(APIResponse))
#49 /home/adlitipbulteni/public_html/lib/pkp/classes/core/APIRouter.inc.php(115): Slim\App->run()
#50 /home/adlitipbulteni/public_html/lib/pkp/classes/core/Dispatcher.inc.php(144): APIRouter->route(Object(Request))
#51 /home/adlitipbulteni/public_html/lib/pkp/classes/core/PKPApplication.inc.php(364): Dispatcher->dispatch(Object(Request))
#52 /home/adlitipbulteni/public_html/index.php(68): PKPApplication->execute()
#53 {main}
View in rendered output by enabling the "displayErrorDetails" setting.

@asmecher
Copy link
Member

@davidjb and @drugurkocak, are these upgraded OJS installations or fresh installs?

@asmecher asmecher added this to the OJS/OMP/OPS 3.3.0-4 milestone Feb 11, 2021
@asmecher asmecher added the Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. label Feb 11, 2021
@davidjb
Copy link
Author

davidjb commented Feb 11, 2021

@asmecher Thanks for looking into this!

Mine is an upgrade, originally installed at 2.4.8, upgraded then to 3.2.1 and now to 3.3.0. Originally, the database was set up on a much older version of MySQL; because of this, I had database-encoding upgrading to 3.2.1 (fixed though and working fine for months), and then issues moving to 3.3.0 (detailed at https://forum.pkp.sfu.ca/t/serious-issue-with-database-upgrade-failed-from-3-2-1-3-to-3-3-0-2/65598/27)

@drugurkocak
Copy link
Contributor

@davidjb and @drugurkocak, are these upgraded OJS installations or fresh installs?

Dear @asmecher
Yes, this is an 8 year old database and lastly, it was upgraded from ojs 3.2.1.3 to 3.3.0.3 after applying 2 fixes.

  1. Unable to upgrade 3.3.0.2: Call to a member function getConnection() on null #6703 (comment)
  2. 77fe9dd

Regards,

@drugurkocak
Copy link
Contributor

drugurkocak commented Feb 11, 2021

I just noticed that I can't assign the new announcement to an announcement type since it is not listed on the dialouge. Also, when I click an existing announcement type, a blank (empty) dialogue is opened and a new one is created when I fill the title field. I can add and edit new announcement types, but can't edit or delete the previous types. I can't see any error on php-error.log while editing the announcement types.
Sorry, I get an access denied message when I press remove button for newly created announcement types.
Regards,

@dagosalas
Copy link

I have the same problem, and it is a clean install of OJS 3.3.0-3.
Apart from that, in the expiration date it is an empty input box.

[php7:notice] [pid 13752] [client 148.234.13.27:61705] Slim Application Error:\nType: Illuminate\Database\QueryException\nCode: HY000\nMessage: SQLSTATE[HY000]: General error: 1364 Field 'setting_type' doesn't have a default value

asmecher added a commit that referenced this issue Feb 13, 2021
asmecher added a commit that referenced this issue Feb 13, 2021
@asmecher
Copy link
Member

The issue is caused by upgraded installations not having the setting_type column of announcement_settings set to permit null entries. You can fix already-upgraded installations by running the following SQL query:

ALTER TABLE announcement_settings MODIFY setting_type VARCHAR(6);

However, I would recommend also installing the patch attached to this issue (https://github.com/pkp/pkp-lib/commit/20b2f238e8ed3cd317d216f596edecac2b115a82.diff) -- it corrects some additional minor issues around announcement and announcement type creation.

Your confirmation that this corrects the issue would be helpful!

@asmecher asmecher self-assigned this Feb 13, 2021
@davidjb
Copy link
Author

davidjb commented Feb 13, 2021

@asmecher For all the rows already in the table after the upgrade, their setting_type values are set as ’string’ - do these need to change or be made null? Thanks for the fix; will confirm in the coming days.

Edit: have updated the table in my installation and applied the patch -- all looks good for new entries and existing ones. Thank you!

@drugurkocak
Copy link
Contributor

Hi @asmecher
After running the sql query on the database, and applying the code changes, the issue was resolved after clearing the cache, and reimporting the data into announcement tables.
Thank you very much.

@asmecher
Copy link
Member

do these need to change or be made null?

I think the setting_type column in any table backed by the SchemaDAO is no longer used, as it's taken from the schema file ( lib/pkp/schemas/announcement.json in this case) -- correct, @NateWr?

@NateWr
Copy link
Contributor

NateWr commented Feb 22, 2021

Correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.
Projects
None yet
Development

No branches or pull requests

5 participants