Tuesday, July 10, 2018

Common Koha Bugs

In koha sometime we get "Internal server error" message when try to open MARC record after migration.
to get the error details visit the default koha error path "/var/log/koha/library" and open the log file "plack-error.log"

here is how the file look like


let us focus on the two errors on red and show how can we fix them

if the error message comes after upgrade from very old version of Koha to the latest version.
Software error:
Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1570.

The first solution is that execute a full index of Zebra. Apply following command;

sudo su
koha-rebuild-zebra -f -a -b -v library

if this not success then try to update the Koha source code



1) Use of uninitialized value $tag in hash element at /usr/share/perl5/MARC/Record.pm line 202.

update file "/usr/share/perl5/MARC/Record.pm"
add the next check









2) Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1570.
update file "/usr/share/koha/lib/C4/Biblio.pm"
add the next check


Friday, July 6, 2018

React Native with firebase online free DB

1) Open account on Firebase

2) install firebase component to react native project using
npm install firebase --save

3) Create new account on Firebase URL https://console.firebase.google.com
    then create new project



we will need the code in red area in the next file





React Native Code 

4) Open Firebase DB connection on new page with name 'firebase.js'

import * as firebase from 'firebase';

// Initialize Firebase
const firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxxxx.firebaseio.com",
projectId: "xxxxxxxxx",
storageBucket: "xxxxxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxxxx"
};


let instance = null

class FirebaseService {
constructor() {
try {
if (!instance) {
this.app = firebase.initializeApp(firebaseConfig);
instance = this;
}
return instance;
}
catch (e) {
console.log('Firebase error');
console.log(e);
return null;
}
}
}

const firebaseService = new FirebaseService().app
export default firebaseService;



5) Create code to use Firebase connection
Code does the next jobs: Create Account/Login/LogOut and also for Insert/Update/Select/Delete

import React, { Component } from 'react';
import { Text, View, StyleSheet, LayoutAnimation, Platform, UIManager, TouchableOpacity } from 'react-native';
import firebaseService from './firebase'

export default class FireBaseTest extends React.Component {
componentWillMount() {
//Create account
// firebaseService.auth().createUserWithEmailAndPassword('test@test.com', '123456').catch(function(error) {
// console.log(error);
// });

//Login
// firebaseService.auth().signInWithEmailAndPassword('test@test.com', '123456').catch(function(error) {
// console.log(error);
// });


console.log('Code version 2');

//Insert
firebaseService.database().ref('News/001').set({
Title: 'Test',
Contents: 'Test'
}).then(() => {
//console.log('Insert Done');
}).catch((error) => {
// console.log(error);
});


//Update
firebaseService.database().ref('News/001').update({
Title: 'Update Title Only!'
}).then(() => {
//console.log('Update Done');
}).catch((error) => {
//console.log(error);
});

//=========Select
//Method 1
//Run only once during loading
firebaseService.database().ref('News').once('value', (data) => {
var returnResults = data.toJSON();
console.log(returnResults);
}).then(() => {
//console.log('Select Done');
}).catch((error) => {
//console.log(error);
});
//Method 2
//Run with everytime DB data change
// firebaseService.database().ref('News').on('value', (data) => {
// var returnResults = data.toJSON();
// console.log(returnResults);
// });


//Delete
// firebaseService.database().ref('News/001').remove().then(() => {
// console.log('Done');
// }).catch((error) => {
// console.log(error);
// });


//SignOut
// firebase.auth().signOut().then(function() {
// console.log('Sign-out successful');
// }).catch(function(error) {
// console.log(error);
// });
}


render() {
return (
<View>
<View>
<TouchableOpacity>
<Text>Title</Text>
</TouchableOpacity>
<View>
<Text >
Contents
</Text>
</View>
</View>
</View>
);
}
}